Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/compiled/String.cpp

Issue 29721753: Issue 6180 - use ABP_TEXT everywhere in order to let String be a UTF-8 string (Closed) Base URL: https://github.com/adblockplus/adblockpluscore.git@adb2678354813ce5b6de095072954c5a784a7bc4
Patch Set: rebase Created March 15, 2018, 1:53 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/compiled/RegExp.cpp ('k') | test/compiled/StringMap.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/compiled/String.cpp
diff --git a/test/compiled/String.cpp b/test/compiled/String.cpp
index b42a879704e7aedd9c81a58a9b1c5ce1fb0382e3..e969ccde556eb61d9b3b67a6303fca1eddec8b9b 100644
--- a/test/compiled/String.cpp
+++ b/test/compiled/String.cpp
@@ -44,15 +44,15 @@ TEST(TestString, constructInvalidOwnedString)
EXPECT_TRUE(s3.is_invalid());
// Empty valid string lead to valid string.
- OwnedString s4(u""_str);
+ OwnedString s4(ABP_TEXT(""_str));
EXPECT_FALSE(s4.is_invalid());
}
TEST(TestStringTrimSpaces, zeroLengthString)
{
- EXPECT_EQ(u""_str, TrimSpaces(DependentString()));
- EXPECT_EQ(u""_str, TrimSpaces(OwnedString()));
- EXPECT_EQ(u""_str, TrimSpaces(u""_str));
+ EXPECT_EQ(ABP_TEXT(""_str), TrimSpaces(DependentString()));
+ EXPECT_EQ(ABP_TEXT(""_str), TrimSpaces(OwnedString()));
+ EXPECT_EQ(ABP_TEXT(""_str), TrimSpaces(ABP_TEXT(""_str)));
}
TEST(TestStringTrimSpaces, spacesAreRemoved)
@@ -81,97 +81,97 @@ TEST(TestStringTrimSpaces, spacesAreRemoved)
TEST(TestStringSplitString, test)
{
{
- auto str = u"123:abc"_str;
+ auto str = ABP_TEXT("123:abc"_str);
auto split = SplitString(str, 3);
- EXPECT_EQ(u"123"_str, split.first);
- EXPECT_EQ(u"abc"_str, split.second);
+ EXPECT_EQ(ABP_TEXT("123"_str), split.first);
+ EXPECT_EQ(ABP_TEXT("abc"_str), split.second);
}
{
- auto str = u"123:abc"_str;
+ auto str = ABP_TEXT("123:abc"_str);
auto split = SplitString(str, 0);
- EXPECT_EQ(u""_str, split.first);
- EXPECT_EQ(u"23:abc"_str, split.second);
+ EXPECT_EQ(ABP_TEXT(""_str), split.first);
+ EXPECT_EQ(ABP_TEXT("23:abc"_str), split.second);
}
{
- auto str = u"123:abc"_str;
+ auto str = ABP_TEXT("123:abc"_str);
auto split = SplitString(str, 6);
- EXPECT_EQ(u"123:ab"_str, split.first);
- EXPECT_EQ(u""_str, split.second);
+ EXPECT_EQ(ABP_TEXT("123:ab"_str), split.first);
+ EXPECT_EQ(ABP_TEXT(""_str), split.second);
}
{
- auto str = u"123:abc"_str;
+ auto str = ABP_TEXT("123:abc"_str);
auto split = SplitString(str, 7);
- EXPECT_EQ(u"123:abc"_str, split.first);
- EXPECT_EQ(u""_str, split.second);
+ EXPECT_EQ(ABP_TEXT("123:abc"_str), split.first);
+ EXPECT_EQ(ABP_TEXT(""_str), split.second);
}
{
- auto str = u"123:abc"_str;
+ auto str = ABP_TEXT("123:abc"_str);
auto split = SplitString(str, 10);
- EXPECT_EQ(u"123:abc"_str, split.first);
- EXPECT_EQ(u""_str, split.second);
+ EXPECT_EQ(ABP_TEXT("123:abc"_str), split.first);
+ EXPECT_EQ(ABP_TEXT(""_str), split.second);
}
}
TEST(TestStringLexicalCast, toIntegers)
{
- EXPECT_EQ(0, lexical_cast<int32_t>(u"0"_str));
- EXPECT_EQ(1, lexical_cast<int32_t>(u"1"_str));
- EXPECT_EQ(2, lexical_cast<int32_t>(u"2"_str));
- EXPECT_EQ(10, lexical_cast<int32_t>(u"10"_str));
- EXPECT_EQ(10, lexical_cast<int32_t>(u"010"_str));
- EXPECT_EQ(-1, lexical_cast<int32_t>(u"-1"_str));
- EXPECT_EQ(-2, lexical_cast<int32_t>(u"-2"_str));
- EXPECT_EQ(-20, lexical_cast<int32_t>(u"-20"_str));
- EXPECT_EQ(-20, lexical_cast<int32_t>(u"-020"_str));
- EXPECT_EQ(0, lexical_cast<int32_t>(u"0-2"_str));
- EXPECT_EQ(-2147483647, lexical_cast<int32_t>(u"-2147483647"_str));
- EXPECT_EQ(-2147483648, lexical_cast<int32_t>(u"-2147483648"_str));
- EXPECT_EQ( 0, lexical_cast<int32_t>(u"-2147483649"_str));
- EXPECT_EQ( 0, lexical_cast<int32_t>(u"-2157483649"_str));
- EXPECT_EQ( 0, lexical_cast<int32_t>(u"-3147483649"_str));
- EXPECT_EQ(-2147483648, lexical_cast<int32_t>(u"-02147483648"_str));
- EXPECT_EQ(-2147483648, lexical_cast<int32_t>(u"-000002147483648"_str));
- EXPECT_EQ( 0, lexical_cast<int32_t>(u"-21474836480"_str));
- EXPECT_EQ(2147483647, lexical_cast<int32_t>(u"2147483647"_str));
- EXPECT_EQ(2147483647, lexical_cast<int32_t>(u"000002147483647"_str));
- EXPECT_EQ(2147483647, lexical_cast<int32_t>(u"02147483647"_str));
- EXPECT_EQ( 0, lexical_cast<int32_t>(u"21474836470"_str));
- EXPECT_EQ( 0, lexical_cast<int32_t>(u"2147483648"_str));
- EXPECT_EQ( 0, lexical_cast<int32_t>(u"2157483648"_str));
- EXPECT_EQ( 0, lexical_cast<int32_t>(u"3147483648"_str));
- EXPECT_EQ(0u, lexical_cast<uint32_t>(u"0"_str));
- EXPECT_EQ(2u, lexical_cast<uint32_t>(u"2"_str));
- EXPECT_EQ(123u, lexical_cast<uint32_t>(u"123"_str));
- EXPECT_EQ(123u, lexical_cast<uint32_t>(u"0123"_str));
- EXPECT_EQ(123u, lexical_cast<uint32_t>(u"0000123"_str));
- EXPECT_EQ(4294967294u, lexical_cast<uint32_t>(u"4294967294"_str));
- EXPECT_EQ(4294967295u, lexical_cast<uint32_t>(u"4294967295"_str));
- EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"4294967296"_str));
- EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"4594967295"_str));
- EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"5294967295"_str));
- EXPECT_EQ( 0u, lexical_cast<uint32_t>(u"42949672950"_str));
- EXPECT_EQ(4294967295u, lexical_cast<uint32_t>(u"04294967295"_str));
+ EXPECT_EQ(0, lexical_cast<int32_t>(ABP_TEXT("0"_str)));
+ EXPECT_EQ(1, lexical_cast<int32_t>(ABP_TEXT("1"_str)));
+ EXPECT_EQ(2, lexical_cast<int32_t>(ABP_TEXT("2"_str)));
+ EXPECT_EQ(10, lexical_cast<int32_t>(ABP_TEXT("10"_str)));
+ EXPECT_EQ(10, lexical_cast<int32_t>(ABP_TEXT("010"_str)));
+ EXPECT_EQ(-1, lexical_cast<int32_t>(ABP_TEXT("-1"_str)));
+ EXPECT_EQ(-2, lexical_cast<int32_t>(ABP_TEXT("-2"_str)));
+ EXPECT_EQ(-20, lexical_cast<int32_t>(ABP_TEXT("-20"_str)));
+ EXPECT_EQ(-20, lexical_cast<int32_t>(ABP_TEXT("-020"_str)));
+ EXPECT_EQ(0, lexical_cast<int32_t>(ABP_TEXT("0-2"_str)));
+ EXPECT_EQ(-2147483647, lexical_cast<int32_t>(ABP_TEXT("-2147483647"_str)));
+ EXPECT_EQ(-2147483648, lexical_cast<int32_t>(ABP_TEXT("-2147483648"_str)));
+ EXPECT_EQ( 0, lexical_cast<int32_t>(ABP_TEXT("-2147483649"_str)));
+ EXPECT_EQ( 0, lexical_cast<int32_t>(ABP_TEXT("-2157483649"_str)));
+ EXPECT_EQ( 0, lexical_cast<int32_t>(ABP_TEXT("-3147483649"_str)));
+ EXPECT_EQ(-2147483648, lexical_cast<int32_t>(ABP_TEXT("-02147483648"_str)));
+ EXPECT_EQ(-2147483648, lexical_cast<int32_t>(ABP_TEXT("-000002147483648"_str)));
+ EXPECT_EQ( 0, lexical_cast<int32_t>(ABP_TEXT("-21474836480"_str)));
+ EXPECT_EQ(2147483647, lexical_cast<int32_t>(ABP_TEXT("2147483647"_str)));
+ EXPECT_EQ(2147483647, lexical_cast<int32_t>(ABP_TEXT("000002147483647"_str)));
+ EXPECT_EQ(2147483647, lexical_cast<int32_t>(ABP_TEXT("02147483647"_str)));
+ EXPECT_EQ( 0, lexical_cast<int32_t>(ABP_TEXT("21474836470"_str)));
+ EXPECT_EQ( 0, lexical_cast<int32_t>(ABP_TEXT("2147483648"_str)));
+ EXPECT_EQ( 0, lexical_cast<int32_t>(ABP_TEXT("2157483648"_str)));
+ EXPECT_EQ( 0, lexical_cast<int32_t>(ABP_TEXT("3147483648"_str)));
+ EXPECT_EQ(0u, lexical_cast<uint32_t>(ABP_TEXT("0"_str)));
+ EXPECT_EQ(2u, lexical_cast<uint32_t>(ABP_TEXT("2"_str)));
+ EXPECT_EQ(123u, lexical_cast<uint32_t>(ABP_TEXT("123"_str)));
+ EXPECT_EQ(123u, lexical_cast<uint32_t>(ABP_TEXT("0123"_str)));
+ EXPECT_EQ(123u, lexical_cast<uint32_t>(ABP_TEXT("0000123"_str)));
+ EXPECT_EQ(4294967294u, lexical_cast<uint32_t>(ABP_TEXT("4294967294"_str)));
+ EXPECT_EQ(4294967295u, lexical_cast<uint32_t>(ABP_TEXT("4294967295"_str)));
+ EXPECT_EQ( 0u, lexical_cast<uint32_t>(ABP_TEXT("4294967296"_str)));
+ EXPECT_EQ( 0u, lexical_cast<uint32_t>(ABP_TEXT("4594967295"_str)));
+ EXPECT_EQ( 0u, lexical_cast<uint32_t>(ABP_TEXT("5294967295"_str)));
+ EXPECT_EQ( 0u, lexical_cast<uint32_t>(ABP_TEXT("42949672950"_str)));
+ EXPECT_EQ(4294967295u, lexical_cast<uint32_t>(ABP_TEXT("04294967295"_str)));
- EXPECT_EQ(0, lexical_cast<int32_t>(u" 123"_str));
- EXPECT_EQ(0u, lexical_cast<uint32_t>(u" 123"_str));
- EXPECT_EQ(0, lexical_cast<int32_t>(u"123abc"_str));
- EXPECT_EQ(0u, lexical_cast<uint32_t>(u"123abc"_str));
- EXPECT_EQ(0, lexical_cast<int32_t>(u"1 23"_str));
- EXPECT_EQ(0u, lexical_cast<uint32_t>(u"1 23"_str));
+ EXPECT_EQ(0, lexical_cast<int32_t>(ABP_TEXT(" 123"_str)));
+ EXPECT_EQ(0u, lexical_cast<uint32_t>(ABP_TEXT(" 123"_str)));
+ EXPECT_EQ(0, lexical_cast<int32_t>(ABP_TEXT("123abc"_str)));
+ EXPECT_EQ(0u, lexical_cast<uint32_t>(ABP_TEXT("123abc"_str)));
+ EXPECT_EQ(0, lexical_cast<int32_t>(ABP_TEXT("1 23"_str)));
+ EXPECT_EQ(0u, lexical_cast<uint32_t>(ABP_TEXT("1 23"_str)));
}
TEST(TestStringLexicalCast, toBoolean)
{
- EXPECT_TRUE(lexical_cast<bool>(u"true"_str));
- EXPECT_FALSE(lexical_cast<bool>(u"true123"_str));
- EXPECT_FALSE(lexical_cast<bool>(u"false"_str));
- EXPECT_FALSE(lexical_cast<bool>(u"some-string"_str));
- EXPECT_FALSE(lexical_cast<bool>(u""_str));
+ EXPECT_TRUE(lexical_cast<bool>(ABP_TEXT("true"_str)));
+ EXPECT_FALSE(lexical_cast<bool>(ABP_TEXT("true123"_str)));
+ EXPECT_FALSE(lexical_cast<bool>(ABP_TEXT("false"_str)));
+ EXPECT_FALSE(lexical_cast<bool>(ABP_TEXT("some-string"_str)));
+ EXPECT_FALSE(lexical_cast<bool>(ABP_TEXT(""_str)));
EXPECT_FALSE(lexical_cast<bool>(DependentString()));
}
TEST(TestStringLexicalCast, toOwnedString)
{
- EXPECT_EQ(u"some-string"_str, lexical_cast<OwnedString>(u"some-string"_str));
- EXPECT_EQ(u""_str, lexical_cast<OwnedString>(u""_str));
+ EXPECT_EQ(ABP_TEXT("some-string"_str), lexical_cast<OwnedString>(ABP_TEXT("some-string"_str)));
+ EXPECT_EQ(ABP_TEXT(""_str), lexical_cast<OwnedString>(ABP_TEXT(""_str)));
}
« no previous file with comments | « test/compiled/RegExp.cpp ('k') | test/compiled/StringMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld