From 4871395b676802e4c563c4d5bdf62fa6928020c3 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 7 Aug 2018 19:57:51 +0000 Subject: Add test for {Byte,Wide}String Operator+(). Precursor to converting some Format() operations to simple string addition. Change-Id: I3a159f5ac548ea14586d87e7d56d1ec288898b0d Reviewed-on: https://pdfium-review.googlesource.com/39590 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- core/fxcrt/bytestring_unittest.cpp | 7 +++++++ core/fxcrt/widestring_unittest.cpp | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp index 7095a1b799..abc3648f18 100644 --- a/core/fxcrt/bytestring_unittest.cpp +++ b/core/fxcrt/bytestring_unittest.cpp @@ -390,6 +390,13 @@ TEST(ByteString, OperatorNE) { EXPECT_TRUE(c_string3 != byte_string); } +TEST(ByteString, OperatorPlus) { + EXPECT_EQ("I like dogs", "I like " + ByteString("dogs")); + EXPECT_EQ("Dogs like me", ByteString("Dogs") + " like me"); + EXPECT_EQ("Oh no, error number 42", + "Oh no, error number " + ByteString::Format("%d", 42)); +} + TEST(ByteString, Concat) { ByteString fred; fred.Concat("FRED", 4); diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp index 37d4ecd581..9017fe0c54 100644 --- a/core/fxcrt/widestring_unittest.cpp +++ b/core/fxcrt/widestring_unittest.cpp @@ -395,6 +395,13 @@ TEST(WideString, OperatorNE) { EXPECT_TRUE(c_string3 != wide_string); } +TEST(WideString, OperatorPlus) { + EXPECT_EQ(L"I like dogs", L"I like " + WideString(L"dogs")); + EXPECT_EQ(L"Dogs like me", WideString(L"Dogs") + L" like me"); + EXPECT_EQ(L"Oh no, error number 42", + L"Oh no, error number " + WideString::Format(L"%d", 42)); +} + TEST(WideString, ConcatInPlace) { WideString fred; fred.Concat(L"FRED", 4); -- cgit v1.2.3