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

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

Issue 1768063002: Introduce String::fromUTF8Lenient() and use it for cache_name in CacheStorage API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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
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 319320f0341fb6e9908cd03ea3596f5b4b007c87..51086350ef8e0d4f61143f8ed90037995f6b9df4 100644
--- a/third_party/WebKit/Source/wtf/text/WTFStringTest.cpp
+++ b/third_party/WebKit/Source/wtf/text/WTFStringTest.cpp
@@ -401,4 +401,17 @@ TEST(StringTest, Lower)
EXPECT_STREQ("link", String::fromUTF8("LIN\xE2\x84\xAA").lower().utf8().data());
}
+TEST(StringTest, fromUTF8Lenient)
jsbell 2016/03/08 20:28:15 Nit: test name capitalized? (I know this matches
horo 2016/03/09 01:58:40 Done.
+{
+ UChar buffer[] = {0x0061 /* 'a' */, 0x0062 /* 'b' */, 0x0063 /* 'c' */, 0xd800 /* surrogate value */};
+ String utf16String(buffer, sizeof(buffer) / sizeof(UChar));
+ ASSERT_FALSE(utf16String.isNull());
+
+ std::string utf8String(utf16String.utf8().data());
+ ASSERT_TRUE(String::fromUTF8(utf8String.data()).isNull());
+ String utf16NewString = String::fromUTF8Lenient(utf8String.data(), utf8String.length());
jsbell 2016/03/08 20:28:15 In addition to testing that fromUTF8Lenient lets t
horo 2016/03/09 01:58:40 Done.
+ ASSERT_FALSE(utf16NewString.isNull());
+ ASSERT_EQ(utf16String, utf16NewString);
+}
+
} // namespace WTF

Powered by Google App Engine
This is Rietveld 408576698