Changeset 181512 in webkit
- Timestamp:
- Mar 15, 2015, 12:43:18 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 19 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/selectors/attribute-exact-value-match-is-ascii-case-insensitive-expected.txt (added)
-
LayoutTests/fast/selectors/attribute-exact-value-match-is-ascii-case-insensitive.html (added)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/WTF.vcxproj/WTF.vcxproj (modified) (1 diff)
-
Source/WTF/WTF.vcxproj/WTF.vcxproj.filters (modified) (1 diff)
-
Source/WTF/WTF.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Source/WTF/wtf/ASCIICType.h (modified) (3 diffs)
-
Source/WTF/wtf/CMakeLists.txt (modified) (1 diff)
-
Source/WTF/wtf/text/AtomicString.h (modified) (1 diff)
-
Source/WTF/wtf/text/StringCommon.h (added)
-
Source/WTF/wtf/text/StringImpl.cpp (modified) (1 diff)
-
Source/WTF/wtf/text/StringImpl.h (modified) (2 diffs)
-
Source/WTF/wtf/text/StringView.h (modified) (2 diffs)
-
Source/WTF/wtf/text/WTFString.h (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSParser.cpp (modified) (1 diff)
-
Source/WebCore/css/SelectorCheckerTestFunctions.h (modified) (1 diff)
-
Source/WebCore/cssjit/SelectorCompiler.cpp (modified) (2 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp (modified) (1 diff)
-
Tools/TestWebKitAPI/Tests/WTF/StringView.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r181509 r181512 1 2015-03-15 Benjamin Poulain <bpoulain@apple.com> 2 3 Change the exact attribute matching to be ASCII case-insensitive 4 https://bugs.webkit.org/show_bug.cgi?id=142609 5 6 Reviewed by Darin Adler. 7 8 * fast/selectors/attribute-exact-value-match-is-ascii-case-insensitive-expected.txt: Added. 9 * fast/selectors/attribute-exact-value-match-is-ascii-case-insensitive.html: Added. 10 1 11 2015-03-15 Brent Fulgham <bfulgham@apple.com> 2 12 -
trunk/Source/WTF/ChangeLog
r181501 r181512 1 2015-03-15 Benjamin Poulain <bpoulain@apple.com> 2 3 Change the exact attribute matching to be ASCII case-insensitive 4 https://bugs.webkit.org/show_bug.cgi?id=142609 5 6 Reviewed by Darin Adler. 7 8 Add support for ASCII case insensitive comparisons to all the string 9 classes. 10 11 The new file StringCommon.h has the common algorithm to avoid repeating 12 the same code with different types. 13 14 * WTF.vcxproj/WTF.vcxproj: 15 * WTF.vcxproj/WTF.vcxproj.filters: 16 * wtf/ASCIICType.h: 17 (WTF::toASCIILower): 18 * wtf/CMakeLists.txt: 19 * wtf/text/AtomicString.h: 20 (WTF::equalIgnoringASCIICase): 21 * wtf/text/StringCommon.h: Added. 22 (WTF::equalIgnoringASCIICase): 23 (WTF::equalIgnoringASCIICaseCommon): 24 * wtf/text/StringImpl.cpp: 25 (WTF::equalIgnoringASCIICase): 26 (WTF::equalIgnoringASCIICaseNonNull): 27 (WTF::StringImpl::utf8Impl): 28 (WTF::StringImpl::defaultWritingDirection): Deleted. 29 (WTF::StringImpl::adopt): Deleted. 30 (WTF::StringImpl::sizeInBytes): Deleted. 31 (WTF::putUTF8Triple): Deleted. 32 (WTF::StringImpl::utf8): Deleted. 33 * wtf/text/StringImpl.h: 34 (WTF::StringImpl::isSubString): Deleted. 35 (WTF::find): Deleted. 36 1 37 2015-03-14 Michael Saboff <msaboff@apple.com> 2 38 -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj
r181485 r181512 292 292 <ClInclude Include="..\wtf\text\StringBuffer.h" /> 293 293 <ClInclude Include="..\wtf\text\StringBuilder.h" /> 294 <ClInclude Include="..\wtf\text\StringCommon.h" /> 294 295 <ClInclude Include="..\wtf\text\StringConcatenate.h" /> 295 296 <ClInclude Include="..\wtf\text\StringHash.h" /> -
trunk/Source/WTF/WTF.vcxproj/WTF.vcxproj.filters
r181485 r181512 326 326 </ClInclude> 327 327 <ClInclude Include="..\wtf\text\StringBuilder.h"> 328 <Filter>text</Filter> 329 </ClInclude> 330 <ClInclude Include="..\wtf\text\StringCommon.h"> 328 331 <Filter>text</Filter> 329 332 </ClInclude> -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r181485 r181512 74 74 2CDED0F318115C85004DBA70 /* RunLoop.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2CDED0F118115C85004DBA70 /* RunLoop.cpp */; }; 75 75 2CDED0F418115C85004DBA70 /* RunLoop.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CDED0F218115C85004DBA70 /* RunLoop.h */; }; 76 430B47891AAAAC1A001223DA /* StringCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 430B47871AAAAC1A001223DA /* StringCommon.h */; }; 76 77 7CBBA07419BB7FDC00BBF025 /* OSObjectPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */; }; 77 78 7CDD7FF8186D291E007433CD /* IteratorAdaptors.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */; }; … … 358 359 2CDED0F118115C85004DBA70 /* RunLoop.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RunLoop.cpp; sourceTree = "<group>"; }; 359 360 2CDED0F218115C85004DBA70 /* RunLoop.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RunLoop.h; sourceTree = "<group>"; }; 361 430B47871AAAAC1A001223DA /* StringCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringCommon.h; sourceTree = "<group>"; }; 360 362 5D247B6214689B8600E78B76 /* libWTF.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libWTF.a; sourceTree = BUILT_PRODUCTS_DIR; }; 361 363 5D247B6E14689C4700E78B76 /* Base.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Base.xcconfig; sourceTree = "<group>"; }; … … 950 952 A8A47324151A825B004123FF /* StringBuilder.cpp */, 951 953 A8A47325151A825B004123FF /* StringBuilder.h */, 954 430B47871AAAAC1A001223DA /* StringCommon.h */, 952 955 A8A47326151A825B004123FF /* StringConcatenate.h */, 953 956 A8A47327151A825B004123FF /* StringHash.h */, … … 1197 1200 1A6EB1E0187D0BD30030126F /* StringView.h in Headers */, 1198 1201 A8A47433151A825B004123FF /* TemporaryChange.h in Headers */, 1202 430B47891AAAAC1A001223DA /* StringCommon.h in Headers */, 1199 1203 A8A47444151A825B004123FF /* TextPosition.h in Headers */, 1200 1204 A8A47447151A825B004123FF /* ThreadFunctionInvocation.h in Headers */, -
trunk/Source/WTF/wtf/ASCIICType.h
r181497 r181512 31 31 32 32 #include <wtf/Assertions.h> 33 #include <wtf/text/LChar.h> 33 34 34 35 // The behavior of many of the functions in the <ctype.h> header is dependent … … 43 44 44 45 namespace WTF { 46 47 const unsigned char asciiCaseFoldTable[256] = { 48 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 49 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 50 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 51 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 52 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 53 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, 54 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 55 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 56 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 57 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 58 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 59 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 60 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 61 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 62 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 63 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff 64 }; 45 65 46 66 template<typename CharType> inline bool isASCII(CharType c) … … 115 135 { 116 136 return c | ((c >= 'A' && c <= 'Z') << 5); 137 } 138 139 template<> 140 inline char toASCIILower(char c) 141 { 142 return static_cast<char>(asciiCaseFoldTable[static_cast<unsigned char>(c)]); 143 } 144 145 template<> 146 inline LChar toASCIILower(LChar c) 147 { 148 return asciiCaseFoldTable[c]; 117 149 } 118 150 -
trunk/Source/WTF/wtf/CMakeLists.txt
r181485 r181512 130 130 text/LChar.h 131 131 text/StringBuffer.h 132 text/StringCommon.h 132 133 text/StringHash.h 133 134 text/StringImpl.h -
trunk/Source/WTF/wtf/text/AtomicString.h
r179429 r181512 248 248 inline bool equalIgnoringCase(const String& a, const AtomicString& b) { return equalIgnoringCase(a.impl(), b.impl()); } 249 249 250 inline bool equalIgnoringASCIICase(const AtomicString& a, const AtomicString& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); } 251 inline bool equalIgnoringASCIICase(const AtomicString& a, const String& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); } 252 inline bool equalIgnoringASCIICase(const String& a, const AtomicString& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); } 253 250 254 // Define external global variables for the commonly used atomic strings. 251 255 // These are only usable from the main thread. -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r181105 r181512 2019 2019 } 2020 2020 2021 bool equalIgnoringASCIICase(const StringImpl& a, const StringImpl& b) 2022 { 2023 return equalIgnoringASCIICaseCommon(a, b); 2024 } 2025 2026 bool equalIgnoringASCIICase(const StringImpl* a, const StringImpl*b) 2027 { 2028 if (a == b) 2029 return true; 2030 if (!a || !b) 2031 return false; 2032 return equalIgnoringASCIICaseCommon(*a, *b); 2033 } 2034 2035 bool equalIgnoringASCIICaseNonNull(const StringImpl* a, const StringImpl* b) 2036 { 2037 ASSERT(a); 2038 ASSERT(b); 2039 return equalIgnoringASCIICaseCommon(*a, *b); 2040 } 2041 2021 2042 UCharDirection StringImpl::defaultWritingDirection(bool* hasStrongDirectionality) 2022 2043 { -
trunk/Source/WTF/wtf/text/StringImpl.h
r181105 r181512 1133 1133 WTF_EXPORT_STRING_API bool equalIgnoringNullity(const UChar*, size_t length, StringImpl*); 1134 1134 1135 WTF_EXPORT_STRING_API bool equalIgnoringASCIICase(const StringImpl&, const StringImpl&); 1136 WTF_EXPORT_STRING_API bool equalIgnoringASCIICase(const StringImpl*, const StringImpl*); 1137 WTF_EXPORT_STRING_API bool equalIgnoringASCIICaseNonNull(const StringImpl*, const StringImpl*); 1138 1135 1139 template<typename CharacterType> 1136 1140 inline size_t find(const CharacterType* characters, unsigned length, CharacterType matchCharacter, unsigned index = 0) … … 1375 1379 using WTF::StringImpl; 1376 1380 using WTF::equal; 1381 using WTF::equalIgnoringASCIICase; 1377 1382 using WTF::TextCaseSensitivity; 1378 1383 using WTF::TextCaseSensitive; -
trunk/Source/WTF/wtf/text/StringView.h
r179532 r181512 32 32 #include <wtf/Vector.h> 33 33 #include <wtf/text/LChar.h> 34 #include <wtf/text/StringCommon.h> 34 35 35 36 // FIXME: Enabling the StringView lifetime checking causes the MSVC build to fail. Figure out why. … … 506 507 inline bool equalIgnoringASCIICase(StringView a, StringView b) 507 508 { 508 unsigned aLength = a.length(); 509 if (aLength != b.length()) 510 return false; 511 for (size_t i = 0; i < aLength; ++i) { 512 if (toASCIILower(a[i]) != toASCIILower(b[i])) 513 return false; 514 } 515 return true; 509 return equalIgnoringASCIICaseCommon(a, b); 516 510 } 517 511 -
trunk/Source/WTF/wtf/text/WTFString.h
r181105 r181512 492 492 inline bool equalIgnoringCase(const LChar* a, const String& b) { return equalIgnoringCase(a, b.impl()); } 493 493 inline bool equalIgnoringCase(const char* a, const String& b) { return equalIgnoringCase(reinterpret_cast<const LChar*>(a), b.impl()); } 494 495 inline bool equalIgnoringASCIICase(const String& a, const String& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); } 494 496 495 497 inline bool equalPossiblyIgnoringCase(const String& a, const String& b, bool ignoreCase) -
trunk/Source/WebCore/ChangeLog
r181510 r181512 1 2015-03-15 Benjamin Poulain <bpoulain@apple.com> 2 3 Change the exact attribute matching to be ASCII case-insensitive 4 https://bugs.webkit.org/show_bug.cgi?id=142609 5 6 Reviewed by Darin Adler. 7 8 In CSS, testing attribute values should be ASCII case-insensitive, 9 previously we were using full unicode case conversion. 10 11 Test: fast/selectors/attribute-exact-value-match-is-ascii-case-insensitive.html 12 13 * css/CSSParser.cpp: 14 (WebCore::CSSParser::parseKeyframeSelector): 15 The CSS parser has its own fast version for ASCII case insensitive. 16 This code was using the general equalIgnoringASCIICase() which was causing name conflicts, 17 change that to the normal CSS parser version. 18 19 * css/SelectorCheckerTestFunctions.h: 20 (WebCore::equalIgnoringASCIICase): Deleted. 21 * cssjit/SelectorCompiler.cpp: 22 (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementAttributeValueExactMatching): 23 1 24 2015-03-15 Brent Fulgham <bfulgham@apple.com> 2 25 -
trunk/Source/WebCore/css/CSSParser.cpp
r181426 r181512 4775 4775 4776 4776 // For now the syntax MUST be 'xxx%' or 'from' or 'to', where xxx is a legal floating point number 4777 if (equalIgnoring ASCIICase(cur, "from"))4777 if (equalIgnoringCase(cur, "from")) 4778 4778 key = 0; 4779 else if (equalIgnoring ASCIICase(cur, "to"))4779 else if (equalIgnoringCase(cur, "to")) 4780 4780 key = 1; 4781 4781 else if (cur.endsWith('%')) { -
trunk/Source/WebCore/css/SelectorCheckerTestFunctions.h
r181408 r181512 121 121 } 122 122 123 ALWAYS_INLINE bool equalIgnoringASCIICase(const String& a, const String& b)124 {125 if (a.length() != b.length())126 return false;127 for (size_t i = 0; i < a.length(); ++i) {128 if (toASCIILower(a[i]) != toASCIILower(b[i]))129 return false;130 }131 return true;132 }133 134 123 ALWAYS_INLINE bool containslanguageSubtagMatchingRange(StringView language, StringView range, unsigned languageLength, unsigned& position) 135 124 { -
trunk/Source/WebCore/cssjit/SelectorCompiler.cpp
r181283 r181512 2935 2935 2936 2936 FunctionCall functionCall(m_assembler, m_registerAllocator, m_stackAllocator, m_functionCalls); 2937 functionCall.setFunctionAddress(WTF::equalIgnoring CaseNonNull);2937 functionCall.setFunctionAddress(WTF::equalIgnoringASCIICaseNonNull); 2938 2938 functionCall.setTwoArguments(valueStringImpl, expectedValueRegister); 2939 2939 failureCases.append(functionCall.callAndBranchOnBooleanReturnValue(Assembler::Zero)); … … 2948 2948 Assembler::Jump skipCaseInsensitiveComparison = m_assembler.branchPtr(Assembler::Equal, valueStringImpl, expectedValueRegister); 2949 2949 FunctionCall functionCall(m_assembler, m_registerAllocator, m_stackAllocator, m_functionCalls); 2950 functionCall.setFunctionAddress(WTF::equalIgnoring CaseNonNull);2950 functionCall.setFunctionAddress(WTF::equalIgnoringASCIICaseNonNull); 2951 2951 functionCall.setTwoArguments(valueStringImpl, expectedValueRegister); 2952 2952 failureCases.append(functionCall.callAndBranchOnBooleanReturnValue(Assembler::Zero)); -
trunk/Tools/ChangeLog
r181479 r181512 1 2015-03-15 Benjamin Poulain <bpoulain@apple.com> 2 3 Change the exact attribute matching to be ASCII case-insensitive 4 https://bugs.webkit.org/show_bug.cgi?id=142609 5 6 Reviewed by Darin Adler. 7 8 * TestWebKitAPI/Tests/WTF/StringImpl.cpp: 9 * TestWebKitAPI/Tests/WTF/StringView.cpp: 10 1 11 2015-03-13 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp
r166076 r181512 100 100 } 101 101 102 TEST(WTF, StringImplEqualIgnoringASCIICaseBasic) 103 { 104 RefPtr<StringImpl> a = StringImpl::createFromLiteral("aBcDeFG"); 105 RefPtr<StringImpl> b = StringImpl::createFromLiteral("ABCDEFG"); 106 RefPtr<StringImpl> c = StringImpl::createFromLiteral("abcdefg"); 107 RefPtr<StringImpl> empty = StringImpl::create(reinterpret_cast<const LChar*>("")); 108 RefPtr<StringImpl> shorter = StringImpl::createFromLiteral("abcdef"); 109 110 // Identity. 111 ASSERT_TRUE(equalIgnoringASCIICase(a.get(), a.get())); 112 ASSERT_TRUE(equalIgnoringASCIICase(b.get(), b.get())); 113 ASSERT_TRUE(equalIgnoringASCIICase(c.get(), c.get())); 114 115 // Transitivity. 116 ASSERT_TRUE(equalIgnoringASCIICase(a.get(), b.get())); 117 ASSERT_TRUE(equalIgnoringASCIICase(b.get(), c.get())); 118 ASSERT_TRUE(equalIgnoringASCIICase(a.get(), c.get())); 119 120 // Negative cases. 121 ASSERT_FALSE(equalIgnoringASCIICase(a.get(), empty.get())); 122 ASSERT_FALSE(equalIgnoringASCIICase(b.get(), empty.get())); 123 ASSERT_FALSE(equalIgnoringASCIICase(c.get(), empty.get())); 124 ASSERT_FALSE(equalIgnoringASCIICase(a.get(), shorter.get())); 125 ASSERT_FALSE(equalIgnoringASCIICase(b.get(), shorter.get())); 126 ASSERT_FALSE(equalIgnoringASCIICase(c.get(), shorter.get())); 127 } 128 129 TEST(WTF, StringImplEqualIgnoringASCIICaseWithNull) 130 { 131 RefPtr<StringImpl> reference = StringImpl::createFromLiteral("aBcDeFG"); 132 ASSERT_FALSE(equalIgnoringASCIICase(nullptr, reference.get())); 133 ASSERT_FALSE(equalIgnoringASCIICase(reference.get(), nullptr)); 134 ASSERT_TRUE(equalIgnoringASCIICase(nullptr, nullptr)); 135 } 136 137 TEST(WTF, StringImplEqualIgnoringASCIICaseWithEmpty) 138 { 139 RefPtr<StringImpl> a = StringImpl::create(reinterpret_cast<const LChar*>("")); 140 RefPtr<StringImpl> b = StringImpl::create(reinterpret_cast<const LChar*>("")); 141 ASSERT_TRUE(equalIgnoringASCIICase(a.get(), b.get())); 142 ASSERT_TRUE(equalIgnoringASCIICase(b.get(), a.get())); 143 } 144 145 TEST(WTF, StringImplEqualIgnoringASCIICaseWithLatin1Characters) 146 { 147 RefPtr<StringImpl> a = StringImpl::create(reinterpret_cast<const LChar*>("aBcéeFG")); 148 RefPtr<StringImpl> b = StringImpl::create(reinterpret_cast<const LChar*>("ABCÉEFG")); 149 RefPtr<StringImpl> c = StringImpl::create(reinterpret_cast<const LChar*>("ABCéEFG")); 150 RefPtr<StringImpl> d = StringImpl::create(reinterpret_cast<const LChar*>("abcéefg")); 151 152 // Identity. 153 ASSERT_TRUE(equalIgnoringASCIICase(a.get(), a.get())); 154 ASSERT_TRUE(equalIgnoringASCIICase(b.get(), b.get())); 155 ASSERT_TRUE(equalIgnoringASCIICase(c.get(), c.get())); 156 ASSERT_TRUE(equalIgnoringASCIICase(d.get(), d.get())); 157 158 // All combination. 159 ASSERT_FALSE(equalIgnoringASCIICase(a.get(), b.get())); 160 ASSERT_TRUE(equalIgnoringASCIICase(a.get(), c.get())); 161 ASSERT_TRUE(equalIgnoringASCIICase(a.get(), d.get())); 162 ASSERT_FALSE(equalIgnoringASCIICase(b.get(), c.get())); 163 ASSERT_FALSE(equalIgnoringASCIICase(b.get(), d.get())); 164 ASSERT_TRUE(equalIgnoringASCIICase(c.get(), d.get())); 165 } 166 102 167 } // namespace TestWebKitAPI -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp
r174271 r181512 143 143 } 144 144 145 TEST(WTF, StringViewEqualIgnoringASCIICaseBasic) 146 { 147 RefPtr<StringImpl> a = StringImpl::createFromLiteral("aBcDeFG"); 148 RefPtr<StringImpl> b = StringImpl::createFromLiteral("ABCDEFG"); 149 RefPtr<StringImpl> c = StringImpl::createFromLiteral("abcdefg"); 150 RefPtr<StringImpl> empty = StringImpl::create(reinterpret_cast<const LChar*>("")); 151 RefPtr<StringImpl> shorter = StringImpl::createFromLiteral("abcdef"); 152 153 StringView stringViewA(*a.get()); 154 StringView stringViewB(*b.get()); 155 StringView stringViewC(*c.get()); 156 StringView emptyStringView(*empty.get()); 157 StringView shorterStringView(*shorter.get()); 158 159 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewB)); 160 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, stringViewC)); 161 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, stringViewC)); 162 163 // Identity. 164 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewA)); 165 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, stringViewB)); 166 ASSERT_TRUE(equalIgnoringASCIICase(stringViewC, stringViewC)); 167 168 // Transitivity. 169 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewB)); 170 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, stringViewC)); 171 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewC)); 172 173 // Negative cases. 174 ASSERT_FALSE(equalIgnoringASCIICase(stringViewA, emptyStringView)); 175 ASSERT_FALSE(equalIgnoringASCIICase(stringViewB, emptyStringView)); 176 ASSERT_FALSE(equalIgnoringASCIICase(stringViewC, emptyStringView)); 177 ASSERT_FALSE(equalIgnoringASCIICase(stringViewA, shorterStringView)); 178 ASSERT_FALSE(equalIgnoringASCIICase(stringViewB, shorterStringView)); 179 ASSERT_FALSE(equalIgnoringASCIICase(stringViewC, shorterStringView)); 180 } 181 182 TEST(WTF, StringViewEqualIgnoringASCIICaseWithEmpty) 183 { 184 RefPtr<StringImpl> a = StringImpl::create(reinterpret_cast<const LChar*>("")); 185 RefPtr<StringImpl> b = StringImpl::create(reinterpret_cast<const LChar*>("")); 186 StringView stringViewA(*a.get()); 187 StringView stringViewB(*b.get()); 188 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewB)); 189 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, stringViewA)); 190 } 191 192 TEST(WTF, StringViewEqualIgnoringASCIICaseWithLatin1Characters) 193 { 194 RefPtr<StringImpl> a = StringImpl::create(reinterpret_cast<const LChar*>("aBcéeFG")); 195 RefPtr<StringImpl> b = StringImpl::create(reinterpret_cast<const LChar*>("ABCÉEFG")); 196 RefPtr<StringImpl> c = StringImpl::create(reinterpret_cast<const LChar*>("ABCéEFG")); 197 RefPtr<StringImpl> d = StringImpl::create(reinterpret_cast<const LChar*>("abcéefg")); 198 StringView stringViewA(*a.get()); 199 StringView stringViewB(*b.get()); 200 StringView stringViewC(*c.get()); 201 StringView stringViewD(*d.get()); 202 203 // Identity. 204 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewA)); 205 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, stringViewB)); 206 ASSERT_TRUE(equalIgnoringASCIICase(stringViewC, stringViewC)); 207 ASSERT_TRUE(equalIgnoringASCIICase(stringViewD, stringViewD)); 208 209 // All combination. 210 ASSERT_FALSE(equalIgnoringASCIICase(stringViewA, stringViewB)); 211 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewC)); 212 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewD)); 213 ASSERT_FALSE(equalIgnoringASCIICase(stringViewB, stringViewC)); 214 ASSERT_FALSE(equalIgnoringASCIICase(stringViewB, stringViewD)); 215 ASSERT_TRUE(equalIgnoringASCIICase(stringViewC, stringViewD)); 216 } 217 145 218 } // namespace TestWebKitAPI
Note:
See TracChangeset
for help on using the changeset viewer.