diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-04-22 12:04:14 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-04-22 12:04:14 -0700 |
commit | 1ddf056da74de0a34631b8a719f4f02b4ec82144 (patch) | |
tree | 45217449a89d4286a903c76774971c1c2c6c38e4 /core/src/fxcrt/fx_basic_bstring_unittest.cpp | |
parent | ea6a069e6e593d97513e86fc761cf789a9714c22 (diff) | |
download | pdfium-1ddf056da74de0a34631b8a719f4f02b4ec82144.tar.xz |
Add missing operators for CFX_ByteStringC.
Removing the implicit cast operator forces a build breakage should we
use ByteStringC in STL containers. Adding an operator< restores correct
behaviour. Adding an operator[] avoids re-writing some code to call
GetPtr() prior to array indexing.
Part 1 of 4.
R=thestig@chromium.org
TBR=brucedawson@chromium.org
BUG=pdfium:142.
Review URL: https://codereview.chromium.org/1090303003
Diffstat (limited to 'core/src/fxcrt/fx_basic_bstring_unittest.cpp')
-rw-r--r-- | core/src/fxcrt/fx_basic_bstring_unittest.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/core/src/fxcrt/fx_basic_bstring_unittest.cpp b/core/src/fxcrt/fx_basic_bstring_unittest.cpp index 1ddaad420a..57cfc8047e 100644 --- a/core/src/fxcrt/fx_basic_bstring_unittest.cpp +++ b/core/src/fxcrt/fx_basic_bstring_unittest.cpp @@ -229,3 +229,42 @@ TEST(fxcrt, ByteStringCGetAt) { EXPECT_EQ('\0', embedded_nul_string.GetAt(2)); EXPECT_EQ('c', embedded_nul_string.GetAt(3)); } + +TEST(fxcrt, ByteStringCOperatorSubscript) { + // CFX_ByteStringC includes the NUL terminator for non-empty strings. + CFX_ByteStringC abc("abc"); + EXPECT_EQ('a', abc[0]); + EXPECT_EQ('b', abc[1]); + EXPECT_EQ('c', abc[2]); + EXPECT_EQ(0, abc[3]); +} + +TEST(fxcrt, ByteStringCOperatorLT) { + CFX_ByteStringC empty; + CFX_ByteStringC a("a"); + CFX_ByteStringC abc("abc"); + CFX_ByteStringC def("def"); + + EXPECT_FALSE(empty < empty); + EXPECT_FALSE(a < a); + EXPECT_FALSE(abc < abc); + EXPECT_FALSE(def < def); + + EXPECT_TRUE(empty < a); + EXPECT_FALSE(a < empty); + + EXPECT_TRUE(empty < abc); + EXPECT_FALSE(abc < empty); + + EXPECT_TRUE(empty < def); + EXPECT_FALSE(def < empty); + + EXPECT_TRUE(a < abc); + EXPECT_FALSE(abc < a); + + EXPECT_TRUE(a < def); + EXPECT_FALSE(def < a); + + EXPECT_TRUE(abc < def); + EXPECT_FALSE(def < abc); +} |