| 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 |
| 223 TEST(fxcrt, WideStringCOperatorEQ) { |
| 224 CFX_WideStringC wide_string_c(L"hello"); |
| 225 ASSERT_TRUE(wide_string_c == wide_string_c); |
| 226 |
| 227 CFX_WideStringC wide_string_c_same1(L"hello"); |
| 228 ASSERT_TRUE(wide_string_c == wide_string_c_same1); |
| 229 ASSERT_TRUE(wide_string_c_same1 == wide_string_c); |
| 230 |
| 231 CFX_WideStringC wide_string_c_same2(wide_string_c); |
| 232 ASSERT_TRUE(wide_string_c == wide_string_c_same2); |
| 233 ASSERT_TRUE(wide_string_c_same2 == wide_string_c); |
| 234 |
| 235 CFX_WideStringC wide_string_c1(L"he"); |
| 236 CFX_WideStringC wide_string_c2(L"hellp"); |
| 237 CFX_WideStringC wide_string_c3(L"hellod"); |
| 238 ASSERT_FALSE(wide_string_c == wide_string_c1); |
| 239 ASSERT_FALSE(wide_string_c == wide_string_c2); |
| 240 ASSERT_FALSE(wide_string_c == wide_string_c3); |
| 241 ASSERT_FALSE(wide_string_c1 == wide_string_c); |
| 242 ASSERT_FALSE(wide_string_c2 == wide_string_c); |
| 243 ASSERT_FALSE(wide_string_c3 == wide_string_c); |
| 244 |
| 245 CFX_WideString wide_string_same1(L"hello"); |
| 246 ASSERT_TRUE(wide_string_c == wide_string_same1); |
| 247 ASSERT_TRUE(wide_string_same1 == wide_string_c); |
| 248 |
| 249 CFX_WideString wide_string1(L"he"); |
| 250 CFX_WideString wide_string2(L"hellp"); |
| 251 CFX_WideString wide_string3(L"hellod"); |
| 252 ASSERT_FALSE(wide_string_c == wide_string1); |
| 253 ASSERT_FALSE(wide_string_c == wide_string2); |
| 254 ASSERT_FALSE(wide_string_c == wide_string3); |
| 255 ASSERT_FALSE(wide_string1 == wide_string_c); |
| 256 ASSERT_FALSE(wide_string2 == wide_string_c); |
| 257 ASSERT_FALSE(wide_string3 == wide_string_c); |
| 258 |
| 259 #if 0 |
| 260 // TODO(tsepez): ambiguos overload prevents compilation |
| 261 const wchar_t* c_string_same1 = L"hello"; |
| 262 ASSERT_TRUE(wide_string_c == c_string_same1); |
| 263 ASSERT_TRUE(c_string_same1 == wide_string_c); |
| 264 |
| 265 const wchar_t* c_string1 = L"he"; |
| 266 const wchar_t* c_string2 = L"hellp"; |
| 267 const wchar_t* c_string3 = L"hellod"; |
| 268 ASSERT_FALSE(wide_string_c == c_string1); |
| 269 ASSERT_FALSE(wide_string_c == c_string2); |
| 270 ASSERT_FALSE(wide_string_c == c_string3); |
| 271 |
| 272 ASSERT_FALSE(c_string1 == wide_string_c); |
| 273 ASSERT_FALSE(c_string2 == wide_string_c); |
| 274 ASSERT_FALSE(c_string3 == wide_string_c); |
| 275 #endif |
| 276 } |
| 277 |
| 278 TEST(fxcrt, WideStringCOperatorNE) { |
| 279 CFX_WideStringC wide_string_c(L"hello"); |
| 280 ASSERT_FALSE(wide_string_c != wide_string_c); |
| 281 |
| 282 CFX_WideStringC wide_string_c_same1(L"hello"); |
| 283 ASSERT_FALSE(wide_string_c != wide_string_c_same1); |
| 284 ASSERT_FALSE(wide_string_c_same1 != wide_string_c); |
| 285 |
| 286 CFX_WideStringC wide_string_c_same2(wide_string_c); |
| 287 ASSERT_FALSE(wide_string_c != wide_string_c_same2); |
| 288 ASSERT_FALSE(wide_string_c_same2 != wide_string_c); |
| 289 |
| 290 CFX_WideStringC wide_string_c1(L"he"); |
| 291 CFX_WideStringC wide_string_c2(L"hellp"); |
| 292 CFX_WideStringC wide_string_c3(L"hellod"); |
| 293 ASSERT_TRUE(wide_string_c != wide_string_c1); |
| 294 ASSERT_TRUE(wide_string_c != wide_string_c2); |
| 295 ASSERT_TRUE(wide_string_c != wide_string_c3); |
| 296 ASSERT_TRUE(wide_string_c1 != wide_string_c); |
| 297 ASSERT_TRUE(wide_string_c2 != wide_string_c); |
| 298 ASSERT_TRUE(wide_string_c3 != wide_string_c); |
| 299 |
| 300 CFX_WideString wide_string_same1(L"hello"); |
| 301 ASSERT_FALSE(wide_string_c != wide_string_same1); |
| 302 ASSERT_FALSE(wide_string_same1 != wide_string_c); |
| 303 |
| 304 CFX_WideString wide_string1(L"he"); |
| 305 CFX_WideString wide_string2(L"hellp"); |
| 306 CFX_WideString wide_string3(L"hellod"); |
| 307 ASSERT_TRUE(wide_string_c != wide_string1); |
| 308 ASSERT_TRUE(wide_string_c != wide_string2); |
| 309 ASSERT_TRUE(wide_string_c != wide_string3); |
| 310 ASSERT_TRUE(wide_string1 != wide_string_c); |
| 311 ASSERT_TRUE(wide_string2 != wide_string_c); |
| 312 ASSERT_TRUE(wide_string3 != wide_string_c); |
| 313 |
| 314 #if 0 |
| 315 // See above TODO. |
| 316 const wchar_t* c_string_same1 = L"hello"; |
| 317 ASSERT_FALSE(wide_string_c != c_string_same1); |
| 318 ASSERT_FALSE(c_string_same1 != wide_string_c); |
| 319 |
| 320 const wchar_t* c_string1 = L"he"; |
| 321 const wchar_t* c_string2 = L"hellp"; |
| 322 const wchar_t* c_string3 = L"hellod"; |
| 323 ASSERT_TRUE(wide_string_c != c_string1); |
| 324 ASSERT_TRUE(wide_string_c != c_string2); |
| 325 ASSERT_TRUE(wide_string_c != c_string3); |
| 326 |
| 327 ASSERT_TRUE(c_string1 != wide_string_c); |
| 328 ASSERT_TRUE(c_string2 != wide_string_c); |
| 329 ASSERT_TRUE(c_string3 != wide_string_c); |
| 330 #endif |
| 331 } |
| OLD | NEW |