summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_widestring_unittest.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-08-25 15:34:41 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-08-25 19:57:25 +0000
commited48c1a42b2f9a0c8cb04185c180c6424bad3b83 (patch)
tree34745df62b9982021dfa990b1cec824674033236 /core/fxcrt/cfx_widestring_unittest.cpp
parent175a8588f4290df8ec32d697c0248eb5c6b2c396 (diff)
downloadpdfium-ed48c1a42b2f9a0c8cb04185c180c6424bad3b83.tar.xz
Add help IsValid* methods to string classeschromium/3198chromium/3197
The various string classes, CFX_ByteString, CFX_ByteStringC, CFX_WideString, and CFX_WideStringC, have many conditionals that are effectively determining if a value is a valid index or length. This CL refactors the logic into one place per class, so it only needs to be changed once if its behaviour needs to change. It also make the some of the methods stricter on the inputs they will accept. BUG=pdfium:828 Change-Id: Iadcdaa34a6d862a2804485770027179c89dc6956 Reviewed-on: https://pdfium-review.googlesource.com/12030 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_widestring_unittest.cpp')
-rw-r--r--core/fxcrt/cfx_widestring_unittest.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/core/fxcrt/cfx_widestring_unittest.cpp b/core/fxcrt/cfx_widestring_unittest.cpp
index e688a5334e..0005cb3754 100644
--- a/core/fxcrt/cfx_widestring_unittest.cpp
+++ b/core/fxcrt/cfx_widestring_unittest.cpp
@@ -304,13 +304,6 @@ TEST(fxcrt, WideStringConcatInPlace) {
fred.Concat(L"DY", 2);
EXPECT_EQ(L"FREDDY", fred);
EXPECT_EQ(L"FRED", copy);
-
- // Test invalid arguments.
- copy = fred;
- fred.Concat(L"freddy", -6);
- CFX_WideString not_aliased(L"xxxxxx");
- EXPECT_EQ(L"FREDDY", fred);
- EXPECT_EQ(L"xxxxxx", not_aliased);
}
TEST(fxcrt, WideStringRemove) {
@@ -483,10 +476,10 @@ TEST(fxcrt, WideStringMid) {
EXPECT_EQ(L"D", fred.Mid(3, 1));
EXPECT_EQ(L"FR", fred.Mid(0, 2));
EXPECT_EQ(L"FRED", fred.Mid(0, 4));
- EXPECT_EQ(L"FRED", fred.Mid(0, 10));
+ EXPECT_EQ(L"", fred.Mid(0, 10));
- EXPECT_EQ(L"FR", fred.Mid(-1, 2));
- EXPECT_EQ(L"RED", fred.Mid(1, 4));
+ EXPECT_EQ(L"", fred.Mid(-1, 2));
+ EXPECT_EQ(L"", fred.Mid(1, 4));
EXPECT_EQ(L"", fred.Mid(4, 1));
CFX_WideString empty;
@@ -501,7 +494,7 @@ TEST(fxcrt, WideStringLeft) {
EXPECT_EQ(L"FRE", fred.Left(3));
EXPECT_EQ(L"FRED", fred.Left(4));
- EXPECT_EQ(L"FRED", fred.Left(5));
+ EXPECT_EQ(L"", fred.Left(5));
EXPECT_EQ(L"", fred.Left(-1));
CFX_WideString empty;
@@ -518,7 +511,7 @@ TEST(fxcrt, WideStringRight) {
EXPECT_EQ(L"RED", fred.Right(3));
EXPECT_EQ(L"FRED", fred.Right(4));
- EXPECT_EQ(L"FRED", fred.Right(5));
+ EXPECT_EQ(L"", fred.Right(5));
EXPECT_EQ(L"", fred.Right(-1));
CFX_WideString empty;