| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #include "../../../testing/fx_string_testhelpers.h" | 6 #include "../../../testing/fx_string_testhelpers.h" |
| 7 #include "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
| 8 | 8 |
| 9 TEST(fxcrt, WideStringOperatorSubscript) { | 9 TEST(fxcrt, WideStringOperatorSubscript) { |
| 10 // CFX_WideString includes the NUL terminator for non-empty strings. | 10 // CFX_WideString includes the NUL terminator for non-empty strings. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 EXPECT_TRUE(a < abc); | 38 EXPECT_TRUE(a < abc); |
| 39 EXPECT_FALSE(abc < a); | 39 EXPECT_FALSE(abc < a); |
| 40 | 40 |
| 41 EXPECT_TRUE(a < def); | 41 EXPECT_TRUE(a < def); |
| 42 EXPECT_FALSE(def < a); | 42 EXPECT_FALSE(def < a); |
| 43 | 43 |
| 44 EXPECT_TRUE(abc < def); | 44 EXPECT_TRUE(abc < def); |
| 45 EXPECT_FALSE(def < abc); | 45 EXPECT_FALSE(def < abc); |
| 46 } | 46 } |
| 47 | 47 |
| 48 TEST(fxcrt, WideStringOperatorEQ) { |
| 49 CFX_WideString wide_string(L"hello"); |
| 50 ASSERT_TRUE(wide_string == wide_string); |
| 51 |
| 52 CFX_WideString wide_string_same1(L"hello"); |
| 53 ASSERT_TRUE(wide_string == wide_string_same1); |
| 54 ASSERT_TRUE(wide_string_same1 == wide_string); |
| 55 |
| 56 CFX_WideString wide_string_same2(wide_string); |
| 57 ASSERT_TRUE(wide_string == wide_string_same2); |
| 58 ASSERT_TRUE(wide_string_same2 == wide_string); |
| 59 |
| 60 CFX_WideString wide_string1(L"he"); |
| 61 CFX_WideString wide_string2(L"hellp"); |
| 62 CFX_WideString wide_string3(L"hellod"); |
| 63 ASSERT_FALSE(wide_string == wide_string1); |
| 64 ASSERT_FALSE(wide_string == wide_string2); |
| 65 ASSERT_FALSE(wide_string == wide_string3); |
| 66 ASSERT_FALSE(wide_string1 == wide_string); |
| 67 ASSERT_FALSE(wide_string2 == wide_string); |
| 68 ASSERT_FALSE(wide_string3 == wide_string); |
| 69 |
| 70 CFX_WideStringC wide_string_c_same1(L"hello"); |
| 71 ASSERT_TRUE(wide_string == wide_string_c_same1); |
| 72 ASSERT_TRUE(wide_string_c_same1 == wide_string); |
| 73 |
| 74 CFX_WideStringC wide_string_c1(L"he"); |
| 75 CFX_WideStringC wide_string_c2(L"hellp"); |
| 76 CFX_WideStringC wide_string_c3(L"hellod"); |
| 77 ASSERT_FALSE(wide_string == wide_string_c1); |
| 78 ASSERT_FALSE(wide_string == wide_string_c2); |
| 79 ASSERT_FALSE(wide_string == wide_string_c3); |
| 80 ASSERT_FALSE(wide_string_c1 == wide_string); |
| 81 ASSERT_FALSE(wide_string_c2 == wide_string); |
| 82 ASSERT_FALSE(wide_string_c3 == wide_string); |
| 83 |
| 84 const wchar_t* c_string_same1 = L"hello"; |
| 85 ASSERT_TRUE(wide_string == c_string_same1); |
| 86 #if 0 |
| 87 // TODO(tsepez): Missing operator - there's a prototype but no actual |
| 88 // implementation (at least we already removed implicit c_str() casting). |
| 89 ASSERT_TRUE(c_string_same1 == wide_string); |
| 90 #endif |
| 91 |
| 92 const wchar_t* c_string1 = L"he"; |
| 93 const wchar_t* c_string2 = L"hellp"; |
| 94 const wchar_t* c_string3 = L"hellod"; |
| 95 ASSERT_FALSE(wide_string == c_string1); |
| 96 ASSERT_FALSE(wide_string == c_string2); |
| 97 ASSERT_FALSE(wide_string == c_string3); |
| 98 #if 0 |
| 99 // See above TODO. |
| 100 ASSERT_FALSE(c_string1 == wide_string); |
| 101 ASSERT_FALSE(c_string2 == wide_string); |
| 102 ASSERT_FALSE(c_string3 == wide_string); |
| 103 #endif |
| 104 } |
| 105 |
| 106 TEST(fxcrt, WideStringOperatorNE) { |
| 107 CFX_WideString wide_string(L"hello"); |
| 108 ASSERT_FALSE(wide_string != wide_string); |
| 109 |
| 110 CFX_WideString wide_string_same1(L"hello"); |
| 111 ASSERT_FALSE(wide_string != wide_string_same1); |
| 112 ASSERT_FALSE(wide_string_same1 != wide_string); |
| 113 |
| 114 CFX_WideString wide_string_same2(wide_string); |
| 115 ASSERT_FALSE(wide_string != wide_string_same2); |
| 116 ASSERT_FALSE(wide_string_same2 != wide_string); |
| 117 |
| 118 CFX_WideString wide_string1(L"he"); |
| 119 CFX_WideString wide_string2(L"hellp"); |
| 120 CFX_WideString wide_string3(L"hellod"); |
| 121 ASSERT_TRUE(wide_string != wide_string1); |
| 122 ASSERT_TRUE(wide_string != wide_string2); |
| 123 ASSERT_TRUE(wide_string != wide_string3); |
| 124 ASSERT_TRUE(wide_string1 != wide_string); |
| 125 ASSERT_TRUE(wide_string2 != wide_string); |
| 126 ASSERT_TRUE(wide_string3 != wide_string); |
| 127 |
| 128 CFX_WideStringC wide_string_c_same1(L"hello"); |
| 129 ASSERT_FALSE(wide_string != wide_string_c_same1); |
| 130 ASSERT_FALSE(wide_string_c_same1 != wide_string); |
| 131 |
| 132 CFX_WideStringC wide_string_c1(L"he"); |
| 133 CFX_WideStringC wide_string_c2(L"hellp"); |
| 134 CFX_WideStringC wide_string_c3(L"hellod"); |
| 135 ASSERT_TRUE(wide_string != wide_string_c1); |
| 136 ASSERT_TRUE(wide_string != wide_string_c2); |
| 137 ASSERT_TRUE(wide_string != wide_string_c3); |
| 138 ASSERT_TRUE(wide_string_c1 != wide_string); |
| 139 ASSERT_TRUE(wide_string_c2 != wide_string); |
| 140 ASSERT_TRUE(wide_string_c3 != wide_string); |
| 141 |
| 142 const wchar_t* c_string_same1 = L"hello"; |
| 143 ASSERT_FALSE(wide_string != c_string_same1); |
| 144 #if 0 |
| 145 // See above TODO. |
| 146 ASSERT_FALSE(c_string_same1 != wide_string); |
| 147 #endif |
| 148 const wchar_t* c_string1 = L"he"; |
| 149 const wchar_t* c_string2 = L"hellp"; |
| 150 const wchar_t* c_string3 = L"hellod"; |
| 151 ASSERT_TRUE(wide_string != c_string1); |
| 152 ASSERT_TRUE(wide_string != c_string2); |
| 153 ASSERT_TRUE(wide_string != c_string3); |
| 154 #if 0 |
| 155 // See above TODO. |
| 156 ASSERT_TRUE(c_string1 != wide_string); |
| 157 ASSERT_TRUE(c_string2 != wide_string); |
| 158 ASSERT_TRUE(c_string3 != wide_string); |
| 159 #endif |
| 160 } |
| 161 |
| 48 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) | 162 #define ByteStringLiteral(str) CFX_ByteString(FX_BSTRC(str)) |
| 49 | 163 |
| 50 TEST(fxcrt, WideStringUTF16LE_Encode) { | 164 TEST(fxcrt, WideStringUTF16LE_Encode) { |
| 51 struct UTF16LEEncodeCase { | 165 struct UTF16LEEncodeCase { |
| 52 CFX_WideString ws; | 166 CFX_WideString ws; |
| 53 CFX_ByteString bs; | 167 CFX_ByteString bs; |
| 54 } utf16le_encode_cases[] = { | 168 } utf16le_encode_cases[] = { |
| 55 { L"", ByteStringLiteral("\0\0") }, | 169 { L"", ByteStringLiteral("\0\0") }, |
| 56 { L"abc", ByteStringLiteral("a\0b\0c\0\0\0") }, | 170 { L"abc", ByteStringLiteral("a\0b\0c\0\0\0") }, |
| 57 { L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0\0\0") }, | 171 { L"abcdef", ByteStringLiteral("a\0b\0c\0d\0e\0f\0\0\0") }, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 EXPECT_TRUE(a < abc); | 213 EXPECT_TRUE(a < abc); |
| 100 EXPECT_FALSE(abc < a); | 214 EXPECT_FALSE(abc < a); |
| 101 | 215 |
| 102 EXPECT_TRUE(a < def); | 216 EXPECT_TRUE(a < def); |
| 103 EXPECT_FALSE(def < a); | 217 EXPECT_FALSE(def < a); |
| 104 | 218 |
| 105 EXPECT_TRUE(abc < def); | 219 EXPECT_TRUE(abc < def); |
| 106 EXPECT_FALSE(def < abc); | 220 EXPECT_FALSE(def < abc); |
| 107 } | 221 } |
| 108 | 222 |
| OLD | NEW |