diff options
author | Lei Zhang <thestig@chromium.org> | 2017-11-06 19:00:21 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-06 19:00:21 +0000 |
commit | d7a3f981fdc6bf9aef306854505638db7b4b51c7 (patch) | |
tree | bb83ad096cf3618b864e93f4cbb07632a9510368 /core/fxcrt/bytestring_unittest.cpp | |
parent | ac7ce6ec217ba7b4753f4cf2ed80c921d8ea6898 (diff) | |
download | pdfium-d7a3f981fdc6bf9aef306854505638db7b4b51c7.tar.xz |
Improve ByteString{View}::operator<().
Make it possible to compare:
1) const char* < ByteStringView
2) ByteString < const char*
3) ByteString < ByteStringView
4) const char* < ByteString
Do the same for WideString{View}. With new unit test cases.
Change-Id: I31da526b1ab78b8d51ec1c99bf29046fe13754d5
Reviewed-on: https://pdfium-review.googlesource.com/17872
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/bytestring_unittest.cpp')
-rw-r--r-- | core/fxcrt/bytestring_unittest.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/core/fxcrt/bytestring_unittest.cpp b/core/fxcrt/bytestring_unittest.cpp index 9812367fe8..4668fe1cc8 100644 --- a/core/fxcrt/bytestring_unittest.cpp +++ b/core/fxcrt/bytestring_unittest.cpp @@ -55,29 +55,94 @@ TEST(ByteString, OperatorLT) { ByteString a("a"); ByteString abc("abc"); ByteString def("def"); + ByteStringView v_empty; + ByteStringView v_a("a"); + ByteStringView v_abc("abc"); + ByteStringView v_def("def"); + const char* const c_null = nullptr; + const char* const c_empty = ""; + const char* const c_a = "a"; + const char* const c_abc = "abc"; + const char* const c_def = "def"; EXPECT_FALSE(empty < empty); EXPECT_FALSE(a < a); EXPECT_FALSE(abc < abc); EXPECT_FALSE(def < def); + EXPECT_FALSE(c_null < empty); + EXPECT_FALSE(c_empty < empty); + EXPECT_FALSE(c_a < a); + EXPECT_FALSE(c_abc < abc); + EXPECT_FALSE(c_def < def); + EXPECT_FALSE(empty < c_null); + EXPECT_FALSE(empty < c_empty); + EXPECT_FALSE(a < c_a); + EXPECT_FALSE(abc < c_abc); + EXPECT_FALSE(def < c_def); + EXPECT_FALSE(empty < v_empty); + EXPECT_FALSE(a < v_a); + EXPECT_FALSE(abc < v_abc); + EXPECT_FALSE(def < v_def); EXPECT_TRUE(empty < a); EXPECT_FALSE(a < empty); + EXPECT_TRUE(c_null < a); + EXPECT_TRUE(c_empty < a); + EXPECT_FALSE(c_a < empty); + EXPECT_TRUE(empty < c_a); + EXPECT_FALSE(a < c_null); + EXPECT_FALSE(a < c_empty); + EXPECT_TRUE(empty < v_a); + EXPECT_FALSE(a < v_empty); EXPECT_TRUE(empty < abc); EXPECT_FALSE(abc < empty); + EXPECT_TRUE(c_null < abc); + EXPECT_TRUE(c_empty < abc); + EXPECT_FALSE(c_abc < empty); + EXPECT_TRUE(empty < c_abc); + EXPECT_FALSE(abc < c_null); + EXPECT_FALSE(abc < c_empty); + EXPECT_TRUE(empty < v_abc); + EXPECT_FALSE(abc < v_empty); EXPECT_TRUE(empty < def); EXPECT_FALSE(def < empty); + EXPECT_TRUE(c_null < def); + EXPECT_TRUE(c_empty < def); + EXPECT_FALSE(c_def < empty); + EXPECT_TRUE(empty < c_def); + EXPECT_FALSE(def < c_null); + EXPECT_FALSE(def < c_empty); + EXPECT_TRUE(empty < v_def); + EXPECT_FALSE(def < v_empty); EXPECT_TRUE(a < abc); EXPECT_FALSE(abc < a); + EXPECT_TRUE(c_a < abc); + EXPECT_FALSE(c_abc < a); + EXPECT_TRUE(a < c_abc); + EXPECT_FALSE(abc < c_a); + EXPECT_TRUE(a < v_abc); + EXPECT_FALSE(abc < v_a); EXPECT_TRUE(a < def); EXPECT_FALSE(def < a); + EXPECT_TRUE(c_a < def); + EXPECT_FALSE(c_def < a); + EXPECT_TRUE(a < c_def); + EXPECT_FALSE(def < c_a); + EXPECT_TRUE(a < v_def); + EXPECT_FALSE(def < v_a); EXPECT_TRUE(abc < def); EXPECT_FALSE(def < abc); + EXPECT_TRUE(c_abc < def); + EXPECT_FALSE(c_def < abc); + EXPECT_TRUE(abc < c_def); + EXPECT_FALSE(def < c_abc); + EXPECT_TRUE(abc < v_def); + EXPECT_FALSE(def < v_abc); } TEST(ByteString, OperatorEQ) { @@ -1092,29 +1157,59 @@ TEST(ByteStringView, OperatorLT) { ByteStringView a("a"); ByteStringView abc("abc"); ByteStringView def("def"); + const char* const c_null = nullptr; + const char* const c_empty = ""; + const char* const c_a = "a"; + const char* const c_abc = "abc"; + const char* const c_def = "def"; EXPECT_FALSE(empty < empty); EXPECT_FALSE(a < a); EXPECT_FALSE(abc < abc); EXPECT_FALSE(def < def); + EXPECT_FALSE(c_null < empty); + EXPECT_FALSE(c_empty < empty); + EXPECT_FALSE(c_a < a); + EXPECT_FALSE(c_abc < abc); + EXPECT_FALSE(c_def < def); + EXPECT_FALSE(empty < c_null); + EXPECT_FALSE(empty < c_empty); + EXPECT_FALSE(a < c_a); + EXPECT_FALSE(abc < c_abc); + EXPECT_FALSE(def < c_def); EXPECT_TRUE(empty < a); EXPECT_FALSE(a < empty); + EXPECT_TRUE(empty < c_a); + EXPECT_FALSE(a < c_null); + EXPECT_FALSE(a < c_empty); EXPECT_TRUE(empty < abc); EXPECT_FALSE(abc < empty); + EXPECT_TRUE(empty < c_abc); + EXPECT_FALSE(abc < c_null); + EXPECT_FALSE(abc < c_empty); EXPECT_TRUE(empty < def); EXPECT_FALSE(def < empty); + EXPECT_TRUE(empty < c_def); + EXPECT_FALSE(def < c_null); + EXPECT_FALSE(def < c_empty); EXPECT_TRUE(a < abc); EXPECT_FALSE(abc < a); + EXPECT_TRUE(a < c_abc); + EXPECT_FALSE(abc < c_a); EXPECT_TRUE(a < def); EXPECT_FALSE(def < a); + EXPECT_TRUE(a < c_def); + EXPECT_FALSE(def < c_a); EXPECT_TRUE(abc < def); EXPECT_FALSE(def < abc); + EXPECT_TRUE(abc < c_def); + EXPECT_FALSE(def < c_abc); } TEST(ByteStringView, OperatorEQ) { |