Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(488)

Unified Diff: core/src/fxcrt/fx_basic_wstring_unittest.cpp

Issue 1122573002: Backfill some FX String unit tests for == and !=. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@retained_strings
Patch Set: rebased Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: core/src/fxcrt/fx_basic_wstring_unittest.cpp
diff --git a/core/src/fxcrt/fx_basic_wstring_unittest.cpp b/core/src/fxcrt/fx_basic_wstring_unittest.cpp
index 084410ad19c40269be872b5eb2b8b51321974f0d..d20f107b1247137a6e4b5e1b6e36a37654205670 100644
--- a/core/src/fxcrt/fx_basic_wstring_unittest.cpp
+++ b/core/src/fxcrt/fx_basic_wstring_unittest.cpp
@@ -45,6 +45,120 @@ TEST(fxcrt, WideStringOperatorLT) {
EXPECT_FALSE(def < abc);
}
+TEST(fxcrt, WideStringOperatorEQ) {
+ CFX_WideString wideString(L"hello");
+ ASSERT_TRUE(wideString == wideString);
+
+ CFX_WideString wideStringSame1(L"hello");
+ ASSERT_TRUE(wideString == wideStringSame1);
+ ASSERT_TRUE(wideStringSame1 == wideString);
+
+ CFX_WideString wideStringSame2(wideString);
+ ASSERT_TRUE(wideString == wideStringSame2);
+ ASSERT_TRUE(wideStringSame2 == wideString);
+
+ CFX_WideString wideString1(L"he");
+ CFX_WideString wideString2(L"hellp");
+ CFX_WideString wideString3(L"hellod");
+ ASSERT_FALSE(wideString == wideString1);
+ ASSERT_FALSE(wideString == wideString2);
+ ASSERT_FALSE(wideString == wideString3);
+ ASSERT_FALSE(wideString1 == wideString);
+ ASSERT_FALSE(wideString2 == wideString);
+ ASSERT_FALSE(wideString3 == wideString);
+
+ CFX_WideStringC wideStringCSame1(L"hello");
+ ASSERT_TRUE(wideString == wideStringCSame1);
+ ASSERT_TRUE(wideStringCSame1 == wideString);
+
+ CFX_WideStringC wideStringC1(L"he");
+ CFX_WideStringC wideStringC2(L"hellp");
+ CFX_WideStringC wideStringC3(L"hellod");
+ ASSERT_FALSE(wideString == wideStringC1);
+ ASSERT_FALSE(wideString == wideStringC2);
+ ASSERT_FALSE(wideString == wideStringC3);
+ ASSERT_FALSE(wideStringC1 == wideString);
+ ASSERT_FALSE(wideStringC2 == wideString);
+ ASSERT_FALSE(wideStringC3 == wideString);
+
+ const wchar_t* cStringSame1 = L"hello";
+ ASSERT_TRUE(wideString == cStringSame1);
+#if 0
+ // TODO(tsepez): Missing operator - there's a prototype but no actual
+ // implementation (at least we already removed implicit c_str() casting).
+ ASSERT_TRUE(cStringSame1 == wideString);
+#endif
+
+ const wchar_t* cString1 = L"he";
+ const wchar_t* cString2 = L"hellp";
+ const wchar_t* cString3 = L"hellod";
+ ASSERT_FALSE(wideString == cString1);
+ ASSERT_FALSE(wideString == cString2);
+ ASSERT_FALSE(wideString == cString3);
+#if 0
+ // See above TODO.
+ ASSERT_FALSE(cString1 == wideString);
+ ASSERT_FALSE(cString2 == wideString);
+ ASSERT_FALSE(cString3 == wideString);
+#endif
+}
+
+TEST(fxcrt, WideStringOperatorNE) {
+ CFX_WideString wideString(L"hello");
+ ASSERT_FALSE(wideString != wideString);
+
+ CFX_WideString wideStringSame1(L"hello");
+ ASSERT_FALSE(wideString != wideStringSame1);
+ ASSERT_FALSE(wideStringSame1 != wideString);
+
+ CFX_WideString wideStringSame2(wideString);
+ ASSERT_FALSE(wideString != wideStringSame2);
+ ASSERT_FALSE(wideStringSame2 != wideString);
+
+ CFX_WideString wideString1(L"he");
+ CFX_WideString wideString2(L"hellp");
+ CFX_WideString wideString3(L"hellod");
+ ASSERT_TRUE(wideString != wideString1);
+ ASSERT_TRUE(wideString != wideString2);
+ ASSERT_TRUE(wideString != wideString3);
+ ASSERT_TRUE(wideString1 != wideString);
+ ASSERT_TRUE(wideString2 != wideString);
+ ASSERT_TRUE(wideString3 != wideString);
+
+ CFX_WideStringC wideStringCSame1(L"hello");
+ ASSERT_FALSE(wideString != wideStringCSame1);
+ ASSERT_FALSE(wideStringCSame1 != wideString);
+
+ CFX_WideStringC wideStringC1(L"he");
+ CFX_WideStringC wideStringC2(L"hellp");
+ CFX_WideStringC wideStringC3(L"hellod");
+ ASSERT_TRUE(wideString != wideStringC1);
+ ASSERT_TRUE(wideString != wideStringC2);
+ ASSERT_TRUE(wideString != wideStringC3);
+ ASSERT_TRUE(wideStringC1 != wideString);
+ ASSERT_TRUE(wideStringC2 != wideString);
+ ASSERT_TRUE(wideStringC3 != wideString);
+
+ const wchar_t* cStringSame1 = L"hello";
+ ASSERT_FALSE(wideString != cStringSame1);
+#if 0
+ // See above TODO.
+ ASSERT_FALSE(cStringSame1 != wideString);
+#endif
+ const wchar_t* cString1 = L"he";
+ const wchar_t* cString2 = L"hellp";
+ const wchar_t* cString3 = L"hellod";
+ ASSERT_TRUE(wideString != cString1);
+ ASSERT_TRUE(wideString != cString2);
+ ASSERT_TRUE(wideString != cString3);
+#if 0
+ // See above TODO.
+ ASSERT_TRUE(cString1 != wideString);
+ ASSERT_TRUE(cString2 != wideString);
+ ASSERT_TRUE(cString3 != wideString);
+#endif
+}
+
#define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str))
TEST(fxcrt, WideStringUTF16LE_Encode) {
« core/src/fxcrt/fx_basic_bstring_unittest.cpp ('K') | « core/src/fxcrt/fx_basic_bstring_unittest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698