Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Unified Diff: third_party/WebKit/Source/wtf/text/WTFStringTest.cpp

Issue 2508953003: WTF: Add comments and tests for Unicode aware case-insensitive string operations. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/WTFStringTest.cpp
diff --git a/third_party/WebKit/Source/wtf/text/WTFStringTest.cpp b/third_party/WebKit/Source/wtf/text/WTFStringTest.cpp
index c756b39d0b2defd0c9c76164659c8ee5396e3ac0..6e2a8efb8afe40c56aad3499dfae46a756a2c1ff 100644
--- a/third_party/WebKit/Source/wtf/text/WTFStringTest.cpp
+++ b/third_party/WebKit/Source/wtf/text/WTFStringTest.cpp
@@ -336,6 +336,12 @@ TEST(StringTest, ToLowerLocale) {
}
}
+TEST(StringTest, StartsWithIgnoringUnicodeCase) {
+ // [U+017F U+212A i a] starts with "sk".
+ EXPECT_TRUE(String::fromUTF8("\xC5\xBF\xE2\x84\xAAia")
+ .startsWith("sk", TextCaseInsensitive));
+}
+
TEST(StringTest, StartsWithIgnoringASCIICase) {
String allASCII("LINK");
String allASCIILowerCase("link");
@@ -415,10 +421,17 @@ TEST(StringTest, Lower) {
EXPECT_STREQ("link", String("LINK").lower().ascii().data());
EXPECT_STREQ("link", String("lInk").lower().ascii().data());
EXPECT_STREQ("lin\xE1k", String("lIn\xC1k").lower().latin1().data());
+ // U+212A -> k
EXPECT_STREQ("link",
String::fromUTF8("LIN\xE2\x84\xAA").lower().utf8().data());
}
+TEST(StringTest, Upper) {
+ EXPECT_STREQ("CROSS", String("cross").upper().utf8().data());
+ // U+017F -> S
+ EXPECT_STREQ("CROSS", String::fromUTF8("cro\xC5\xBFs").upper().utf8().data());
+}
+
TEST(StringTest, Ensure16Bit) {
String string8("8bit");
EXPECT_TRUE(string8.is8Bit());
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698