summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_widestring_unittest.cpp
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-05 15:33:18 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-06 13:53:19 +0000
commit81f9eeef041f2974274751d7508598049ae32db2 (patch)
tree00bdcdddc9d141e4929005a14372bde65c68ee81 /core/fxcrt/cfx_widestring_unittest.cpp
parent3ef61c73a97b31000a21e323e04ad5397e517c4c (diff)
downloadpdfium-81f9eeef041f2974274751d7508598049ae32db2.tar.xz
Convert FX_STRSIZE int->size_t
Change the underlying type for FX_STRSIZE to size_t from int. This will make the value unsigned and thus all values in the range of the type will be valid. This allows for the final remove of negative length strings, but also introduces a some casting and functional errors, since many parts of the code base assume that FX_STRSIZE is int or another signed type. This also CL fixes these errors. BUG=pdfium:828 Change-Id: I231dca59e96fc9330cbb099eecbdfc41fcf86f5b Reviewed-on: https://pdfium-review.googlesource.com/11830 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_widestring_unittest.cpp')
-rw-r--r--core/fxcrt/cfx_widestring_unittest.cpp110
1 files changed, 55 insertions, 55 deletions
diff --git a/core/fxcrt/cfx_widestring_unittest.cpp b/core/fxcrt/cfx_widestring_unittest.cpp
index 0005cb3754..1408d10f15 100644
--- a/core/fxcrt/cfx_widestring_unittest.cpp
+++ b/core/fxcrt/cfx_widestring_unittest.cpp
@@ -373,31 +373,31 @@ TEST(fxcrt, WideStringReplace) {
TEST(fxcrt, WideStringInsert) {
CFX_WideString fred(L"FRED");
- EXPECT_EQ(4, fred.Insert(-1, 'X'));
+ EXPECT_EQ(4u, fred.Insert(-1, 'X'));
EXPECT_EQ(L"FRED", fred);
- EXPECT_EQ(5, fred.Insert(0, 'S'));
+ EXPECT_EQ(5u, fred.Insert(0, 'S'));
EXPECT_EQ(L"SFRED", fred);
- EXPECT_EQ(6, fred.Insert(1, 'T'));
+ EXPECT_EQ(6u, fred.Insert(1, 'T'));
EXPECT_EQ(L"STFRED", fred);
- EXPECT_EQ(7, fred.Insert(4, 'U'));
+ EXPECT_EQ(7u, fred.Insert(4, 'U'));
EXPECT_EQ(L"STFRUED", fred);
- EXPECT_EQ(8, fred.Insert(7, 'V'));
+ EXPECT_EQ(8u, fred.Insert(7, 'V'));
EXPECT_EQ(L"STFRUEDV", fred);
- EXPECT_EQ(8, fred.Insert(12, 'P'));
+ EXPECT_EQ(8u, fred.Insert(12, 'P'));
EXPECT_EQ(L"STFRUEDV", fred);
{
CFX_WideString empty;
- EXPECT_EQ(0, empty.Insert(-1, 'X'));
+ EXPECT_EQ(0u, empty.Insert(-1, 'X'));
EXPECT_NE(L"X", empty);
}
{
CFX_WideString empty;
- EXPECT_EQ(1, empty.Insert(0, 'X'));
+ EXPECT_EQ(1u, empty.Insert(0, 'X'));
EXPECT_EQ(L"X", empty);
}
{
CFX_WideString empty;
- EXPECT_EQ(0, empty.Insert(5, 'X'));
+ EXPECT_EQ(0u, empty.Insert(5, 'X'));
EXPECT_NE(L"X", empty);
}
}
@@ -405,60 +405,60 @@ TEST(fxcrt, WideStringInsert) {
TEST(fxcrt, WideStringInsertAtFrontAndInsertAtBack) {
{
CFX_WideString empty;
- EXPECT_EQ(1, empty.InsertAtFront('D'));
+ EXPECT_EQ(1u, empty.InsertAtFront('D'));
EXPECT_EQ(L"D", empty);
- EXPECT_EQ(2, empty.InsertAtFront('E'));
+ EXPECT_EQ(2u, empty.InsertAtFront('E'));
EXPECT_EQ(L"ED", empty);
- EXPECT_EQ(3, empty.InsertAtFront('R'));
+ EXPECT_EQ(3u, empty.InsertAtFront('R'));
EXPECT_EQ(L"RED", empty);
- EXPECT_EQ(4, empty.InsertAtFront('F'));
+ EXPECT_EQ(4u, empty.InsertAtFront('F'));
EXPECT_EQ(L"FRED", empty);
}
{
CFX_WideString empty;
- EXPECT_EQ(1, empty.InsertAtBack('F'));
+ EXPECT_EQ(1u, empty.InsertAtBack('F'));
EXPECT_EQ(L"F", empty);
- EXPECT_EQ(2, empty.InsertAtBack('R'));
+ EXPECT_EQ(2u, empty.InsertAtBack('R'));
EXPECT_EQ(L"FR", empty);
- EXPECT_EQ(3, empty.InsertAtBack('E'));
+ EXPECT_EQ(3u, empty.InsertAtBack('E'));
EXPECT_EQ(L"FRE", empty);
- EXPECT_EQ(4, empty.InsertAtBack('D'));
+ EXPECT_EQ(4u, empty.InsertAtBack('D'));
EXPECT_EQ(L"FRED", empty);
}
{
CFX_WideString empty;
- EXPECT_EQ(1, empty.InsertAtBack('E'));
+ EXPECT_EQ(1u, empty.InsertAtBack('E'));
EXPECT_EQ(L"E", empty);
- EXPECT_EQ(2, empty.InsertAtFront('R'));
+ EXPECT_EQ(2u, empty.InsertAtFront('R'));
EXPECT_EQ(L"RE", empty);
- EXPECT_EQ(3, empty.InsertAtBack('D'));
+ EXPECT_EQ(3u, empty.InsertAtBack('D'));
EXPECT_EQ(L"RED", empty);
- EXPECT_EQ(4, empty.InsertAtFront('F'));
+ EXPECT_EQ(4u, empty.InsertAtFront('F'));
EXPECT_EQ(L"FRED", empty);
}
}
TEST(fxcrt, WideStringDelete) {
CFX_WideString fred(L"FRED");
- EXPECT_EQ(4, fred.Delete(0, 0));
+ EXPECT_EQ(4u, fred.Delete(0, 0));
EXPECT_EQ(L"FRED", fred);
- EXPECT_EQ(2, fred.Delete(0, 2));
+ EXPECT_EQ(2u, fred.Delete(0, 2));
EXPECT_EQ(L"ED", fred);
- EXPECT_EQ(1, fred.Delete(1));
+ EXPECT_EQ(1u, fred.Delete(1));
EXPECT_EQ(L"E", fred);
- EXPECT_EQ(1, fred.Delete(-1));
+ EXPECT_EQ(1u, fred.Delete(-1));
EXPECT_EQ(L"E", fred);
- EXPECT_EQ(0, fred.Delete(0));
+ EXPECT_EQ(0u, fred.Delete(0));
EXPECT_EQ(L"", fred);
- EXPECT_EQ(0, fred.Delete(0));
+ EXPECT_EQ(0u, fred.Delete(0));
EXPECT_EQ(L"", fred);
CFX_WideString empty;
- EXPECT_EQ(0, empty.Delete(0));
+ EXPECT_EQ(0u, empty.Delete(0));
EXPECT_EQ(L"", empty);
- EXPECT_EQ(0, empty.Delete(-1));
+ EXPECT_EQ(0u, empty.Delete(-1));
EXPECT_EQ(L"", empty);
- EXPECT_EQ(0, empty.Delete(1));
+ EXPECT_EQ(0u, empty.Delete(1));
EXPECT_EQ(L"", empty);
}
@@ -533,31 +533,31 @@ TEST(fxcrt, WideStringFind) {
CFX_WideString single_string(L"a");
result = single_string.Find(L'a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.Find(L'b').has_value());
EXPECT_FALSE(single_string.Find(L'\0').has_value());
CFX_WideString longer_string(L"abccc");
result = longer_string.Find(L'a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
result = longer_string.Find(L'c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
result = longer_string.Find(L'c', 3);
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(3, result.value());
+ EXPECT_EQ(3u, result.value());
EXPECT_FALSE(longer_string.Find(L'\0').has_value());
result = longer_string.Find(L"ab");
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
result = longer_string.Find(L"ccc");
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
result = longer_string.Find(L"cc", 3);
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(3, result.value());
+ EXPECT_EQ(3u, result.value());
EXPECT_FALSE(longer_string.Find(L"d").has_value());
CFX_WideString hibyte_string(
@@ -565,7 +565,7 @@ TEST(fxcrt, WideStringFind) {
L"def");
result = hibyte_string.Find(L'\xff8c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
}
TEST(fxcrt, WideStringUpperLower) {
@@ -800,19 +800,19 @@ TEST(fxcrt, WideStringUTF16LE_Encode) {
TEST(fxcrt, WideStringCFromVector) {
std::vector<CFX_WideStringC::UnsignedType> null_vec;
CFX_WideStringC null_string(null_vec);
- EXPECT_EQ(0, null_string.GetLength());
+ EXPECT_EQ(0u, null_string.GetLength());
std::vector<CFX_WideStringC::UnsignedType> lower_a_vec(
10, static_cast<CFX_WideStringC::UnsignedType>(L'a'));
CFX_WideStringC lower_a_string(lower_a_vec);
- EXPECT_EQ(10, lower_a_string.GetLength());
+ EXPECT_EQ(10u, lower_a_string.GetLength());
EXPECT_EQ(L"aaaaaaaaaa", lower_a_string);
std::vector<CFX_WideStringC::UnsignedType> cleared_vec;
cleared_vec.push_back(42);
cleared_vec.pop_back();
CFX_WideStringC cleared_string(cleared_vec);
- EXPECT_EQ(0, cleared_string.GetLength());
+ EXPECT_EQ(0u, cleared_string.GetLength());
EXPECT_EQ(nullptr, cleared_string.raw_str());
}
@@ -976,17 +976,17 @@ TEST(fxcrt, WideStringCFind) {
CFX_WideStringC single_string(L"a");
result = single_string.Find(L'a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.Find(L'b').has_value());
EXPECT_FALSE(single_string.Find(L'\0').has_value());
CFX_WideStringC longer_string(L"abccc");
result = longer_string.Find(L'a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
result = longer_string.Find(L'c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
EXPECT_FALSE(longer_string.Find(L'd').has_value());
EXPECT_FALSE(longer_string.Find(L'\0').has_value());
@@ -995,7 +995,7 @@ TEST(fxcrt, WideStringCFind) {
L"def");
result = hibyte_string.Find(L'\xFF8c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
}
TEST(fxcrt, WideStringCNullIterator) {
@@ -1146,9 +1146,9 @@ TEST(fxcrt, WideStringFormatOutOfRangeChar) {
TEST(fxcrt, EmptyWideString) {
CFX_WideString empty_str;
EXPECT_TRUE(empty_str.IsEmpty());
- EXPECT_EQ(0, empty_str.GetLength());
+ EXPECT_EQ(0u, empty_str.GetLength());
const wchar_t* cstr = empty_str.c_str();
- EXPECT_EQ(0, FXSYS_wcslen(cstr));
+ EXPECT_EQ(0u, FXSYS_wcslen(cstr));
}
TEST(fxcrt, WidStringInitializerList) {
@@ -1255,7 +1255,7 @@ TEST(fxcrt, OStreamWideStringOverload) {
// Writing a CFX_WideString with nulls and no specified length treats it as
// a C-style null-terminated string.
str = CFX_WideString(stringWithNulls);
- EXPECT_EQ(2, str.GetLength());
+ EXPECT_EQ(2u, str.GetLength());
stream.str("");
stream << str;
EXPECT_EQ(2u, stream.tellp());
@@ -1263,7 +1263,7 @@ TEST(fxcrt, OStreamWideStringOverload) {
// Writing a CFX_WideString with nulls but specifying its length treats it as
// a C++-style string.
str = CFX_WideString(stringWithNulls, 4);
- EXPECT_EQ(4, str.GetLength());
+ EXPECT_EQ(4u, str.GetLength());
stream.str("");
stream << str;
EXPECT_EQ(4u, stream.tellp());
@@ -1309,7 +1309,7 @@ TEST(fxcrt, WideOStreamWideStringOverload) {
// Writing a CFX_WideString with nulls and no specified length treats it as
// a C-style null-terminated string.
str = CFX_WideString(stringWithNulls);
- EXPECT_EQ(2, str.GetLength());
+ EXPECT_EQ(2u, str.GetLength());
stream.str(L"");
stream << str;
EXPECT_EQ(2u, stream.tellp());
@@ -1317,7 +1317,7 @@ TEST(fxcrt, WideOStreamWideStringOverload) {
// Writing a CFX_WideString with nulls but specifying its length treats it as
// a C++-style string.
str = CFX_WideString(stringWithNulls, 4);
- EXPECT_EQ(4, str.GetLength());
+ EXPECT_EQ(4u, str.GetLength());
stream.str(L"");
stream << str;
EXPECT_EQ(4u, stream.tellp());
@@ -1381,7 +1381,7 @@ TEST(fxcrt, OStreamWideStringCOverload) {
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
std::ostringstream stream;
CFX_WideStringC str(stringWithNulls);
- EXPECT_EQ(2, str.GetLength());
+ EXPECT_EQ(2u, str.GetLength());
stream << str;
EXPECT_EQ(2u, stream.tellp());
str = L"";
@@ -1393,7 +1393,7 @@ TEST(fxcrt, OStreamWideStringCOverload) {
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
std::ostringstream stream;
CFX_WideStringC str(stringWithNulls, 4);
- EXPECT_EQ(4, str.GetLength());
+ EXPECT_EQ(4u, str.GetLength());
stream << str;
EXPECT_EQ(4u, stream.tellp());
str = L"";
@@ -1460,7 +1460,7 @@ TEST(fxcrt, WideOStreamWideStringCOverload) {
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
std::wostringstream stream;
CFX_WideStringC str(stringWithNulls);
- EXPECT_EQ(2, str.GetLength());
+ EXPECT_EQ(2u, str.GetLength());
stream << str;
EXPECT_EQ(2u, stream.tellp());
}
@@ -1471,7 +1471,7 @@ TEST(fxcrt, WideOStreamWideStringCOverload) {
wchar_t stringWithNulls[]{'x', 'y', '\0', 'z'};
std::wostringstream stream;
CFX_WideStringC str(stringWithNulls, 4);
- EXPECT_EQ(4, str.GetLength());
+ EXPECT_EQ(4u, str.GetLength());
stream << str;
EXPECT_EQ(4u, stream.tellp());
}