summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_bytestring_unittest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/cfx_bytestring_unittest.cpp')
-rw-r--r--core/fxcrt/cfx_bytestring_unittest.cpp134
1 files changed, 67 insertions, 67 deletions
diff --git a/core/fxcrt/cfx_bytestring_unittest.cpp b/core/fxcrt/cfx_bytestring_unittest.cpp
index a590af3b14..415b4621a1 100644
--- a/core/fxcrt/cfx_bytestring_unittest.cpp
+++ b/core/fxcrt/cfx_bytestring_unittest.cpp
@@ -291,7 +291,7 @@ TEST(fxcrt, ByteStringOperatorNE) {
TEST(fxcrt, ByteStringCNull) {
CFX_ByteStringC null_string;
EXPECT_FALSE(null_string.raw_str());
- EXPECT_EQ(0, null_string.GetLength());
+ EXPECT_EQ(0u, null_string.GetLength());
EXPECT_TRUE(null_string.IsEmpty());
CFX_ByteStringC another_null_string;
@@ -299,27 +299,27 @@ TEST(fxcrt, ByteStringCNull) {
CFX_ByteStringC copied_null_string(null_string);
EXPECT_FALSE(copied_null_string.raw_str());
- EXPECT_EQ(0, copied_null_string.GetLength());
+ EXPECT_EQ(0u, copied_null_string.GetLength());
EXPECT_TRUE(copied_null_string.IsEmpty());
EXPECT_EQ(null_string, copied_null_string);
CFX_ByteStringC empty_string(""); // Pointer to NUL, not NULL pointer.
EXPECT_TRUE(empty_string.raw_str());
- EXPECT_EQ(0, empty_string.GetLength());
+ EXPECT_EQ(0u, empty_string.GetLength());
EXPECT_TRUE(empty_string.IsEmpty());
EXPECT_EQ(null_string, empty_string);
CFX_ByteStringC assigned_null_string("initially not nullptr");
assigned_null_string = null_string;
EXPECT_FALSE(assigned_null_string.raw_str());
- EXPECT_EQ(0, assigned_null_string.GetLength());
+ EXPECT_EQ(0u, assigned_null_string.GetLength());
EXPECT_TRUE(assigned_null_string.IsEmpty());
EXPECT_EQ(null_string, assigned_null_string);
CFX_ByteStringC assigned_nullptr_string("initially not nullptr");
assigned_nullptr_string = nullptr;
EXPECT_FALSE(assigned_nullptr_string.raw_str());
- EXPECT_EQ(0, assigned_nullptr_string.GetLength());
+ EXPECT_EQ(0u, assigned_nullptr_string.GetLength());
EXPECT_TRUE(assigned_nullptr_string.IsEmpty());
EXPECT_EQ(null_string, assigned_nullptr_string);
@@ -414,31 +414,31 @@ TEST(fxcrt, ByteStringReplace) {
TEST(fxcrt, ByteStringInsert) {
CFX_ByteString fred("FRED");
- EXPECT_EQ(4, fred.Insert(-1, 'X'));
+ EXPECT_EQ(4u, fred.Insert(-1, 'X'));
EXPECT_EQ("FRED", fred);
- EXPECT_EQ(5, fred.Insert(0, 'S'));
+ EXPECT_EQ(5u, fred.Insert(0, 'S'));
EXPECT_EQ("SFRED", fred);
- EXPECT_EQ(6, fred.Insert(1, 'T'));
+ EXPECT_EQ(6u, fred.Insert(1, 'T'));
EXPECT_EQ("STFRED", fred);
- EXPECT_EQ(7, fred.Insert(4, 'U'));
+ EXPECT_EQ(7u, fred.Insert(4, 'U'));
EXPECT_EQ("STFRUED", fred);
- EXPECT_EQ(8, fred.Insert(7, 'V'));
+ EXPECT_EQ(8u, fred.Insert(7, 'V'));
EXPECT_EQ("STFRUEDV", fred);
- EXPECT_EQ(8, fred.Insert(12, 'P'));
+ EXPECT_EQ(8u, fred.Insert(12, 'P'));
EXPECT_EQ("STFRUEDV", fred);
{
CFX_ByteString empty;
- EXPECT_EQ(0, empty.Insert(-1, 'X'));
+ EXPECT_EQ(0u, empty.Insert(-1, 'X'));
EXPECT_NE("X", empty);
}
{
CFX_ByteString empty;
- EXPECT_EQ(1, empty.Insert(0, 'X'));
+ EXPECT_EQ(1u, empty.Insert(0, 'X'));
EXPECT_EQ("X", empty);
}
{
CFX_ByteString empty;
- EXPECT_EQ(0, empty.Insert(5, 'X'));
+ EXPECT_EQ(0u, empty.Insert(5, 'X'));
EXPECT_NE("X", empty);
}
}
@@ -446,60 +446,60 @@ TEST(fxcrt, ByteStringInsert) {
TEST(fxcrt, ByteStringInsertAtFrontAndInsertAtBack) {
{
CFX_ByteString empty;
- EXPECT_EQ(1, empty.InsertAtFront('D'));
+ EXPECT_EQ(1u, empty.InsertAtFront('D'));
EXPECT_EQ("D", empty);
- EXPECT_EQ(2, empty.InsertAtFront('E'));
+ EXPECT_EQ(2u, empty.InsertAtFront('E'));
EXPECT_EQ("ED", empty);
- EXPECT_EQ(3, empty.InsertAtFront('R'));
+ EXPECT_EQ(3u, empty.InsertAtFront('R'));
EXPECT_EQ("RED", empty);
- EXPECT_EQ(4, empty.InsertAtFront('F'));
+ EXPECT_EQ(4u, empty.InsertAtFront('F'));
EXPECT_EQ("FRED", empty);
}
{
CFX_ByteString empty;
- EXPECT_EQ(1, empty.InsertAtBack('F'));
+ EXPECT_EQ(1u, empty.InsertAtBack('F'));
EXPECT_EQ("F", empty);
- EXPECT_EQ(2, empty.InsertAtBack('R'));
+ EXPECT_EQ(2u, empty.InsertAtBack('R'));
EXPECT_EQ("FR", empty);
- EXPECT_EQ(3, empty.InsertAtBack('E'));
+ EXPECT_EQ(3u, empty.InsertAtBack('E'));
EXPECT_EQ("FRE", empty);
- EXPECT_EQ(4, empty.InsertAtBack('D'));
+ EXPECT_EQ(4u, empty.InsertAtBack('D'));
EXPECT_EQ("FRED", empty);
}
{
CFX_ByteString empty;
- EXPECT_EQ(1, empty.InsertAtBack('E'));
+ EXPECT_EQ(1u, empty.InsertAtBack('E'));
EXPECT_EQ("E", empty);
- EXPECT_EQ(2, empty.InsertAtFront('R'));
+ EXPECT_EQ(2u, empty.InsertAtFront('R'));
EXPECT_EQ("RE", empty);
- EXPECT_EQ(3, empty.InsertAtBack('D'));
+ EXPECT_EQ(3u, empty.InsertAtBack('D'));
EXPECT_EQ("RED", empty);
- EXPECT_EQ(4, empty.InsertAtFront('F'));
+ EXPECT_EQ(4u, empty.InsertAtFront('F'));
EXPECT_EQ("FRED", empty);
}
}
TEST(fxcrt, ByteStringDelete) {
CFX_ByteString fred("FRED");
- EXPECT_EQ(4, fred.Delete(0, 0));
+ EXPECT_EQ(4u, fred.Delete(0, 0));
EXPECT_EQ("FRED", fred);
- EXPECT_EQ(2, fred.Delete(0, 2));
+ EXPECT_EQ(2u, fred.Delete(0, 2));
EXPECT_EQ("ED", fred);
- EXPECT_EQ(1, fred.Delete(1));
+ EXPECT_EQ(1u, fred.Delete(1));
EXPECT_EQ("E", fred);
- EXPECT_EQ(1, fred.Delete(-1));
+ EXPECT_EQ(1u, fred.Delete(-1));
EXPECT_EQ("E", fred);
- EXPECT_EQ(0, fred.Delete(0));
+ EXPECT_EQ(0u, fred.Delete(0));
EXPECT_EQ("", fred);
- EXPECT_EQ(0, fred.Delete(0));
+ EXPECT_EQ(0u, fred.Delete(0));
EXPECT_EQ("", fred);
CFX_ByteString empty;
- EXPECT_EQ(0, empty.Delete(0));
+ EXPECT_EQ(0u, empty.Delete(0));
EXPECT_EQ("", empty);
- EXPECT_EQ(0, empty.Delete(-1));
+ EXPECT_EQ(0u, empty.Delete(-1));
EXPECT_EQ("", empty);
- EXPECT_EQ(0, empty.Delete(1));
+ EXPECT_EQ(0u, empty.Delete(1));
EXPECT_EQ("", empty);
}
@@ -574,32 +574,32 @@ TEST(fxcrt, ByteStringFind) {
CFX_ByteString single_string("a");
result = single_string.Find('a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.Find('b').has_value());
EXPECT_FALSE(single_string.Find('\0').has_value());
CFX_ByteString longer_string("abccc");
result = longer_string.Find('a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
result = longer_string.Find('c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
result = longer_string.Find('c', 3);
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(3, result.value());
+ EXPECT_EQ(3u, result.value());
EXPECT_FALSE(longer_string.Find('d').has_value());
EXPECT_FALSE(longer_string.Find('\0').has_value());
result = longer_string.Find("ab");
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
result = longer_string.Find("ccc");
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
result = longer_string.Find("cc", 3);
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(3, result.value());
+ EXPECT_EQ(3u, result.value());
EXPECT_FALSE(longer_string.Find("d").has_value());
CFX_ByteString hibyte_string(
@@ -607,7 +607,7 @@ TEST(fxcrt, ByteStringFind) {
"def");
result = hibyte_string.Find('\x8c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
}
TEST(fxcrt, ByteStringReverseFind) {
@@ -623,17 +623,17 @@ TEST(fxcrt, ByteStringReverseFind) {
CFX_ByteString single_string("a");
result = single_string.ReverseFind('a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.ReverseFind('b').has_value());
EXPECT_FALSE(single_string.ReverseFind('\0').has_value());
CFX_ByteString longer_string("abccc");
result = longer_string.ReverseFind('a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
result = longer_string.ReverseFind('c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(4, result.value());
+ EXPECT_EQ(4u, result.value());
EXPECT_FALSE(longer_string.ReverseFind('\0').has_value());
CFX_ByteString hibyte_string(
@@ -641,7 +641,7 @@ TEST(fxcrt, ByteStringReverseFind) {
"def");
result = hibyte_string.ReverseFind('\x8c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
}
TEST(fxcrt, ByteStringUpperLower) {
@@ -862,11 +862,11 @@ TEST(fxcrt, ByteStringCNotNull) {
CFX_ByteStringC embedded_nul_string7("abc\0def", 7);
CFX_ByteStringC illegal_string7("abcdef", 7);
- EXPECT_EQ(3, string3.GetLength());
- EXPECT_EQ(6, string6.GetLength());
- EXPECT_EQ(3, alternate_string3.GetLength());
- EXPECT_EQ(7, embedded_nul_string7.GetLength());
- EXPECT_EQ(7, illegal_string7.GetLength());
+ EXPECT_EQ(3u, string3.GetLength());
+ EXPECT_EQ(6u, string6.GetLength());
+ EXPECT_EQ(3u, alternate_string3.GetLength());
+ EXPECT_EQ(7u, embedded_nul_string7.GetLength());
+ EXPECT_EQ(7u, illegal_string7.GetLength());
EXPECT_NE(string3, string6);
EXPECT_EQ(string3, alternate_string3);
@@ -913,10 +913,10 @@ TEST(fxcrt, ByteStringCFromChar) {
CFX_ByteStringC lower_a_string_from_char(lower_a);
// Pointer to nul, not nullptr ptr, hence length 1 ...
- EXPECT_EQ(1, nul_string_from_char.GetLength());
+ EXPECT_EQ(1u, nul_string_from_char.GetLength());
EXPECT_NE(null_string, nul_string_from_char);
- EXPECT_EQ(1, lower_a_string_from_char.GetLength());
+ EXPECT_EQ(1u, lower_a_string_from_char.GetLength());
EXPECT_EQ(lower_a_string, lower_a_string_from_char);
EXPECT_NE(nul_string_from_char, lower_a_string_from_char);
@@ -927,18 +927,18 @@ TEST(fxcrt, ByteStringCFromChar) {
TEST(fxcrt, ByteStringCFromVector) {
std::vector<uint8_t> null_vec;
CFX_ByteStringC null_string(null_vec);
- EXPECT_EQ(0, null_string.GetLength());
+ EXPECT_EQ(0u, null_string.GetLength());
std::vector<uint8_t> lower_a_vec(10, static_cast<uint8_t>('a'));
CFX_ByteStringC lower_a_string(lower_a_vec);
- EXPECT_EQ(10, lower_a_string.GetLength());
+ EXPECT_EQ(static_cast<FX_STRSIZE>(10), lower_a_string.GetLength());
EXPECT_EQ("aaaaaaaaaa", lower_a_string);
std::vector<uint8_t> cleared_vec;
cleared_vec.push_back(42);
cleared_vec.pop_back();
CFX_ByteStringC cleared_string(cleared_vec);
- EXPECT_EQ(0, cleared_string.GetLength());
+ EXPECT_EQ(0u, cleared_string.GetLength());
EXPECT_EQ(nullptr, cleared_string.raw_str());
}
@@ -969,17 +969,17 @@ TEST(fxcrt, ByteStringCFind) {
CFX_ByteStringC single_string("a");
result = single_string.Find('a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
EXPECT_FALSE(single_string.Find('b').has_value());
EXPECT_FALSE(single_string.Find('\0').has_value());
CFX_ByteStringC longer_string("abccc");
result = longer_string.Find('a');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(0, result.value());
+ EXPECT_EQ(0u, result.value());
result = longer_string.Find('c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
EXPECT_FALSE(longer_string.Find('d').has_value());
EXPECT_FALSE(longer_string.Find('\0').has_value());
@@ -988,7 +988,7 @@ TEST(fxcrt, ByteStringCFind) {
"def");
result = hibyte_string.Find('\x8c');
ASSERT_TRUE(result.has_value());
- EXPECT_EQ(2, result.value());
+ EXPECT_EQ(2u, result.value());
}
TEST(fxcrt, ByteStringCMid) {
@@ -1303,9 +1303,9 @@ TEST(fxcrt, ByteStringFormatPrecision) {
TEST(fxcrt, EmptyByteString) {
CFX_ByteString empty_str;
EXPECT_TRUE(empty_str.IsEmpty());
- EXPECT_EQ(0, empty_str.GetLength());
+ EXPECT_EQ(0u, empty_str.GetLength());
const char* cstr = empty_str.c_str();
- EXPECT_EQ(0, FXSYS_strlen(cstr));
+ EXPECT_EQ(0u, FXSYS_strlen(cstr));
}
TEST(fxcrt, ByteStringInitializerList) {
@@ -1420,7 +1420,7 @@ TEST(fxcrt, OStreamByteStringOverload) {
// Writing a CFX_ByteString with nulls and no specified length treats it as
// a C-style null-terminated string.
str = CFX_ByteString(stringWithNulls);
- EXPECT_EQ(2, str.GetLength());
+ EXPECT_EQ(2u, str.GetLength());
stream.str("");
stream << str;
EXPECT_EQ(2u, stream.tellp());
@@ -1428,7 +1428,7 @@ TEST(fxcrt, OStreamByteStringOverload) {
// Writing a CFX_ByteString with nulls but specifying its length treats it as
// a C++-style string.
str = CFX_ByteString(stringWithNulls, 4);
- EXPECT_EQ(4, str.GetLength());
+ EXPECT_EQ(4u, str.GetLength());
stream.str("");
stream << str;
EXPECT_EQ(4u, stream.tellp());
@@ -1484,7 +1484,7 @@ TEST(fxcrt, OStreamByteStringCOverload) {
std::ostringstream stream;
char stringWithNulls[]{'x', 'y', '\0', 'z'};
CFX_ByteStringC str(stringWithNulls);
- EXPECT_EQ(2, str.GetLength());
+ EXPECT_EQ(2u, str.GetLength());
stream << str;
EXPECT_EQ(2u, stream.tellp());
str = "";
@@ -1496,7 +1496,7 @@ TEST(fxcrt, OStreamByteStringCOverload) {
std::ostringstream stream;
char stringWithNulls[]{'x', 'y', '\0', 'z'};
CFX_ByteStringC str(stringWithNulls, 4);
- EXPECT_EQ(4, str.GetLength());
+ EXPECT_EQ(4u, str.GetLength());
stream << str;
EXPECT_EQ(4u, stream.tellp());
str = "";