summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/fxcrt/fx_basic_bstring_unittest.cpp114
-rw-r--r--core/src/fxcrt/fx_basic_wstring_unittest.cpp109
2 files changed, 223 insertions, 0 deletions
diff --git a/core/src/fxcrt/fx_basic_bstring_unittest.cpp b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
index 0672be6e73..7259c97b1f 100644
--- a/core/src/fxcrt/fx_basic_bstring_unittest.cpp
+++ b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
@@ -376,3 +376,117 @@ TEST(fxcrt, ByteStringCOperatorLT) {
EXPECT_TRUE(abc < def);
EXPECT_FALSE(def < abc);
}
+
+TEST(fxcrt, ByteStringCOperatorEQ) {
+ CFX_ByteStringC byte_string_c("hello");
+ ASSERT_TRUE(byte_string_c == byte_string_c);
+
+ CFX_ByteStringC byte_string_c_same1("hello");
+ ASSERT_TRUE(byte_string_c == byte_string_c_same1);
+ ASSERT_TRUE(byte_string_c_same1 == byte_string_c);
+
+ CFX_ByteStringC byte_string_c_same2(byte_string_c);
+ ASSERT_TRUE(byte_string_c == byte_string_c_same2);
+ ASSERT_TRUE(byte_string_c_same2 == byte_string_c);
+
+ CFX_ByteStringC byte_string_c1("he");
+ CFX_ByteStringC byte_string_c2("hellp");
+ CFX_ByteStringC byte_string_c3("hellod");
+ ASSERT_FALSE(byte_string_c == byte_string_c1);
+ ASSERT_FALSE(byte_string_c == byte_string_c2);
+ ASSERT_FALSE(byte_string_c == byte_string_c3);
+ ASSERT_FALSE(byte_string_c1 == byte_string_c);
+ ASSERT_FALSE(byte_string_c2 == byte_string_c);
+ ASSERT_FALSE(byte_string_c3 == byte_string_c);
+
+ CFX_ByteString byte_string_same1("hello");
+ ASSERT_TRUE(byte_string_c == byte_string_same1);
+ ASSERT_TRUE(byte_string_same1 == byte_string_c);
+
+ CFX_ByteString byte_string1("he");
+ CFX_ByteString byte_string2("hellp");
+ CFX_ByteString byte_string3("hellod");
+ ASSERT_FALSE(byte_string_c == byte_string1);
+ ASSERT_FALSE(byte_string_c == byte_string2);
+ ASSERT_FALSE(byte_string_c == byte_string3);
+ ASSERT_FALSE(byte_string1 == byte_string_c);
+ ASSERT_FALSE(byte_string2 == byte_string_c);
+ ASSERT_FALSE(byte_string3 == byte_string_c);
+
+ const char* c_string_same1 = "hello";
+ ASSERT_TRUE(byte_string_c == c_string_same1);
+#if 0
+ // TODO(tsepez): missing operator (but no implicit cast to c_str).
+ ASSERT_TRUE(c_string_same1 == byte_string_c);
+#endif
+
+ const char* c_string1 = "he";
+ const char* c_string2 = "hellp";
+ const char* c_string3 = "hellod";
+ ASSERT_FALSE(byte_string_c == c_string1);
+ ASSERT_FALSE(byte_string_c == c_string2);
+ ASSERT_FALSE(byte_string_c == c_string3);
+#if 0
+ // See above TODO.
+ ASSERT_FALSE(c_string1 == byte_string_c);
+ ASSERT_FALSE(c_string2 == byte_string_c);
+ ASSERT_FALSE(c_string3 == byte_string_c);
+#endif
+}
+
+TEST(fxcrt, ByteStringCOperatorNE) {
+ CFX_ByteStringC byte_string_c("hello");
+ ASSERT_FALSE(byte_string_c != byte_string_c);
+
+ CFX_ByteStringC byte_string_c_same1("hello");
+ ASSERT_FALSE(byte_string_c != byte_string_c_same1);
+ ASSERT_FALSE(byte_string_c_same1 != byte_string_c);
+
+ CFX_ByteStringC byte_string_c_same2(byte_string_c);
+ ASSERT_FALSE(byte_string_c != byte_string_c_same2);
+ ASSERT_FALSE(byte_string_c_same2 != byte_string_c);
+
+ CFX_ByteStringC byte_string_c1("he");
+ CFX_ByteStringC byte_string_c2("hellp");
+ CFX_ByteStringC byte_string_c3("hellod");
+ ASSERT_TRUE(byte_string_c != byte_string_c1);
+ ASSERT_TRUE(byte_string_c != byte_string_c2);
+ ASSERT_TRUE(byte_string_c != byte_string_c3);
+ ASSERT_TRUE(byte_string_c1 != byte_string_c);
+ ASSERT_TRUE(byte_string_c2 != byte_string_c);
+ ASSERT_TRUE(byte_string_c3 != byte_string_c);
+
+ CFX_ByteString byte_string_same1("hello");
+ ASSERT_FALSE(byte_string_c != byte_string_same1);
+ ASSERT_FALSE(byte_string_same1 != byte_string_c);
+
+ CFX_ByteString byte_string1("he");
+ CFX_ByteString byte_string2("hellp");
+ CFX_ByteString byte_string3("hellod");
+ ASSERT_TRUE(byte_string_c != byte_string1);
+ ASSERT_TRUE(byte_string_c != byte_string2);
+ ASSERT_TRUE(byte_string_c != byte_string3);
+ ASSERT_TRUE(byte_string1 != byte_string_c);
+ ASSERT_TRUE(byte_string2 != byte_string_c);
+ ASSERT_TRUE(byte_string3 != byte_string_c);
+
+ const char* c_string_same1 = "hello";
+ ASSERT_FALSE(byte_string_c != c_string_same1);
+#if 0
+ // TODO(tsepez): missing operator (but no implicit cast to c_str).
+ ASSERT_FALSE(c_string_same1 != byte_string_c);
+#endif
+
+ const char* c_string1 = "he";
+ const char* c_string2 = "hellp";
+ const char* c_string3 = "hellod";
+ ASSERT_TRUE(byte_string_c != c_string1);
+ ASSERT_TRUE(byte_string_c != c_string2);
+ ASSERT_TRUE(byte_string_c != c_string3);
+#if 0
+ // See above TODO.
+ ASSERT_TRUE(c_string1 != byte_string_c);
+ ASSERT_TRUE(c_string2 != byte_string_c);
+ ASSERT_TRUE(c_string3 != byte_string_c);
+#endif
+}
diff --git a/core/src/fxcrt/fx_basic_wstring_unittest.cpp b/core/src/fxcrt/fx_basic_wstring_unittest.cpp
index a76d06bb72..16d71cb5b8 100644
--- a/core/src/fxcrt/fx_basic_wstring_unittest.cpp
+++ b/core/src/fxcrt/fx_basic_wstring_unittest.cpp
@@ -220,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
+}