Add more tests for string assignment operators.
Change-Id: Ib642da67366d0fe34d1c98654b8fdfcd5d2016fb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/70873
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp
index fe01957..a726b66 100644
--- a/core/fxcrt/bytestring_unittest.cpp
+++ b/core/fxcrt/bytestring_unittest.cpp
@@ -112,6 +112,26 @@
}
EXPECT_EQ(1, string1.ReferenceCountForTesting());
}
+ {
+ // From char*.
+ ByteString string1 = "abc";
+ EXPECT_EQ("abc", string1);
+ string1 = nullptr;
+ EXPECT_TRUE(string1.IsEmpty());
+ string1 = "def";
+ EXPECT_EQ("def", string1);
+ string1 = "";
+ EXPECT_TRUE(string1.IsEmpty());
+ }
+ {
+ // From ByteStringView.
+ ByteString string1(ByteStringView("abc"));
+ EXPECT_EQ("abc", string1);
+ string1 = ByteStringView("");
+ EXPECT_TRUE(string1.IsEmpty());
+ string1 = ByteStringView("def");
+ EXPECT_EQ("def", string1);
+ }
}
TEST(ByteString, OperatorLT) {
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp
index 7114ae4..02c25c1 100644
--- a/core/fxcrt/widestring_unittest.cpp
+++ b/core/fxcrt/widestring_unittest.cpp
@@ -109,6 +109,26 @@
}
EXPECT_EQ(1, string1.ReferenceCountForTesting());
}
+ {
+ // From wchar_t*.
+ WideString string1 = L"abc";
+ EXPECT_EQ(L"abc", string1);
+ string1 = nullptr;
+ EXPECT_TRUE(string1.IsEmpty());
+ string1 = L"def";
+ EXPECT_EQ(L"def", string1);
+ string1 = L"";
+ EXPECT_TRUE(string1.IsEmpty());
+ }
+ {
+ // From WideStringView.
+ WideString string1(WideStringView(L"abc"));
+ EXPECT_EQ(L"abc", string1);
+ string1 = WideStringView(L"");
+ EXPECT_TRUE(string1.IsEmpty());
+ string1 = WideStringView(L"def");
+ EXPECT_EQ(L"def", string1);
+ }
}
TEST(WideString, OperatorLT) {