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

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

Issue 1126433002: Merge to XFA: Backfill some FX String/StringC unit tests for == and !=. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: 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
« no previous file with comments | « core/src/fxcrt/fx_basic_bstring_unittest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..16d71cb5b8e700f6a4c4643e6b245186dd31a2c6 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 wide_string(L"hello");
+ ASSERT_TRUE(wide_string == wide_string);
+
+ CFX_WideString wide_string_same1(L"hello");
+ ASSERT_TRUE(wide_string == wide_string_same1);
+ ASSERT_TRUE(wide_string_same1 == wide_string);
+
+ CFX_WideString wide_string_same2(wide_string);
+ ASSERT_TRUE(wide_string == wide_string_same2);
+ ASSERT_TRUE(wide_string_same2 == wide_string);
+
+ CFX_WideString wide_string1(L"he");
+ CFX_WideString wide_string2(L"hellp");
+ CFX_WideString wide_string3(L"hellod");
+ ASSERT_FALSE(wide_string == wide_string1);
+ ASSERT_FALSE(wide_string == wide_string2);
+ ASSERT_FALSE(wide_string == wide_string3);
+ ASSERT_FALSE(wide_string1 == wide_string);
+ ASSERT_FALSE(wide_string2 == wide_string);
+ ASSERT_FALSE(wide_string3 == wide_string);
+
+ CFX_WideStringC wide_string_c_same1(L"hello");
+ ASSERT_TRUE(wide_string == wide_string_c_same1);
+ ASSERT_TRUE(wide_string_c_same1 == wide_string);
+
+ CFX_WideStringC wide_string_c1(L"he");
+ CFX_WideStringC wide_string_c2(L"hellp");
+ CFX_WideStringC wide_string_c3(L"hellod");
+ ASSERT_FALSE(wide_string == wide_string_c1);
+ ASSERT_FALSE(wide_string == wide_string_c2);
+ ASSERT_FALSE(wide_string == wide_string_c3);
+ ASSERT_FALSE(wide_string_c1 == wide_string);
+ ASSERT_FALSE(wide_string_c2 == wide_string);
+ ASSERT_FALSE(wide_string_c3 == wide_string);
+
+ const wchar_t* c_string_same1 = L"hello";
+ ASSERT_TRUE(wide_string == c_string_same1);
+#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(c_string_same1 == wide_string);
+#endif
+
+ const wchar_t* c_string1 = L"he";
+ const wchar_t* c_string2 = L"hellp";
+ const wchar_t* c_string3 = L"hellod";
+ ASSERT_FALSE(wide_string == c_string1);
+ ASSERT_FALSE(wide_string == c_string2);
+ ASSERT_FALSE(wide_string == c_string3);
+#if 0
+ // See above TODO.
+ ASSERT_FALSE(c_string1 == wide_string);
+ ASSERT_FALSE(c_string2 == wide_string);
+ ASSERT_FALSE(c_string3 == wide_string);
+#endif
+}
+
+TEST(fxcrt, WideStringOperatorNE) {
+ CFX_WideString wide_string(L"hello");
+ ASSERT_FALSE(wide_string != wide_string);
+
+ CFX_WideString wide_string_same1(L"hello");
+ ASSERT_FALSE(wide_string != wide_string_same1);
+ ASSERT_FALSE(wide_string_same1 != wide_string);
+
+ CFX_WideString wide_string_same2(wide_string);
+ ASSERT_FALSE(wide_string != wide_string_same2);
+ ASSERT_FALSE(wide_string_same2 != wide_string);
+
+ CFX_WideString wide_string1(L"he");
+ CFX_WideString wide_string2(L"hellp");
+ CFX_WideString wide_string3(L"hellod");
+ ASSERT_TRUE(wide_string != wide_string1);
+ ASSERT_TRUE(wide_string != wide_string2);
+ ASSERT_TRUE(wide_string != wide_string3);
+ ASSERT_TRUE(wide_string1 != wide_string);
+ ASSERT_TRUE(wide_string2 != wide_string);
+ ASSERT_TRUE(wide_string3 != wide_string);
+
+ CFX_WideStringC wide_string_c_same1(L"hello");
+ ASSERT_FALSE(wide_string != wide_string_c_same1);
+ ASSERT_FALSE(wide_string_c_same1 != wide_string);
+
+ CFX_WideStringC wide_string_c1(L"he");
+ CFX_WideStringC wide_string_c2(L"hellp");
+ CFX_WideStringC wide_string_c3(L"hellod");
+ ASSERT_TRUE(wide_string != wide_string_c1);
+ ASSERT_TRUE(wide_string != wide_string_c2);
+ ASSERT_TRUE(wide_string != wide_string_c3);
+ ASSERT_TRUE(wide_string_c1 != wide_string);
+ ASSERT_TRUE(wide_string_c2 != wide_string);
+ ASSERT_TRUE(wide_string_c3 != wide_string);
+
+ const wchar_t* c_string_same1 = L"hello";
+ ASSERT_FALSE(wide_string != c_string_same1);
+#if 0
+ // See above TODO.
+ ASSERT_FALSE(c_string_same1 != wide_string);
+#endif
+ const wchar_t* c_string1 = L"he";
+ const wchar_t* c_string2 = L"hellp";
+ const wchar_t* c_string3 = L"hellod";
+ ASSERT_TRUE(wide_string != c_string1);
+ ASSERT_TRUE(wide_string != c_string2);
+ ASSERT_TRUE(wide_string != c_string3);
+#if 0
+ // See above TODO.
+ ASSERT_TRUE(c_string1 != wide_string);
+ ASSERT_TRUE(c_string2 != wide_string);
+ ASSERT_TRUE(c_string3 != wide_string);
+#endif
+}
+
#define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str))
TEST(fxcrt, WideStringUTF16LE_Encode) {
@@ -106,3 +220,112 @@ TEST(fxcrt, WideStringCOperatorLT) {
EXPECT_FALSE(def < abc);
}
+TEST(fxcrt, WideStringCOperatorEQ) {
+ CFX_WideStringC wide_string_c(L"hello");
+ ASSERT_TRUE(wide_string_c == wide_string_c);
+
+ CFX_WideStringC wide_string_c_same1(L"hello");
+ ASSERT_TRUE(wide_string_c == wide_string_c_same1);
+ ASSERT_TRUE(wide_string_c_same1 == wide_string_c);
+
+ CFX_WideStringC wide_string_c_same2(wide_string_c);
+ ASSERT_TRUE(wide_string_c == wide_string_c_same2);
+ ASSERT_TRUE(wide_string_c_same2 == wide_string_c);
+
+ CFX_WideStringC wide_string_c1(L"he");
+ CFX_WideStringC wide_string_c2(L"hellp");
+ CFX_WideStringC wide_string_c3(L"hellod");
+ ASSERT_FALSE(wide_string_c == wide_string_c1);
+ ASSERT_FALSE(wide_string_c == wide_string_c2);
+ ASSERT_FALSE(wide_string_c == wide_string_c3);
+ ASSERT_FALSE(wide_string_c1 == wide_string_c);
+ ASSERT_FALSE(wide_string_c2 == wide_string_c);
+ ASSERT_FALSE(wide_string_c3 == wide_string_c);
+
+ CFX_WideString wide_string_same1(L"hello");
+ ASSERT_TRUE(wide_string_c == wide_string_same1);
+ ASSERT_TRUE(wide_string_same1 == wide_string_c);
+
+ CFX_WideString wide_string1(L"he");
+ CFX_WideString wide_string2(L"hellp");
+ CFX_WideString wide_string3(L"hellod");
+ ASSERT_FALSE(wide_string_c == wide_string1);
+ ASSERT_FALSE(wide_string_c == wide_string2);
+ ASSERT_FALSE(wide_string_c == wide_string3);
+ ASSERT_FALSE(wide_string1 == wide_string_c);
+ ASSERT_FALSE(wide_string2 == wide_string_c);
+ ASSERT_FALSE(wide_string3 == wide_string_c);
+
+#if 0
+ // TODO(tsepez): ambiguos overload prevents compilation
+ const wchar_t* c_string_same1 = L"hello";
+ ASSERT_TRUE(wide_string_c == c_string_same1);
+ ASSERT_TRUE(c_string_same1 == wide_string_c);
+
+ const wchar_t* c_string1 = L"he";
+ const wchar_t* c_string2 = L"hellp";
+ const wchar_t* c_string3 = L"hellod";
+ ASSERT_FALSE(wide_string_c == c_string1);
+ ASSERT_FALSE(wide_string_c == c_string2);
+ ASSERT_FALSE(wide_string_c == c_string3);
+
+ ASSERT_FALSE(c_string1 == wide_string_c);
+ ASSERT_FALSE(c_string2 == wide_string_c);
+ ASSERT_FALSE(c_string3 == wide_string_c);
+#endif
+}
+
+TEST(fxcrt, WideStringCOperatorNE) {
+ CFX_WideStringC wide_string_c(L"hello");
+ ASSERT_FALSE(wide_string_c != wide_string_c);
+
+ CFX_WideStringC wide_string_c_same1(L"hello");
+ ASSERT_FALSE(wide_string_c != wide_string_c_same1);
+ ASSERT_FALSE(wide_string_c_same1 != wide_string_c);
+
+ CFX_WideStringC wide_string_c_same2(wide_string_c);
+ ASSERT_FALSE(wide_string_c != wide_string_c_same2);
+ ASSERT_FALSE(wide_string_c_same2 != wide_string_c);
+
+ CFX_WideStringC wide_string_c1(L"he");
+ CFX_WideStringC wide_string_c2(L"hellp");
+ CFX_WideStringC wide_string_c3(L"hellod");
+ ASSERT_TRUE(wide_string_c != wide_string_c1);
+ ASSERT_TRUE(wide_string_c != wide_string_c2);
+ ASSERT_TRUE(wide_string_c != wide_string_c3);
+ ASSERT_TRUE(wide_string_c1 != wide_string_c);
+ ASSERT_TRUE(wide_string_c2 != wide_string_c);
+ ASSERT_TRUE(wide_string_c3 != wide_string_c);
+
+ CFX_WideString wide_string_same1(L"hello");
+ ASSERT_FALSE(wide_string_c != wide_string_same1);
+ ASSERT_FALSE(wide_string_same1 != wide_string_c);
+
+ CFX_WideString wide_string1(L"he");
+ CFX_WideString wide_string2(L"hellp");
+ CFX_WideString wide_string3(L"hellod");
+ ASSERT_TRUE(wide_string_c != wide_string1);
+ ASSERT_TRUE(wide_string_c != wide_string2);
+ ASSERT_TRUE(wide_string_c != wide_string3);
+ ASSERT_TRUE(wide_string1 != wide_string_c);
+ ASSERT_TRUE(wide_string2 != wide_string_c);
+ ASSERT_TRUE(wide_string3 != wide_string_c);
+
+#if 0
+ // See above TODO.
+ const wchar_t* c_string_same1 = L"hello";
+ ASSERT_FALSE(wide_string_c != c_string_same1);
+ ASSERT_FALSE(c_string_same1 != wide_string_c);
+
+ const wchar_t* c_string1 = L"he";
+ const wchar_t* c_string2 = L"hellp";
+ const wchar_t* c_string3 = L"hellod";
+ ASSERT_TRUE(wide_string_c != c_string1);
+ ASSERT_TRUE(wide_string_c != c_string2);
+ ASSERT_TRUE(wide_string_c != c_string3);
+
+ ASSERT_TRUE(c_string1 != wide_string_c);
+ ASSERT_TRUE(c_string2 != wide_string_c);
+ ASSERT_TRUE(c_string3 != wide_string_c);
+#endif
+}
« no previous file with comments | « 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