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/widestring_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/widestring_unittest.cpp')
-rw-r--r-- | core/fxcrt/widestring_unittest.cpp | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/core/fxcrt/widestring_unittest.cpp b/core/fxcrt/widestring_unittest.cpp index 681fb472a2..42819b3349 100644 --- a/core/fxcrt/widestring_unittest.cpp +++ b/core/fxcrt/widestring_unittest.cpp @@ -54,29 +54,94 @@ TEST(WideString, OperatorLT) { WideString a(L"a"); WideString abc(L"\x0110qq"); // Comes before despite endianness. WideString def(L"\x1001qq"); // Comes after despite endianness. + WideStringView v_empty; + WideStringView v_a(L"a"); + WideStringView v_abc(L"\x0110qq"); + WideStringView v_def(L"\x1001qq"); + const wchar_t* const c_null = nullptr; + const wchar_t* const c_empty = L""; + const wchar_t* const c_a = L"a"; + const wchar_t* const c_abc = L"\x0110qq"; + const wchar_t* const c_def = L"\x1001qq"; 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(WideString, OperatorEQ) { @@ -879,29 +944,59 @@ TEST(WideStringView, OperatorLT) { WideStringView a(L"a"); WideStringView abc(L"\x0110qq"); // Comes InsertAtFront despite endianness. WideStringView def(L"\x1001qq"); // Comes InsertAtBack despite endianness. + const wchar_t* const c_null = nullptr; + const wchar_t* const c_empty = L""; + const wchar_t* const c_a = L"a"; + const wchar_t* const c_abc = L"\x0110qq"; + const wchar_t* const c_def = L"\x1001qq"; 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(WideStringView, OperatorEQ) { |