| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2012 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "wtf/text/WTFString.h" | 26 #include "wtf/text/WTFString.h" |
| 27 | 27 |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "wtf/MathExtras.h" | 29 #include "wtf/MathExtras.h" |
| 30 #include "wtf/text/CString.h" | 30 #include "wtf/text/CString.h" |
| 31 #include <limits> | 31 #include <limits> |
| 32 | 32 |
| 33 namespace WTF { | 33 namespace WTF { |
| 34 | 34 |
| 35 TEST(StringTest, CreationFromLiteral) | 35 TEST(StringTest, CreationFromLiteral) { |
| 36 { | 36 String stringFromLiteral("Explicit construction syntax"); |
| 37 String stringFromLiteral("Explicit construction syntax"); | 37 EXPECT_EQ(strlen("Explicit construction syntax"), stringFromLiteral.length()); |
| 38 EXPECT_EQ(strlen("Explicit construction syntax"), stringFromLiteral.length()
); | 38 EXPECT_TRUE(stringFromLiteral == "Explicit construction syntax"); |
| 39 EXPECT_TRUE(stringFromLiteral == "Explicit construction syntax"); | 39 EXPECT_TRUE(stringFromLiteral.is8Bit()); |
| 40 EXPECT_TRUE(stringFromLiteral.is8Bit()); | 40 EXPECT_TRUE(String("Explicit construction syntax") == stringFromLiteral); |
| 41 EXPECT_TRUE(String("Explicit construction syntax") == stringFromLiteral); | 41 } |
| 42 } | 42 |
| 43 | 43 TEST(StringTest, ASCII) { |
| 44 TEST(StringTest, ASCII) | 44 CString output; |
| 45 { | 45 |
| 46 CString output; | 46 // Null String. |
| 47 | 47 output = String().ascii(); |
| 48 // Null String. | 48 EXPECT_STREQ("", output.data()); |
| 49 output = String().ascii(); | 49 |
| 50 EXPECT_STREQ("", output.data()); | 50 // Empty String. |
| 51 | 51 output = emptyString().ascii(); |
| 52 // Empty String. | 52 EXPECT_STREQ("", output.data()); |
| 53 output = emptyString().ascii(); | 53 |
| 54 EXPECT_STREQ("", output.data()); | 54 // Regular String. |
| 55 | 55 output = String("foobar").ascii(); |
| 56 // Regular String. | 56 EXPECT_STREQ("foobar", output.data()); |
| 57 output = String("foobar").ascii(); | |
| 58 EXPECT_STREQ("foobar", output.data()); | |
| 59 } | 57 } |
| 60 | 58 |
| 61 namespace { | 59 namespace { |
| 62 | 60 |
| 63 void testNumberToStringECMAScript(double number, const char* reference) | 61 void testNumberToStringECMAScript(double number, const char* reference) { |
| 64 { | 62 CString numberString = String::numberToStringECMAScript(number).latin1(); |
| 65 CString numberString = String::numberToStringECMAScript(number).latin1(); | 63 EXPECT_STREQ(reference, numberString.data()); |
| 66 EXPECT_STREQ(reference, numberString.data()); | 64 } |
| 67 } | 65 |
| 68 | 66 } // anonymous namespace |
| 69 } // anonymous namespace | 67 |
| 70 | 68 TEST(StringTest, NumberToStringECMAScriptBoundaries) { |
| 71 TEST(StringTest, NumberToStringECMAScriptBoundaries) | 69 typedef std::numeric_limits<double> Limits; |
| 72 { | 70 |
| 73 typedef std::numeric_limits<double> Limits; | 71 // Infinity. |
| 74 | 72 testNumberToStringECMAScript(Limits::infinity(), "Infinity"); |
| 75 // Infinity. | 73 testNumberToStringECMAScript(-Limits::infinity(), "-Infinity"); |
| 76 testNumberToStringECMAScript(Limits::infinity(), "Infinity"); | 74 |
| 77 testNumberToStringECMAScript(-Limits::infinity(), "-Infinity"); | 75 // NaN. |
| 78 | 76 testNumberToStringECMAScript(-Limits::quiet_NaN(), "NaN"); |
| 79 // NaN. | 77 |
| 80 testNumberToStringECMAScript(-Limits::quiet_NaN(), "NaN"); | 78 // Zeros. |
| 81 | 79 testNumberToStringECMAScript(0, "0"); |
| 82 // Zeros. | 80 testNumberToStringECMAScript(-0, "0"); |
| 83 testNumberToStringECMAScript(0, "0"); | 81 |
| 84 testNumberToStringECMAScript(-0, "0"); | 82 // Min-Max. |
| 85 | 83 testNumberToStringECMAScript(Limits::min(), "2.2250738585072014e-308"); |
| 86 // Min-Max. | 84 testNumberToStringECMAScript(Limits::max(), "1.7976931348623157e+308"); |
| 87 testNumberToStringECMAScript(Limits::min(), "2.2250738585072014e-308"); | 85 } |
| 88 testNumberToStringECMAScript(Limits::max(), "1.7976931348623157e+308"); | 86 |
| 89 } | 87 TEST(StringTest, NumberToStringECMAScriptRegularNumbers) { |
| 90 | 88 // Pi. |
| 91 TEST(StringTest, NumberToStringECMAScriptRegularNumbers) | 89 testNumberToStringECMAScript(piDouble, "3.141592653589793"); |
| 92 { | 90 testNumberToStringECMAScript(piFloat, "3.1415927410125732"); |
| 93 // Pi. | 91 testNumberToStringECMAScript(piOverTwoDouble, "1.5707963267948966"); |
| 94 testNumberToStringECMAScript(piDouble, "3.141592653589793"); | 92 testNumberToStringECMAScript(piOverTwoFloat, "1.5707963705062866"); |
| 95 testNumberToStringECMAScript(piFloat, "3.1415927410125732"); | 93 testNumberToStringECMAScript(piOverFourDouble, "0.7853981633974483"); |
| 96 testNumberToStringECMAScript(piOverTwoDouble, "1.5707963267948966"); | 94 testNumberToStringECMAScript(piOverFourFloat, "0.7853981852531433"); |
| 97 testNumberToStringECMAScript(piOverTwoFloat, "1.5707963705062866"); | 95 |
| 98 testNumberToStringECMAScript(piOverFourDouble, "0.7853981633974483"); | 96 // e. |
| 99 testNumberToStringECMAScript(piOverFourFloat, "0.7853981852531433"); | 97 const double e = 2.71828182845904523536028747135266249775724709369995; |
| 100 | 98 testNumberToStringECMAScript(e, "2.718281828459045"); |
| 101 // e. | 99 |
| 102 const double e = 2.71828182845904523536028747135266249775724709369995; | 100 // c, speed of light in m/s. |
| 103 testNumberToStringECMAScript(e, "2.718281828459045"); | 101 const double c = 299792458; |
| 104 | 102 testNumberToStringECMAScript(c, "299792458"); |
| 105 // c, speed of light in m/s. | 103 |
| 106 const double c = 299792458; | 104 // Golen ratio. |
| 107 testNumberToStringECMAScript(c, "299792458"); | 105 const double phi = 1.6180339887498948482; |
| 108 | 106 testNumberToStringECMAScript(phi, "1.618033988749895"); |
| 109 // Golen ratio. | 107 } |
| 110 const double phi = 1.6180339887498948482; | 108 |
| 111 testNumberToStringECMAScript(phi, "1.618033988749895"); | 109 TEST(StringTest, ReplaceWithLiteral) { |
| 112 } | 110 // Cases for 8Bit source. |
| 113 | 111 String testString = "1224"; |
| 114 TEST(StringTest, ReplaceWithLiteral) | 112 EXPECT_TRUE(testString.is8Bit()); |
| 115 { | 113 testString.replaceWithLiteral('2', ""); |
| 116 // Cases for 8Bit source. | 114 EXPECT_STREQ("14", testString.utf8().data()); |
| 117 String testString = "1224"; | 115 |
| 118 EXPECT_TRUE(testString.is8Bit()); | 116 testString = "1224"; |
| 119 testString.replaceWithLiteral('2', ""); | 117 EXPECT_TRUE(testString.is8Bit()); |
| 120 EXPECT_STREQ("14", testString.utf8().data()); | 118 testString.replaceWithLiteral('2', "3"); |
| 121 | 119 EXPECT_STREQ("1334", testString.utf8().data()); |
| 122 testString = "1224"; | 120 |
| 123 EXPECT_TRUE(testString.is8Bit()); | 121 testString = "1224"; |
| 124 testString.replaceWithLiteral('2', "3"); | 122 EXPECT_TRUE(testString.is8Bit()); |
| 125 EXPECT_STREQ("1334", testString.utf8().data()); | 123 testString.replaceWithLiteral('2', "555"); |
| 126 | 124 EXPECT_STREQ("15555554", testString.utf8().data()); |
| 127 testString = "1224"; | 125 |
| 128 EXPECT_TRUE(testString.is8Bit()); | 126 testString = "1224"; |
| 129 testString.replaceWithLiteral('2', "555"); | 127 EXPECT_TRUE(testString.is8Bit()); |
| 130 EXPECT_STREQ("15555554", testString.utf8().data()); | 128 testString.replaceWithLiteral('3', "NotFound"); |
| 131 | 129 EXPECT_STREQ("1224", testString.utf8().data()); |
| 132 testString = "1224"; | 130 |
| 133 EXPECT_TRUE(testString.is8Bit()); | 131 // Cases for 16Bit source. |
| 134 testString.replaceWithLiteral('3', "NotFound"); | 132 // U+00E9 (=0xC3 0xA9 in UTF-8) is e with accent. |
| 135 EXPECT_STREQ("1224", testString.utf8().data()); | 133 testString = String::fromUTF8("r\xC3\xA9sum\xC3\xA9"); |
| 136 | 134 EXPECT_FALSE(testString.is8Bit()); |
| 137 // Cases for 16Bit source. | 135 testString.replaceWithLiteral(UChar(0x00E9), "e"); |
| 138 // U+00E9 (=0xC3 0xA9 in UTF-8) is e with accent. | 136 EXPECT_STREQ("resume", testString.utf8().data()); |
| 139 testString = String::fromUTF8("r\xC3\xA9sum\xC3\xA9"); | 137 |
| 140 EXPECT_FALSE(testString.is8Bit()); | 138 testString = String::fromUTF8("r\xC3\xA9sum\xC3\xA9"); |
| 141 testString.replaceWithLiteral(UChar(0x00E9), "e"); | 139 EXPECT_FALSE(testString.is8Bit()); |
| 142 EXPECT_STREQ("resume", testString.utf8().data()); | 140 testString.replaceWithLiteral(UChar(0x00E9), ""); |
| 143 | 141 EXPECT_STREQ("rsum", testString.utf8().data()); |
| 144 testString = String::fromUTF8("r\xC3\xA9sum\xC3\xA9"); | 142 |
| 145 EXPECT_FALSE(testString.is8Bit()); | 143 testString = String::fromUTF8("r\xC3\xA9sum\xC3\xA9"); |
| 146 testString.replaceWithLiteral(UChar(0x00E9), ""); | 144 EXPECT_FALSE(testString.is8Bit()); |
| 147 EXPECT_STREQ("rsum", testString.utf8().data()); | 145 testString.replaceWithLiteral('3', "NotFound"); |
| 148 | 146 EXPECT_STREQ("r\xC3\xA9sum\xC3\xA9", testString.utf8().data()); |
| 149 testString = String::fromUTF8("r\xC3\xA9sum\xC3\xA9"); | 147 } |
| 150 EXPECT_FALSE(testString.is8Bit()); | 148 |
| 151 testString.replaceWithLiteral('3', "NotFound"); | 149 TEST(StringTest, ComparisonOfSameStringVectors) { |
| 152 EXPECT_STREQ("r\xC3\xA9sum\xC3\xA9", testString.utf8().data()); | 150 Vector<String> stringVector; |
| 153 } | 151 stringVector.append("one"); |
| 154 | 152 stringVector.append("two"); |
| 155 TEST(StringTest, ComparisonOfSameStringVectors) | 153 |
| 156 { | 154 Vector<String> sameStringVector; |
| 157 Vector<String> stringVector; | 155 sameStringVector.append("one"); |
| 158 stringVector.append("one"); | 156 sameStringVector.append("two"); |
| 159 stringVector.append("two"); | 157 |
| 160 | 158 EXPECT_EQ(stringVector, sameStringVector); |
| 161 Vector<String> sameStringVector; | 159 } |
| 162 sameStringVector.append("one"); | 160 |
| 163 sameStringVector.append("two"); | 161 TEST(WTF, SimplifyWhiteSpace) { |
| 164 | 162 String extraSpaces(" Hello world "); |
| 165 EXPECT_EQ(stringVector, sameStringVector); | 163 EXPECT_EQ(String("Hello world"), extraSpaces.simplifyWhiteSpace()); |
| 166 } | 164 EXPECT_EQ(String(" Hello world "), |
| 167 | 165 extraSpaces.simplifyWhiteSpace(WTF::DoNotStripWhiteSpace)); |
| 168 TEST(WTF, SimplifyWhiteSpace) | 166 |
| 169 { | 167 String extraSpacesAndNewlines(" \nHello\n world\n "); |
| 170 String extraSpaces(" Hello world "); | 168 EXPECT_EQ(String("Hello world"), extraSpacesAndNewlines.simplifyWhiteSpace()); |
| 171 EXPECT_EQ(String("Hello world"), extraSpaces.simplifyWhiteSpace()); | 169 EXPECT_EQ( |
| 172 EXPECT_EQ(String(" Hello world "), extraSpaces.simplifyWhiteSpace(WTF::Do
NotStripWhiteSpace)); | 170 String(" Hello world "), |
| 173 | 171 extraSpacesAndNewlines.simplifyWhiteSpace(WTF::DoNotStripWhiteSpace)); |
| 174 String extraSpacesAndNewlines(" \nHello\n world\n "); | 172 |
| 175 EXPECT_EQ(String("Hello world"), extraSpacesAndNewlines.simplifyWhiteSpace()
); | 173 String extraSpacesAndTabs(" \nHello\t world\t "); |
| 176 EXPECT_EQ(String(" Hello world "), extraSpacesAndNewlines.simplifyWhiteSp
ace(WTF::DoNotStripWhiteSpace)); | 174 EXPECT_EQ(String("Hello world"), extraSpacesAndTabs.simplifyWhiteSpace()); |
| 177 | 175 EXPECT_EQ(String(" Hello world "), |
| 178 String extraSpacesAndTabs(" \nHello\t world\t "); | 176 extraSpacesAndTabs.simplifyWhiteSpace(WTF::DoNotStripWhiteSpace)); |
| 179 EXPECT_EQ(String("Hello world"), extraSpacesAndTabs.simplifyWhiteSpace()); | |
| 180 EXPECT_EQ(String(" Hello world "), extraSpacesAndTabs.simplifyWhiteSpace(
WTF::DoNotStripWhiteSpace)); | |
| 181 } | 177 } |
| 182 | 178 |
| 183 struct CaseFoldingTestData { | 179 struct CaseFoldingTestData { |
| 184 const char* sourceDescription; | 180 const char* sourceDescription; |
| 185 const char* source; | 181 const char* source; |
| 186 const char** localeList; | 182 const char** localeList; |
| 187 size_t localeListLength; | 183 size_t localeListLength; |
| 188 const char* expected; | 184 const char* expected; |
| 189 }; | 185 }; |
| 190 | 186 |
| 191 // \xC4\xB0 = U+0130 (capital dotted I) | 187 // \xC4\xB0 = U+0130 (capital dotted I) |
| 192 // \xC4\xB1 = U+0131 (lowercase dotless I) | 188 // \xC4\xB1 = U+0131 (lowercase dotless I) |
| 193 const char* turkicInput = "Isi\xC4\xB0 \xC4\xB0s\xC4\xB1I"; | 189 const char* turkicInput = "Isi\xC4\xB0 \xC4\xB0s\xC4\xB1I"; |
| 194 const char* greekInput = "\xCE\x9F\xCE\x94\xCE\x8C\xCE\xA3 \xCE\x9F\xCE\xB4\xCF\
x8C\xCF\x82 \xCE\xA3\xCE\xBF \xCE\xA3\xCE\x9F o\xCE\xA3 \xCE\x9F\xCE\xA3 \xCF\x8
3 \xE1\xBC\x95\xCE\xBE"; | 190 const char* greekInput = |
| 195 const char* lithuanianInput = "I \xC3\x8F J J\xCC\x88 \xC4\xAE \xC4\xAE\xCC\x88
\xC3\x8C \xC3\x8D \xC4\xA8 xi\xCC\x87\xCC\x88 xj\xCC\x87\xCC\x88 x\xC4\xAF\xCC\x
87\xCC\x88 xi\xCC\x87\xCC\x80 xi\xCC\x87\xCC\x81 xi\xCC\x87\xCC\x83 XI X\xC3\x8F
XJ XJ\xCC\x88 X\xC4\xAE X\xC4\xAE\xCC\x88"; | 191 "\xCE\x9F\xCE\x94\xCE\x8C\xCE\xA3 \xCE\x9F\xCE\xB4\xCF\x8C\xCF\x82 " |
| 196 | 192 "\xCE\xA3\xCE\xBF \xCE\xA3\xCE\x9F o\xCE\xA3 \xCE\x9F\xCE\xA3 \xCF\x83 " |
| 193 "\xE1\xBC\x95\xCE\xBE"; |
| 194 const char* lithuanianInput = |
| 195 "I \xC3\x8F J J\xCC\x88 \xC4\xAE \xC4\xAE\xCC\x88 \xC3\x8C \xC3\x8D " |
| 196 "\xC4\xA8 xi\xCC\x87\xCC\x88 xj\xCC\x87\xCC\x88 x\xC4\xAF\xCC\x87\xCC\x88 " |
| 197 "xi\xCC\x87\xCC\x80 xi\xCC\x87\xCC\x81 xi\xCC\x87\xCC\x83 XI X\xC3\x8F XJ " |
| 198 "XJ\xCC\x88 X\xC4\xAE X\xC4\xAE\xCC\x88"; |
| 197 | 199 |
| 198 const char* turkicLocales[] = { | 200 const char* turkicLocales[] = { |
| 199 "tr", "tr-TR", "tr_TR", "tr@foo=bar", "tr-US", "TR", "tr-tr", "tR", | 201 "tr", "tr-TR", "tr_TR", "tr@foo=bar", "tr-US", "TR", "tr-tr", "tR", |
| 200 "az", "az-AZ", "az_AZ", "az@foo=bar", "az-US", "Az", "AZ-AZ", }; | 202 "az", "az-AZ", "az_AZ", "az@foo=bar", "az-US", "Az", "AZ-AZ", |
| 203 }; |
| 201 const char* nonTurkicLocales[] = { | 204 const char* nonTurkicLocales[] = { |
| 202 "en", "en-US", "en_US", "en@foo=bar", "EN", "En", | 205 "en", "en-US", "en_US", "en@foo=bar", "EN", "En", |
| 203 "ja", "el", "fil", "fi", "lt", }; | 206 "ja", "el", "fil", "fi", "lt", |
| 207 }; |
| 204 const char* greekLocales[] = { | 208 const char* greekLocales[] = { |
| 205 "el", "el-GR", "el_GR", "el@foo=bar", "el-US", "EL", "el-gr", "eL", | 209 "el", "el-GR", "el_GR", "el@foo=bar", "el-US", "EL", "el-gr", "eL", |
| 206 }; | 210 }; |
| 207 const char* nonGreekLocales[] = { | 211 const char* nonGreekLocales[] = { |
| 208 "en", "en-US", "en_US", "en@foo=bar", "EN", "En", | 212 "en", "en-US", "en_US", "en@foo=bar", "EN", "En", |
| 209 "ja", "tr", "az", "fil", "fi", "lt", }; | 213 "ja", "tr", "az", "fil", "fi", "lt", |
| 214 }; |
| 210 const char* lithuanianLocales[] = { | 215 const char* lithuanianLocales[] = { |
| 211 "lt", "lt-LT", "lt_LT", "lt@foo=bar", "lt-US", "LT", "lt-lt", "lT", | 216 "lt", "lt-LT", "lt_LT", "lt@foo=bar", "lt-US", "LT", "lt-lt", "lT", |
| 212 }; | 217 }; |
| 213 // Should not have "tr" or "az" because "lt" and 'tr/az' rules conflict with eac
h other. | 218 // Should not have "tr" or "az" because "lt" and 'tr/az' rules conflict with eac
h other. |
| 214 const char* nonLithuanianLocales[] = { | 219 const char* nonLithuanianLocales[] = { |
| 215 "en", "en-US", "en_US", "en@foo=bar", "EN", "En", "ja", "fil", "fi", "el", }
; | 220 "en", "en-US", "en_US", "en@foo=bar", "EN", "En", "ja", "fil", "fi", "el", |
| 216 | 221 }; |
| 217 TEST(StringTest, ToUpperLocale) | 222 |
| 218 { | 223 TEST(StringTest, ToUpperLocale) { |
| 219 CaseFoldingTestData testDataList[] = { | 224 CaseFoldingTestData testDataList[] = { |
| 220 { | 225 { |
| 221 "Turkic input", | 226 "Turkic input", turkicInput, turkicLocales, |
| 222 turkicInput, | 227 sizeof(turkicLocales) / sizeof(const char*), |
| 223 turkicLocales, | 228 "IS\xC4\xB0\xC4\xB0 \xC4\xB0SII", |
| 224 sizeof(turkicLocales) / sizeof(const char*), | 229 }, |
| 225 "IS\xC4\xB0\xC4\xB0 \xC4\xB0SII", | 230 { |
| 226 }, { | 231 "Turkic input", turkicInput, nonTurkicLocales, |
| 227 "Turkic input", | 232 sizeof(nonTurkicLocales) / sizeof(const char*), |
| 228 turkicInput, | 233 "ISI\xC4\xB0 \xC4\xB0SII", |
| 229 nonTurkicLocales, | 234 }, |
| 230 sizeof(nonTurkicLocales) / sizeof(const char*), | 235 { |
| 231 "ISI\xC4\xB0 \xC4\xB0SII", | 236 "Greek input", greekInput, greekLocales, |
| 232 }, { | 237 sizeof(greekLocales) / sizeof(const char*), |
| 233 "Greek input", | 238 "\xCE\x9F\xCE\x94\xCE\x9F\xCE\xA3 \xCE\x9F\xCE\x94\xCE\x9F\xCE\xA3 " |
| 234 greekInput, | 239 "\xCE\xA3\xCE\x9F \xCE\xA3\xCE\x9F \x4F\xCE\xA3 \xCE\x9F\xCE\xA3 " |
| 235 greekLocales, | 240 "\xCE\xA3 \xCE\x95\xCE\x9E", |
| 236 sizeof(greekLocales) / sizeof(const char*), | 241 }, |
| 237 "\xCE\x9F\xCE\x94\xCE\x9F\xCE\xA3 \xCE\x9F\xCE\x94\xCE\x9F\xCE\xA3 \
xCE\xA3\xCE\x9F \xCE\xA3\xCE\x9F \x4F\xCE\xA3 \xCE\x9F\xCE\xA3 \xCE\xA3 \xCE\x95
\xCE\x9E", | 242 { |
| 238 }, { | 243 "Greek input", greekInput, nonGreekLocales, |
| 239 "Greek input", | 244 sizeof(nonGreekLocales) / sizeof(const char*), |
| 240 greekInput, | 245 "\xCE\x9F\xCE\x94\xCE\x8C\xCE\xA3 \xCE\x9F\xCE\x94\xCE\x8C\xCE\xA3 " |
| 241 nonGreekLocales, | 246 "\xCE\xA3\xCE\x9F \xCE\xA3\xCE\x9F \x4F\xCE\xA3 \xCE\x9F\xCE\xA3 " |
| 242 sizeof(nonGreekLocales) / sizeof(const char*), | 247 "\xCE\xA3 \xE1\xBC\x9D\xCE\x9E", |
| 243 "\xCE\x9F\xCE\x94\xCE\x8C\xCE\xA3 \xCE\x9F\xCE\x94\xCE\x8C\xCE\xA3 \
xCE\xA3\xCE\x9F \xCE\xA3\xCE\x9F \x4F\xCE\xA3 \xCE\x9F\xCE\xA3 \xCE\xA3 \xE1\xBC
\x9D\xCE\x9E", | 248 }, |
| 244 }, { | 249 { |
| 245 "Lithuanian input", | 250 "Lithuanian input", lithuanianInput, lithuanianLocales, |
| 246 lithuanianInput, | 251 sizeof(lithuanianLocales) / sizeof(const char*), |
| 247 lithuanianLocales, | 252 "I \xC3\x8F J J\xCC\x88 \xC4\xAE \xC4\xAE\xCC\x88 \xC3\x8C \xC3\x8D " |
| 248 sizeof(lithuanianLocales) / sizeof(const char*), | 253 "\xC4\xA8 XI\xCC\x88 XJ\xCC\x88 X\xC4\xAE\xCC\x88 XI\xCC\x80 " |
| 249 "I \xC3\x8F J J\xCC\x88 \xC4\xAE \xC4\xAE\xCC\x88 \xC3\x8C \xC3\x8D
\xC4\xA8 XI\xCC\x88 XJ\xCC\x88 X\xC4\xAE\xCC\x88 XI\xCC\x80 XI\xCC\x81 XI\xCC\x8
3 XI X\xC3\x8F XJ XJ\xCC\x88 X\xC4\xAE X\xC4\xAE\xCC\x88", | 254 "XI\xCC\x81 XI\xCC\x83 XI X\xC3\x8F XJ XJ\xCC\x88 X\xC4\xAE " |
| 250 }, { | 255 "X\xC4\xAE\xCC\x88", |
| 251 "Lithuanian input", | 256 }, |
| 252 lithuanianInput, | 257 { |
| 253 nonLithuanianLocales, | 258 "Lithuanian input", lithuanianInput, nonLithuanianLocales, |
| 254 sizeof(nonLithuanianLocales) / sizeof(const char*), | 259 sizeof(nonLithuanianLocales) / sizeof(const char*), |
| 255 "I \xC3\x8F J J\xCC\x88 \xC4\xAE \xC4\xAE\xCC\x88 \xC3\x8C \xC3\x8D
\xC4\xA8 XI\xCC\x87\xCC\x88 XJ\xCC\x87\xCC\x88 X\xC4\xAE\xCC\x87\xCC\x88 XI\xCC\
x87\xCC\x80 XI\xCC\x87\xCC\x81 XI\xCC\x87\xCC\x83 XI X\xC3\x8F XJ XJ\xCC\x88 X\x
C4\xAE X\xC4\xAE\xCC\x88", | 260 "I \xC3\x8F J J\xCC\x88 \xC4\xAE \xC4\xAE\xCC\x88 \xC3\x8C \xC3\x8D " |
| 256 }, | 261 "\xC4\xA8 XI\xCC\x87\xCC\x88 XJ\xCC\x87\xCC\x88 " |
| 257 }; | 262 "X\xC4\xAE\xCC\x87\xCC\x88 XI\xCC\x87\xCC\x80 XI\xCC\x87\xCC\x81 " |
| 258 | 263 "XI\xCC\x87\xCC\x83 XI X\xC3\x8F XJ XJ\xCC\x88 X\xC4\xAE " |
| 259 for (size_t i = 0; i < sizeof(testDataList) / sizeof(testDataList[0]); ++i)
{ | 264 "X\xC4\xAE\xCC\x88", |
| 260 const char* expected = testDataList[i].expected; | 265 }, |
| 261 String source = String::fromUTF8(testDataList[i].source); | 266 }; |
| 262 for (size_t j = 0; j < testDataList[i].localeListLength; ++j) { | 267 |
| 263 const char* locale = testDataList[i].localeList[j]; | 268 for (size_t i = 0; i < sizeof(testDataList) / sizeof(testDataList[0]); ++i) { |
| 264 EXPECT_STREQ(expected, source.upper(locale).utf8().data()) << testDa
taList[i].sourceDescription << "; locale=" << locale; | 269 const char* expected = testDataList[i].expected; |
| 265 } | 270 String source = String::fromUTF8(testDataList[i].source); |
| 271 for (size_t j = 0; j < testDataList[i].localeListLength; ++j) { |
| 272 const char* locale = testDataList[i].localeList[j]; |
| 273 EXPECT_STREQ(expected, source.upper(locale).utf8().data()) |
| 274 << testDataList[i].sourceDescription << "; locale=" << locale; |
| 266 } | 275 } |
| 267 } | 276 } |
| 268 | 277 } |
| 269 TEST(StringTest, ToLowerLocale) | 278 |
| 270 { | 279 TEST(StringTest, ToLowerLocale) { |
| 271 CaseFoldingTestData testDataList[] = { | 280 CaseFoldingTestData testDataList[] = { |
| 272 { | 281 { |
| 273 "Turkic input", | 282 "Turkic input", turkicInput, turkicLocales, |
| 274 turkicInput, | 283 sizeof(turkicLocales) / sizeof(const char*), |
| 275 turkicLocales, | 284 "\xC4\xB1sii is\xC4\xB1\xC4\xB1", |
| 276 sizeof(turkicLocales) / sizeof(const char*), | 285 }, |
| 277 "\xC4\xB1sii is\xC4\xB1\xC4\xB1", | 286 { |
| 278 }, { | 287 "Turkic input", turkicInput, nonTurkicLocales, |
| 279 "Turkic input", | 288 sizeof(nonTurkicLocales) / sizeof(const char*), |
| 280 turkicInput, | 289 // U+0130 is lowercased to U+0069 followed by U+0307 |
| 281 nonTurkicLocales, | 290 "isii\xCC\x87 i\xCC\x87s\xC4\xB1i", |
| 282 sizeof(nonTurkicLocales) / sizeof(const char*), | 291 }, |
| 283 // U+0130 is lowercased to U+0069 followed by U+0307 | 292 { |
| 284 "isii\xCC\x87 i\xCC\x87s\xC4\xB1i", | 293 "Greek input", greekInput, greekLocales, |
| 285 }, { | 294 sizeof(greekLocales) / sizeof(const char*), |
| 286 "Greek input", | 295 "\xCE\xBF\xCE\xB4\xCF\x8C\xCF\x82 \xCE\xBF\xCE\xB4\xCF\x8C\xCF\x82 " |
| 287 greekInput, | 296 "\xCF\x83\xCE\xBF \xCF\x83\xCE\xBF \x6F\xCF\x82 \xCE\xBF\xCF\x82 " |
| 288 greekLocales, | 297 "\xCF\x83 \xE1\xBC\x95\xCE\xBE", |
| 289 sizeof(greekLocales) / sizeof(const char*), | 298 }, |
| 290 "\xCE\xBF\xCE\xB4\xCF\x8C\xCF\x82 \xCE\xBF\xCE\xB4\xCF\x8C\xCF\x82 \
xCF\x83\xCE\xBF \xCF\x83\xCE\xBF \x6F\xCF\x82 \xCE\xBF\xCF\x82 \xCF\x83 \xE1\xBC
\x95\xCE\xBE", | 299 { |
| 291 }, { | 300 "Greek input", greekInput, nonGreekLocales, |
| 292 "Greek input", | 301 sizeof(greekLocales) / sizeof(const char*), |
| 293 greekInput, | 302 "\xCE\xBF\xCE\xB4\xCF\x8C\xCF\x82 \xCE\xBF\xCE\xB4\xCF\x8C\xCF\x82 " |
| 294 nonGreekLocales, | 303 "\xCF\x83\xCE\xBF \xCF\x83\xCE\xBF \x6F\xCF\x82 \xCE\xBF\xCF\x82 " |
| 295 sizeof(greekLocales) / sizeof(const char*), | 304 "\xCF\x83 \xE1\xBC\x95\xCE\xBE", |
| 296 "\xCE\xBF\xCE\xB4\xCF\x8C\xCF\x82 \xCE\xBF\xCE\xB4\xCF\x8C\xCF\x82 \
xCF\x83\xCE\xBF \xCF\x83\xCE\xBF \x6F\xCF\x82 \xCE\xBF\xCF\x82 \xCF\x83 \xE1\xBC
\x95\xCE\xBE", | 305 }, |
| 297 }, { | 306 { |
| 298 "Lithuanian input", | 307 "Lithuanian input", lithuanianInput, lithuanianLocales, |
| 299 lithuanianInput, | 308 sizeof(lithuanianLocales) / sizeof(const char*), |
| 300 lithuanianLocales, | 309 "i \xC3\xAF j j\xCC\x87\xCC\x88 \xC4\xAF \xC4\xAF\xCC\x87\xCC\x88 " |
| 301 sizeof(lithuanianLocales) / sizeof(const char*), | 310 "i\xCC\x87\xCC\x80 i\xCC\x87\xCC\x81 i\xCC\x87\xCC\x83 " |
| 302 "i \xC3\xAF j j\xCC\x87\xCC\x88 \xC4\xAF \xC4\xAF\xCC\x87\xCC\x88 i\
xCC\x87\xCC\x80 i\xCC\x87\xCC\x81 i\xCC\x87\xCC\x83 xi\xCC\x87\xCC\x88 xj\xCC\x8
7\xCC\x88 x\xC4\xAF\xCC\x87\xCC\x88 xi\xCC\x87\xCC\x80 xi\xCC\x87\xCC\x81 xi\xCC
\x87\xCC\x83 xi x\xC3\xAF xj xj\xCC\x87\xCC\x88 x\xC4\xAF x\xC4\xAF\xCC\x87\xCC\
x88", | 311 "xi\xCC\x87\xCC\x88 xj\xCC\x87\xCC\x88 x\xC4\xAF\xCC\x87\xCC\x88 " |
| 303 }, { | 312 "xi\xCC\x87\xCC\x80 xi\xCC\x87\xCC\x81 xi\xCC\x87\xCC\x83 xi " |
| 304 "Lithuanian input", | 313 "x\xC3\xAF xj xj\xCC\x87\xCC\x88 x\xC4\xAF x\xC4\xAF\xCC\x87\xCC\x88", |
| 305 lithuanianInput, | 314 }, |
| 306 nonLithuanianLocales, | 315 { |
| 307 sizeof(nonLithuanianLocales) / sizeof(const char*), | 316 "Lithuanian input", lithuanianInput, nonLithuanianLocales, |
| 308 "\x69 \xC3\xAF \x6A \x6A\xCC\x88 \xC4\xAF \xC4\xAF\xCC\x88 \xC3\xAC
\xC3\xAD \xC4\xA9 \x78\x69\xCC\x87\xCC\x88 \x78\x6A\xCC\x87\xCC\x88 \x78\xC4\xAF
\xCC\x87\xCC\x88 \x78\x69\xCC\x87\xCC\x80 \x78\x69\xCC\x87\xCC\x81 \x78\x69\xCC\
x87\xCC\x83 \x78\x69 \x78\xC3\xAF \x78\x6A \x78\x6A\xCC\x88 \x78\xC4\xAF \x78\xC
4\xAF\xCC\x88", | 317 sizeof(nonLithuanianLocales) / sizeof(const char*), |
| 309 }, | 318 "\x69 \xC3\xAF \x6A \x6A\xCC\x88 \xC4\xAF \xC4\xAF\xCC\x88 \xC3\xAC " |
| 310 }; | 319 "\xC3\xAD \xC4\xA9 \x78\x69\xCC\x87\xCC\x88 \x78\x6A\xCC\x87\xCC\x88 " |
| 311 | 320 "\x78\xC4\xAF\xCC\x87\xCC\x88 \x78\x69\xCC\x87\xCC\x80 " |
| 312 for (size_t i = 0; i < sizeof(testDataList) / sizeof(testDataList[0]); ++i)
{ | 321 "\x78\x69\xCC\x87\xCC\x81 \x78\x69\xCC\x87\xCC\x83 \x78\x69 " |
| 313 const char* expected = testDataList[i].expected; | 322 "\x78\xC3\xAF \x78\x6A \x78\x6A\xCC\x88 \x78\xC4\xAF " |
| 314 String source = String::fromUTF8(testDataList[i].source); | 323 "\x78\xC4\xAF\xCC\x88", |
| 315 for (size_t j = 0; j < testDataList[i].localeListLength; ++j) { | 324 }, |
| 316 const char* locale = testDataList[i].localeList[j]; | 325 }; |
| 317 EXPECT_STREQ(expected, source.lower(locale).utf8().data()) << testDa
taList[i].sourceDescription << "; locale=" << locale; | 326 |
| 318 } | 327 for (size_t i = 0; i < sizeof(testDataList) / sizeof(testDataList[0]); ++i) { |
| 328 const char* expected = testDataList[i].expected; |
| 329 String source = String::fromUTF8(testDataList[i].source); |
| 330 for (size_t j = 0; j < testDataList[i].localeListLength; ++j) { |
| 331 const char* locale = testDataList[i].localeList[j]; |
| 332 EXPECT_STREQ(expected, source.lower(locale).utf8().data()) |
| 333 << testDataList[i].sourceDescription << "; locale=" << locale; |
| 319 } | 334 } |
| 320 } | 335 } |
| 321 | 336 } |
| 322 TEST(StringTest, StartsWithIgnoringASCIICase) | 337 |
| 323 { | 338 TEST(StringTest, StartsWithIgnoringASCIICase) { |
| 324 String allASCII("LINK"); | 339 String allASCII("LINK"); |
| 325 String allASCIILowerCase("link"); | 340 String allASCIILowerCase("link"); |
| 326 EXPECT_TRUE(allASCII.startsWith(allASCIILowerCase, TextCaseASCIIInsensitive)
); | 341 EXPECT_TRUE(allASCII.startsWith(allASCIILowerCase, TextCaseASCIIInsensitive)); |
| 327 String allASCIIMixedCase("lInK"); | 342 String allASCIIMixedCase("lInK"); |
| 328 EXPECT_TRUE(allASCII.startsWith(allASCIIMixedCase, TextCaseASCIIInsensitive)
); | 343 EXPECT_TRUE(allASCII.startsWith(allASCIIMixedCase, TextCaseASCIIInsensitive)); |
| 329 String allASCIIDifferent("foo"); | 344 String allASCIIDifferent("foo"); |
| 330 EXPECT_FALSE(allASCII.startsWith(allASCIIDifferent, TextCaseASCIIInsensitive
)); | 345 EXPECT_FALSE( |
| 331 String nonASCII = String::fromUTF8("LIN\xE2\x84\xAA"); | 346 allASCII.startsWith(allASCIIDifferent, TextCaseASCIIInsensitive)); |
| 332 EXPECT_FALSE(allASCII.startsWith(nonASCII, TextCaseASCIIInsensitive)); | 347 String nonASCII = String::fromUTF8("LIN\xE2\x84\xAA"); |
| 333 EXPECT_TRUE(allASCII.startsWith(nonASCII.lower(), TextCaseASCIIInsensitive))
; | 348 EXPECT_FALSE(allASCII.startsWith(nonASCII, TextCaseASCIIInsensitive)); |
| 334 | 349 EXPECT_TRUE(allASCII.startsWith(nonASCII.lower(), TextCaseASCIIInsensitive)); |
| 335 EXPECT_FALSE(nonASCII.startsWith(allASCII, TextCaseASCIIInsensitive)); | 350 |
| 336 EXPECT_FALSE(nonASCII.startsWith(allASCIILowerCase, TextCaseASCIIInsensitive
)); | 351 EXPECT_FALSE(nonASCII.startsWith(allASCII, TextCaseASCIIInsensitive)); |
| 337 EXPECT_FALSE(nonASCII.startsWith(allASCIIMixedCase, TextCaseASCIIInsensitive
)); | 352 EXPECT_FALSE( |
| 338 EXPECT_FALSE(nonASCII.startsWith(allASCIIDifferent, TextCaseASCIIInsensitive
)); | 353 nonASCII.startsWith(allASCIILowerCase, TextCaseASCIIInsensitive)); |
| 339 } | 354 EXPECT_FALSE( |
| 340 | 355 nonASCII.startsWith(allASCIIMixedCase, TextCaseASCIIInsensitive)); |
| 341 TEST(StringTest, EndsWithIgnoringASCIICase) | 356 EXPECT_FALSE( |
| 342 { | 357 nonASCII.startsWith(allASCIIDifferent, TextCaseASCIIInsensitive)); |
| 343 String allASCII("LINK"); | 358 } |
| 344 String allASCIILowerCase("link"); | 359 |
| 345 EXPECT_TRUE(allASCII.endsWith(allASCIILowerCase, TextCaseASCIIInsensitive)); | 360 TEST(StringTest, EndsWithIgnoringASCIICase) { |
| 346 String allASCIIMixedCase("lInK"); | 361 String allASCII("LINK"); |
| 347 EXPECT_TRUE(allASCII.endsWith(allASCIIMixedCase, TextCaseASCIIInsensitive)); | 362 String allASCIILowerCase("link"); |
| 348 String allASCIIDifferent("foo"); | 363 EXPECT_TRUE(allASCII.endsWith(allASCIILowerCase, TextCaseASCIIInsensitive)); |
| 349 EXPECT_FALSE(allASCII.endsWith(allASCIIDifferent, TextCaseASCIIInsensitive))
; | 364 String allASCIIMixedCase("lInK"); |
| 350 String nonASCII = String::fromUTF8("LIN\xE2\x84\xAA"); | 365 EXPECT_TRUE(allASCII.endsWith(allASCIIMixedCase, TextCaseASCIIInsensitive)); |
| 351 EXPECT_FALSE(allASCII.endsWith(nonASCII, TextCaseASCIIInsensitive)); | 366 String allASCIIDifferent("foo"); |
| 352 EXPECT_TRUE(allASCII.endsWith(nonASCII.lower(), TextCaseASCIIInsensitive)); | 367 EXPECT_FALSE(allASCII.endsWith(allASCIIDifferent, TextCaseASCIIInsensitive)); |
| 353 | 368 String nonASCII = String::fromUTF8("LIN\xE2\x84\xAA"); |
| 354 EXPECT_FALSE(nonASCII.endsWith(allASCII, TextCaseASCIIInsensitive)); | 369 EXPECT_FALSE(allASCII.endsWith(nonASCII, TextCaseASCIIInsensitive)); |
| 355 EXPECT_FALSE(nonASCII.endsWith(allASCIILowerCase, TextCaseASCIIInsensitive))
; | 370 EXPECT_TRUE(allASCII.endsWith(nonASCII.lower(), TextCaseASCIIInsensitive)); |
| 356 EXPECT_FALSE(nonASCII.endsWith(allASCIIMixedCase, TextCaseASCIIInsensitive))
; | 371 |
| 357 EXPECT_FALSE(nonASCII.endsWith(allASCIIDifferent, TextCaseASCIIInsensitive))
; | 372 EXPECT_FALSE(nonASCII.endsWith(allASCII, TextCaseASCIIInsensitive)); |
| 358 } | 373 EXPECT_FALSE(nonASCII.endsWith(allASCIILowerCase, TextCaseASCIIInsensitive)); |
| 359 | 374 EXPECT_FALSE(nonASCII.endsWith(allASCIIMixedCase, TextCaseASCIIInsensitive)); |
| 360 TEST(StringTest, EqualIgnoringASCIICase) | 375 EXPECT_FALSE(nonASCII.endsWith(allASCIIDifferent, TextCaseASCIIInsensitive)); |
| 361 { | 376 } |
| 362 String allASCII("LINK"); | 377 |
| 363 String allASCIILowerCase("link"); | 378 TEST(StringTest, EqualIgnoringASCIICase) { |
| 364 EXPECT_TRUE(equalIgnoringASCIICase(allASCII, allASCIILowerCase)); | 379 String allASCII("LINK"); |
| 365 String allASCIIMixedCase("lInK"); | 380 String allASCIILowerCase("link"); |
| 366 EXPECT_TRUE(equalIgnoringASCIICase(allASCII, allASCIIMixedCase)); | 381 EXPECT_TRUE(equalIgnoringASCIICase(allASCII, allASCIILowerCase)); |
| 367 String allASCIIDifferent("foo"); | 382 String allASCIIMixedCase("lInK"); |
| 368 EXPECT_FALSE(equalIgnoringASCIICase(allASCII, allASCIIDifferent)); | 383 EXPECT_TRUE(equalIgnoringASCIICase(allASCII, allASCIIMixedCase)); |
| 369 String nonASCII = String::fromUTF8("LIN\xE2\x84\xAA"); | 384 String allASCIIDifferent("foo"); |
| 370 EXPECT_FALSE(equalIgnoringASCIICase(allASCII, nonASCII)); | 385 EXPECT_FALSE(equalIgnoringASCIICase(allASCII, allASCIIDifferent)); |
| 371 EXPECT_TRUE(equalIgnoringASCIICase(allASCII, nonASCII.lower())); | 386 String nonASCII = String::fromUTF8("LIN\xE2\x84\xAA"); |
| 372 | 387 EXPECT_FALSE(equalIgnoringASCIICase(allASCII, nonASCII)); |
| 373 EXPECT_FALSE(equalIgnoringASCIICase(nonASCII, allASCII)); | 388 EXPECT_TRUE(equalIgnoringASCIICase(allASCII, nonASCII.lower())); |
| 374 EXPECT_FALSE(equalIgnoringASCIICase(nonASCII, allASCIILowerCase)); | 389 |
| 375 EXPECT_FALSE(equalIgnoringASCIICase(nonASCII, allASCIIMixedCase)); | 390 EXPECT_FALSE(equalIgnoringASCIICase(nonASCII, allASCII)); |
| 376 EXPECT_FALSE(equalIgnoringASCIICase(nonASCII, allASCIIDifferent)); | 391 EXPECT_FALSE(equalIgnoringASCIICase(nonASCII, allASCIILowerCase)); |
| 377 } | 392 EXPECT_FALSE(equalIgnoringASCIICase(nonASCII, allASCIIMixedCase)); |
| 378 | 393 EXPECT_FALSE(equalIgnoringASCIICase(nonASCII, allASCIIDifferent)); |
| 379 TEST(StringTest, FindIgnoringASCIICase) | 394 } |
| 380 { | 395 |
| 381 String needle = String::fromUTF8("a\xCC\x88qa\xCC\x88"); | 396 TEST(StringTest, FindIgnoringASCIICase) { |
| 382 | 397 String needle = String::fromUTF8("a\xCC\x88qa\xCC\x88"); |
| 383 // Multiple matches, non-overlapping | 398 |
| 384 String haystack1 = String::fromUTF8("aA\xCC\x88QA\xCC\x88sA\xCC\x88qa\xCC\x8
8rfi\xC3\xA4q\xC3\xA4"); | 399 // Multiple matches, non-overlapping |
| 385 EXPECT_EQ(1u, haystack1.findIgnoringASCIICase(needle)); | 400 String haystack1 = String::fromUTF8( |
| 386 EXPECT_EQ(7u, haystack1.findIgnoringASCIICase(needle, 2)); | 401 "aA\xCC\x88QA\xCC\x88sA\xCC\x88qa\xCC\x88rfi\xC3\xA4q\xC3\xA4"); |
| 387 EXPECT_EQ(kNotFound, haystack1.findIgnoringASCIICase(needle, 8)); | 402 EXPECT_EQ(1u, haystack1.findIgnoringASCIICase(needle)); |
| 388 | 403 EXPECT_EQ(7u, haystack1.findIgnoringASCIICase(needle, 2)); |
| 389 // Multiple matches, overlapping | 404 EXPECT_EQ(kNotFound, haystack1.findIgnoringASCIICase(needle, 8)); |
| 390 String haystack2 = String::fromUTF8("aA\xCC\x88QA\xCC\x88qa\xCC\x88rfi"); | 405 |
| 391 EXPECT_EQ(1u, haystack2.findIgnoringASCIICase(needle)); | 406 // Multiple matches, overlapping |
| 392 EXPECT_EQ(4u, haystack2.findIgnoringASCIICase(needle, 2)); | 407 String haystack2 = String::fromUTF8("aA\xCC\x88QA\xCC\x88qa\xCC\x88rfi"); |
| 393 EXPECT_EQ(kNotFound, haystack2.findIgnoringASCIICase(needle, 5)); | 408 EXPECT_EQ(1u, haystack2.findIgnoringASCIICase(needle)); |
| 394 } | 409 EXPECT_EQ(4u, haystack2.findIgnoringASCIICase(needle, 2)); |
| 395 | 410 EXPECT_EQ(kNotFound, haystack2.findIgnoringASCIICase(needle, 5)); |
| 396 TEST(StringTest, Lower) | 411 } |
| 397 { | 412 |
| 398 EXPECT_STREQ("link", String("LINK").lower().ascii().data()); | 413 TEST(StringTest, Lower) { |
| 399 EXPECT_STREQ("link", String("lInk").lower().ascii().data()); | 414 EXPECT_STREQ("link", String("LINK").lower().ascii().data()); |
| 400 EXPECT_STREQ("lin\xE1k", String("lIn\xC1k").lower().latin1().data()); | 415 EXPECT_STREQ("link", String("lInk").lower().ascii().data()); |
| 401 EXPECT_STREQ("link", String::fromUTF8("LIN\xE2\x84\xAA").lower().utf8().data
()); | 416 EXPECT_STREQ("lin\xE1k", String("lIn\xC1k").lower().latin1().data()); |
| 402 } | 417 EXPECT_STREQ("link", |
| 403 | 418 String::fromUTF8("LIN\xE2\x84\xAA").lower().utf8().data()); |
| 404 } // namespace WTF | 419 } |
| 420 |
| 421 } // namespace WTF |
| OLD | NEW |