| 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, ByteStringOperatorSubscript) { | 9 TEST(fxcrt, ByteStringOperatorSubscript) { |
| 10 // CFX_ByteString includes the NUL terminator for non-empty strings. | 10 // CFX_ByteString includes the NUL terminator for non-empty strings. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 CFX_ByteStringC byte_string_c3("hellod"); | 76 CFX_ByteStringC byte_string_c3("hellod"); |
| 77 ASSERT_FALSE(byte_string == byte_string_c1); | 77 ASSERT_FALSE(byte_string == byte_string_c1); |
| 78 ASSERT_FALSE(byte_string == byte_string_c2); | 78 ASSERT_FALSE(byte_string == byte_string_c2); |
| 79 ASSERT_FALSE(byte_string == byte_string_c3); | 79 ASSERT_FALSE(byte_string == byte_string_c3); |
| 80 ASSERT_FALSE(byte_string_c1 == byte_string); | 80 ASSERT_FALSE(byte_string_c1 == byte_string); |
| 81 ASSERT_FALSE(byte_string_c2 == byte_string); | 81 ASSERT_FALSE(byte_string_c2 == byte_string); |
| 82 ASSERT_FALSE(byte_string_c3 == byte_string); | 82 ASSERT_FALSE(byte_string_c3 == byte_string); |
| 83 | 83 |
| 84 const char* c_string_same1 = "hello"; | 84 const char* c_string_same1 = "hello"; |
| 85 ASSERT_TRUE(byte_string == c_string_same1); | 85 ASSERT_TRUE(byte_string == c_string_same1); |
| 86 #if 0 | |
| 87 // TODO(tsepez): See, you don't want implicit c_str() casting. | |
| 88 // This degrades to a pointer comparision, which flunks. | |
| 89 ASSERT_TRUE(c_string_same1 == byte_string); | 86 ASSERT_TRUE(c_string_same1 == byte_string); |
| 90 #endif | |
| 91 | 87 |
| 92 const char* c_string1 = "he"; | 88 const char* c_string1 = "he"; |
| 93 const char* c_string2 = "hellp"; | 89 const char* c_string2 = "hellp"; |
| 94 const char* c_string3 = "hellod"; | 90 const char* c_string3 = "hellod"; |
| 95 ASSERT_FALSE(byte_string == c_string1); | 91 ASSERT_FALSE(byte_string == c_string1); |
| 96 ASSERT_FALSE(byte_string == c_string2); | 92 ASSERT_FALSE(byte_string == c_string2); |
| 97 ASSERT_FALSE(byte_string == c_string3); | 93 ASSERT_FALSE(byte_string == c_string3); |
| 98 ASSERT_FALSE(c_string1 == byte_string); | 94 ASSERT_FALSE(c_string1 == byte_string); |
| 99 ASSERT_FALSE(c_string2 == byte_string); | 95 ASSERT_FALSE(c_string2 == byte_string); |
| 100 ASSERT_FALSE(c_string3 == byte_string); | 96 ASSERT_FALSE(c_string3 == byte_string); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 131 CFX_ByteStringC byte_string_c3("hellod"); | 127 CFX_ByteStringC byte_string_c3("hellod"); |
| 132 ASSERT_TRUE(byte_string != byte_string_c1); | 128 ASSERT_TRUE(byte_string != byte_string_c1); |
| 133 ASSERT_TRUE(byte_string != byte_string_c2); | 129 ASSERT_TRUE(byte_string != byte_string_c2); |
| 134 ASSERT_TRUE(byte_string != byte_string_c3); | 130 ASSERT_TRUE(byte_string != byte_string_c3); |
| 135 ASSERT_TRUE(byte_string_c1 != byte_string); | 131 ASSERT_TRUE(byte_string_c1 != byte_string); |
| 136 ASSERT_TRUE(byte_string_c2 != byte_string); | 132 ASSERT_TRUE(byte_string_c2 != byte_string); |
| 137 ASSERT_TRUE(byte_string_c3 != byte_string); | 133 ASSERT_TRUE(byte_string_c3 != byte_string); |
| 138 | 134 |
| 139 const char* c_string_same1 = "hello"; | 135 const char* c_string_same1 = "hello"; |
| 140 ASSERT_FALSE(byte_string != c_string_same1); | 136 ASSERT_FALSE(byte_string != c_string_same1); |
| 141 #if 0 | |
| 142 // See above TODO. | |
| 143 ASSERT_FALSE(c_string_same1 != byte_string); | 137 ASSERT_FALSE(c_string_same1 != byte_string); |
| 144 #endif | 138 |
| 145 const char* c_string1 = "he"; | 139 const char* c_string1 = "he"; |
| 146 const char* c_string2 = "hellp"; | 140 const char* c_string2 = "hellp"; |
| 147 const char* c_string3 = "hellod"; | 141 const char* c_string3 = "hellod"; |
| 148 ASSERT_TRUE(byte_string != c_string1); | 142 ASSERT_TRUE(byte_string != c_string1); |
| 149 ASSERT_TRUE(byte_string != c_string2); | 143 ASSERT_TRUE(byte_string != c_string2); |
| 150 ASSERT_TRUE(byte_string != c_string3); | 144 ASSERT_TRUE(byte_string != c_string3); |
| 151 ASSERT_TRUE(c_string1 != byte_string); | 145 ASSERT_TRUE(c_string1 != byte_string); |
| 152 ASSERT_TRUE(c_string2 != byte_string); | 146 ASSERT_TRUE(c_string2 != byte_string); |
| 153 ASSERT_TRUE(c_string3 != byte_string); | 147 ASSERT_TRUE(c_string3 != byte_string); |
| 154 } | 148 } |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 CFX_ByteString byte_string3("hellod"); | 402 CFX_ByteString byte_string3("hellod"); |
| 409 ASSERT_FALSE(byte_string_c == byte_string1); | 403 ASSERT_FALSE(byte_string_c == byte_string1); |
| 410 ASSERT_FALSE(byte_string_c == byte_string2); | 404 ASSERT_FALSE(byte_string_c == byte_string2); |
| 411 ASSERT_FALSE(byte_string_c == byte_string3); | 405 ASSERT_FALSE(byte_string_c == byte_string3); |
| 412 ASSERT_FALSE(byte_string1 == byte_string_c); | 406 ASSERT_FALSE(byte_string1 == byte_string_c); |
| 413 ASSERT_FALSE(byte_string2 == byte_string_c); | 407 ASSERT_FALSE(byte_string2 == byte_string_c); |
| 414 ASSERT_FALSE(byte_string3 == byte_string_c); | 408 ASSERT_FALSE(byte_string3 == byte_string_c); |
| 415 | 409 |
| 416 const char* c_string_same1 = "hello"; | 410 const char* c_string_same1 = "hello"; |
| 417 ASSERT_TRUE(byte_string_c == c_string_same1); | 411 ASSERT_TRUE(byte_string_c == c_string_same1); |
| 418 #if 0 | |
| 419 // TODO(tsepez): missing operator (but no implicit cast to c_str). | |
| 420 ASSERT_TRUE(c_string_same1 == byte_string_c); | 412 ASSERT_TRUE(c_string_same1 == byte_string_c); |
| 421 #endif | |
| 422 | 413 |
| 423 const char* c_string1 = "he"; | 414 const char* c_string1 = "he"; |
| 424 const char* c_string2 = "hellp"; | 415 const char* c_string2 = "hellp"; |
| 425 const char* c_string3 = "hellod"; | 416 const char* c_string3 = "hellod"; |
| 426 ASSERT_FALSE(byte_string_c == c_string1); | 417 ASSERT_FALSE(byte_string_c == c_string1); |
| 427 ASSERT_FALSE(byte_string_c == c_string2); | 418 ASSERT_FALSE(byte_string_c == c_string2); |
| 428 ASSERT_FALSE(byte_string_c == c_string3); | 419 ASSERT_FALSE(byte_string_c == c_string3); |
| 429 #if 0 | 420 |
| 430 // See above TODO. | |
| 431 ASSERT_FALSE(c_string1 == byte_string_c); | 421 ASSERT_FALSE(c_string1 == byte_string_c); |
| 432 ASSERT_FALSE(c_string2 == byte_string_c); | 422 ASSERT_FALSE(c_string2 == byte_string_c); |
| 433 ASSERT_FALSE(c_string3 == byte_string_c); | 423 ASSERT_FALSE(c_string3 == byte_string_c); |
| 434 #endif | |
| 435 } | 424 } |
| 436 | 425 |
| 437 TEST(fxcrt, ByteStringCOperatorNE) { | 426 TEST(fxcrt, ByteStringCOperatorNE) { |
| 438 CFX_ByteStringC byte_string_c("hello"); | 427 CFX_ByteStringC byte_string_c("hello"); |
| 439 ASSERT_FALSE(byte_string_c != byte_string_c); | 428 ASSERT_FALSE(byte_string_c != byte_string_c); |
| 440 | 429 |
| 441 CFX_ByteStringC byte_string_c_same1("hello"); | 430 CFX_ByteStringC byte_string_c_same1("hello"); |
| 442 ASSERT_FALSE(byte_string_c != byte_string_c_same1); | 431 ASSERT_FALSE(byte_string_c != byte_string_c_same1); |
| 443 ASSERT_FALSE(byte_string_c_same1 != byte_string_c); | 432 ASSERT_FALSE(byte_string_c_same1 != byte_string_c); |
| 444 | 433 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 465 CFX_ByteString byte_string3("hellod"); | 454 CFX_ByteString byte_string3("hellod"); |
| 466 ASSERT_TRUE(byte_string_c != byte_string1); | 455 ASSERT_TRUE(byte_string_c != byte_string1); |
| 467 ASSERT_TRUE(byte_string_c != byte_string2); | 456 ASSERT_TRUE(byte_string_c != byte_string2); |
| 468 ASSERT_TRUE(byte_string_c != byte_string3); | 457 ASSERT_TRUE(byte_string_c != byte_string3); |
| 469 ASSERT_TRUE(byte_string1 != byte_string_c); | 458 ASSERT_TRUE(byte_string1 != byte_string_c); |
| 470 ASSERT_TRUE(byte_string2 != byte_string_c); | 459 ASSERT_TRUE(byte_string2 != byte_string_c); |
| 471 ASSERT_TRUE(byte_string3 != byte_string_c); | 460 ASSERT_TRUE(byte_string3 != byte_string_c); |
| 472 | 461 |
| 473 const char* c_string_same1 = "hello"; | 462 const char* c_string_same1 = "hello"; |
| 474 ASSERT_FALSE(byte_string_c != c_string_same1); | 463 ASSERT_FALSE(byte_string_c != c_string_same1); |
| 475 #if 0 | |
| 476 // TODO(tsepez): missing operator (but no implicit cast to c_str). | |
| 477 ASSERT_FALSE(c_string_same1 != byte_string_c); | 464 ASSERT_FALSE(c_string_same1 != byte_string_c); |
| 478 #endif | |
| 479 | 465 |
| 480 const char* c_string1 = "he"; | 466 const char* c_string1 = "he"; |
| 481 const char* c_string2 = "hellp"; | 467 const char* c_string2 = "hellp"; |
| 482 const char* c_string3 = "hellod"; | 468 const char* c_string3 = "hellod"; |
| 483 ASSERT_TRUE(byte_string_c != c_string1); | 469 ASSERT_TRUE(byte_string_c != c_string1); |
| 484 ASSERT_TRUE(byte_string_c != c_string2); | 470 ASSERT_TRUE(byte_string_c != c_string2); |
| 485 ASSERT_TRUE(byte_string_c != c_string3); | 471 ASSERT_TRUE(byte_string_c != c_string3); |
| 486 #if 0 | 472 |
| 487 // See above TODO. | |
| 488 ASSERT_TRUE(c_string1 != byte_string_c); | 473 ASSERT_TRUE(c_string1 != byte_string_c); |
| 489 ASSERT_TRUE(c_string2 != byte_string_c); | 474 ASSERT_TRUE(c_string2 != byte_string_c); |
| 490 ASSERT_TRUE(c_string3 != byte_string_c); | 475 ASSERT_TRUE(c_string3 != byte_string_c); |
| 491 #endif | |
| 492 } | 476 } |
| OLD | NEW |