| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 2  * This file is part of Adblock Plus <https://adblockplus.org/>, | 
| 3  * Copyright (C) 2006-present eyeo GmbH | 3  * Copyright (C) 2006-present eyeo GmbH | 
| 4  * | 4  * | 
| 5  * Adblock Plus is free software: you can redistribute it and/or modify | 5  * Adblock Plus is free software: you can redistribute it and/or modify | 
| 6  * it under the terms of the GNU General Public License version 3 as | 6  * it under the terms of the GNU General Public License version 3 as | 
| 7  * published by the Free Software Foundation. | 7  * published by the Free Software Foundation. | 
| 8  * | 8  * | 
| 9  * Adblock Plus is distributed in the hope that it will be useful, | 9  * Adblock Plus is distributed in the hope that it will be useful, | 
| 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
| 41 | 41 | 
| 42   // Ensure we still have an invalid string. | 42   // Ensure we still have an invalid string. | 
| 43   OwnedString s3(s); | 43   OwnedString s3(s); | 
| 44   EXPECT_TRUE(s3.is_invalid()); | 44   EXPECT_TRUE(s3.is_invalid()); | 
| 45 | 45 | 
| 46   // Empty valid string lead to valid string. | 46   // Empty valid string lead to valid string. | 
| 47   OwnedString s4(u""_str); | 47   OwnedString s4(u""_str); | 
| 48   EXPECT_FALSE(s4.is_invalid()); | 48   EXPECT_FALSE(s4.is_invalid()); | 
| 49 } | 49 } | 
| 50 | 50 | 
|  | 51 TEST(TestStringTrimSpaces, zeroLengthString) | 
|  | 52 { | 
|  | 53   EXPECT_EQ(u""_str, TrimSpaces(DependentString())); | 
|  | 54   EXPECT_EQ(u""_str, TrimSpaces(OwnedString())); | 
|  | 55   EXPECT_EQ(u""_str, TrimSpaces(u""_str)); | 
|  | 56 } | 
|  | 57 | 
|  | 58 TEST(TestStringTrimSpaces, spacesAreRemoved) | 
|  | 59 { | 
|  | 60   for (uint16_t leftSpaces = 0; leftSpaces < 5; ++leftSpaces) | 
|  | 61   { | 
|  | 62     for (uint16_t rightSpaces = 0; rightSpaces < 5; ++rightSpaces) | 
|  | 63     { | 
|  | 64       for (uint16_t nonSpaces = 0; nonSpaces < 5; ++nonSpaces) | 
|  | 65       { | 
|  | 66         OwnedString str; | 
|  | 67         std::string leftSpacesStdString(leftSpaces, ' '); | 
|  | 68         str.append(leftSpacesStdString.c_str(), leftSpacesStdString.length()); | 
|  | 69         std::string stdString(nonSpaces, 'a'); | 
|  | 70         OwnedString trimmedString; | 
|  | 71         trimmedString.append(stdString.c_str(), stdString.length()); | 
|  | 72         str.append(trimmedString); | 
|  | 73         std::string rightSpacesStdString(rightSpaces, ' '); | 
|  | 74         str.append(rightSpacesStdString.c_str(), rightSpacesStdString.length()); | 
|  | 75         EXPECT_EQ(trimmedString, TrimSpaces(str)); | 
|  | 76       } | 
|  | 77     } | 
|  | 78   } | 
|  | 79 } | 
|  | 80 | 
|  | 81 TEST(TestStringSplitString, test) | 
|  | 82 { | 
|  | 83   { | 
|  | 84     auto str = u"123:abc"_str; | 
|  | 85     auto split = SplitString(str, 3); | 
|  | 86     EXPECT_EQ(u"123"_str, split.first); | 
|  | 87     EXPECT_EQ(u"abc"_str, split.second); | 
|  | 88   } | 
|  | 89   { | 
|  | 90     auto str = u"123:abc"_str; | 
|  | 91     auto split = SplitString(str, 0); | 
|  | 92     EXPECT_EQ(u""_str, split.first); | 
|  | 93     EXPECT_EQ(u"23:abc"_str, split.second); | 
|  | 94   } | 
|  | 95   { | 
|  | 96     auto str = u"123:abc"_str; | 
|  | 97     auto split = SplitString(str, 6); | 
|  | 98     EXPECT_EQ(u"123:ab"_str, split.first); | 
|  | 99     EXPECT_EQ(u""_str, split.second); | 
|  | 100   } | 
|  | 101   { | 
|  | 102     auto str = u"123:abc"_str; | 
|  | 103     auto split = SplitString(str, 7); | 
|  | 104     EXPECT_EQ(u"123:abc"_str, split.first); | 
|  | 105     EXPECT_EQ(u""_str, split.second); | 
|  | 106   } | 
|  | 107   { | 
|  | 108     auto str = u"123:abc"_str; | 
|  | 109     auto split = SplitString(str, 10); | 
|  | 110     EXPECT_EQ(u"123:abc"_str, split.first); | 
|  | 111     EXPECT_EQ(u""_str, split.second); | 
|  | 112   } | 
|  | 113 } | 
| OLD | NEW | 
|---|