summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_basic_wstring_unittest.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-11 17:35:35 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-11 17:35:35 -0700
commitf7fe678a4ada859a2e4fbbeeb0b1dff5b5887227 (patch)
tree271f61e203bcb7026db6b4936668f51f7f5e0de8 /core/fxcrt/fx_basic_wstring_unittest.cpp
parent94dfd56acc7ceb2acfc2e5c7ae516e34b160ea15 (diff)
downloadpdfium-f7fe678a4ada859a2e4fbbeeb0b1dff5b5887227.tar.xz
Add much-needed Find() method for CFX_*StringC
BUG=pdfium:493 Review-Url: https://codereview.chromium.org/1968233002
Diffstat (limited to 'core/fxcrt/fx_basic_wstring_unittest.cpp')
-rw-r--r--core/fxcrt/fx_basic_wstring_unittest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/core/fxcrt/fx_basic_wstring_unittest.cpp b/core/fxcrt/fx_basic_wstring_unittest.cpp
index 02281afd36..4b6f4a5800 100644
--- a/core/fxcrt/fx_basic_wstring_unittest.cpp
+++ b/core/fxcrt/fx_basic_wstring_unittest.cpp
@@ -831,6 +831,31 @@ TEST(fxcrt, WideStringCOperatorNE) {
EXPECT_TRUE(c_string3 != wide_string_c);
}
+TEST(fxcrt, WideStringCFind) {
+ CFX_WideStringC null_string;
+ EXPECT_EQ(-1, null_string.Find(L'a'));
+ EXPECT_EQ(-1, null_string.Find(0));
+
+ CFX_WideStringC empty_string(L"");
+ EXPECT_EQ(-1, empty_string.Find(L'a'));
+ EXPECT_EQ(-1, empty_string.Find(0));
+
+ CFX_WideStringC single_string(L"a");
+ EXPECT_EQ(0, single_string.Find(L'a'));
+ EXPECT_EQ(-1, single_string.Find(L'b'));
+ EXPECT_EQ(-1, single_string.Find(0));
+
+ CFX_WideStringC longer_string(L"abccc");
+ EXPECT_EQ(0, longer_string.Find(L'a'));
+ EXPECT_EQ(2, longer_string.Find(L'c'));
+ EXPECT_EQ(-1, longer_string.Find(0));
+
+ CFX_WideStringC hibyte_string(
+ L"ab\xff08"
+ L"def");
+ EXPECT_EQ(2, hibyte_string.Find(L'\xff08'));
+}
+
TEST(fxcrt, WideStringFormatWidth) {
{
CFX_WideString str;