summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fxcrt/fx_basic_bstring_unittest.cpp108
-rw-r--r--core/src/fxcrt/fx_basic_wstring_unittest.cpp114
2 files changed, 222 insertions, 0 deletions
diff --git a/core/src/fxcrt/fx_basic_bstring_unittest.cpp b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
index 57cfc8047e..0672be6e73 100644
--- a/core/src/fxcrt/fx_basic_bstring_unittest.cpp
+++ b/core/src/fxcrt/fx_basic_bstring_unittest.cpp
@@ -45,6 +45,114 @@ TEST(fxcrt, ByteStringOperatorLT) {
EXPECT_FALSE(def < abc);
}
+TEST(fxcrt, ByteStringOperatorEQ) {
+ CFX_ByteString byte_string("hello");
+ ASSERT_TRUE(byte_string == byte_string);
+
+ CFX_ByteString byte_string_same1("hello");
+ ASSERT_TRUE(byte_string == byte_string_same1);
+ ASSERT_TRUE(byte_string_same1 == byte_string);
+
+ CFX_ByteString byte_string_same2(byte_string);
+ ASSERT_TRUE(byte_string == byte_string_same2);
+ ASSERT_TRUE(byte_string_same2 == byte_string);
+
+ CFX_ByteString byte_string1("he");
+ CFX_ByteString byte_string2("hellp");
+ CFX_ByteString byte_string3("hellod");
+ ASSERT_FALSE(byte_string == byte_string1);
+ ASSERT_FALSE(byte_string == byte_string2);
+ ASSERT_FALSE(byte_string == byte_string3);
+ ASSERT_FALSE(byte_string1 == byte_string);
+ ASSERT_FALSE(byte_string2 == byte_string);
+ ASSERT_FALSE(byte_string3 == byte_string);
+
+ CFX_ByteStringC byte_string_c_same1("hello");
+ ASSERT_TRUE(byte_string == byte_string_c_same1);
+ ASSERT_TRUE(byte_string_c_same1 == byte_string);
+
+ CFX_ByteStringC byte_string_c1("he");
+ CFX_ByteStringC byte_string_c2("hellp");
+ CFX_ByteStringC byte_string_c3("hellod");
+ ASSERT_FALSE(byte_string == byte_string_c1);
+ ASSERT_FALSE(byte_string == byte_string_c2);
+ ASSERT_FALSE(byte_string == byte_string_c3);
+ ASSERT_FALSE(byte_string_c1 == byte_string);
+ ASSERT_FALSE(byte_string_c2 == byte_string);
+ ASSERT_FALSE(byte_string_c3 == byte_string);
+
+ const char* c_string_same1 = "hello";
+ ASSERT_TRUE(byte_string == c_string_same1);
+#if 0
+ // TODO(tsepez): See, you don't want implicit c_str() casting.
+ // This degrades to a pointer comparision, which flunks.
+ ASSERT_TRUE(c_string_same1 == byte_string);
+#endif
+
+ const char* c_string1 = "he";
+ const char* c_string2 = "hellp";
+ const char* c_string3 = "hellod";
+ ASSERT_FALSE(byte_string == c_string1);
+ ASSERT_FALSE(byte_string == c_string2);
+ ASSERT_FALSE(byte_string == c_string3);
+ ASSERT_FALSE(c_string1 == byte_string);
+ ASSERT_FALSE(c_string2 == byte_string);
+ ASSERT_FALSE(c_string3 == byte_string);
+}
+
+TEST(fxcrt, ByteStringOperatorNE) {
+ CFX_ByteString byte_string("hello");
+ ASSERT_FALSE(byte_string != byte_string);
+
+ CFX_ByteString byte_string_same1("hello");
+ ASSERT_FALSE(byte_string != byte_string_same1);
+ ASSERT_FALSE(byte_string_same1 != byte_string);
+
+ CFX_ByteString byte_string_same2(byte_string);
+ ASSERT_FALSE(byte_string != byte_string_same2);
+ ASSERT_FALSE(byte_string_same2 != byte_string);
+
+ CFX_ByteString byte_string1("he");
+ CFX_ByteString byte_string2("hellp");
+ CFX_ByteString byte_string3("hellod");
+ ASSERT_TRUE(byte_string != byte_string1);
+ ASSERT_TRUE(byte_string != byte_string2);
+ ASSERT_TRUE(byte_string != byte_string3);
+ ASSERT_TRUE(byte_string1 != byte_string);
+ ASSERT_TRUE(byte_string2 != byte_string);
+ ASSERT_TRUE(byte_string3 != byte_string);
+
+ CFX_ByteStringC byte_string_c_same1("hello");
+ ASSERT_FALSE(byte_string != byte_string_c_same1);
+ ASSERT_FALSE(byte_string_c_same1 != byte_string);
+
+ CFX_ByteStringC byte_string_c1("he");
+ CFX_ByteStringC byte_string_c2("hellp");
+ CFX_ByteStringC byte_string_c3("hellod");
+ ASSERT_TRUE(byte_string != byte_string_c1);
+ ASSERT_TRUE(byte_string != byte_string_c2);
+ ASSERT_TRUE(byte_string != byte_string_c3);
+ ASSERT_TRUE(byte_string_c1 != byte_string);
+ ASSERT_TRUE(byte_string_c2 != byte_string);
+ ASSERT_TRUE(byte_string_c3 != byte_string);
+
+ const char* c_string_same1 = "hello";
+ ASSERT_FALSE(byte_string != c_string_same1);
+#if 0
+ // See above TODO.
+ ASSERT_FALSE(c_string_same1 != byte_string);
+#endif
+ const char* c_string1 = "he";
+ const char* c_string2 = "hellp";
+ const char* c_string3 = "hellod";
+ ASSERT_TRUE(byte_string != c_string1);
+ ASSERT_TRUE(byte_string != c_string2);
+ ASSERT_TRUE(byte_string != c_string3);
+ ASSERT_TRUE(c_string1 != byte_string);
+ ASSERT_TRUE(c_string2 != byte_string);
+ ASSERT_TRUE(c_string3 != byte_string);
+}
+
TEST(fxcrt, ByteStringCNull) {
CFX_ByteStringC null_string;
EXPECT_EQ(null_string.GetPtr(), nullptr);
diff --git a/core/src/fxcrt/fx_basic_wstring_unittest.cpp b/core/src/fxcrt/fx_basic_wstring_unittest.cpp
index 084410ad19..a76d06bb72 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) {