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

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

Issue 2033293002: Implement StringImpl sharing for StringView::toString(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix preload scanner bug. Created 4 years, 6 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/StringViewTest.cpp
diff --git a/third_party/WebKit/Source/wtf/text/StringViewTest.cpp b/third_party/WebKit/Source/wtf/text/StringViewTest.cpp
index 05c781d3dc6db475059dbe366054506ae323453a..1b0b72e76d291660fc67456f7337a093ab73029f 100644
--- a/third_party/WebKit/Source/wtf/text/StringViewTest.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringViewTest.cpp
@@ -318,18 +318,26 @@ TEST(StringViewTest, IsEmpty)
TEST(StringViewTest, ToString)
{
- // Empty string optimization.
EXPECT_EQ(emptyString().impl(), StringView("").toString().impl());
+ EXPECT_EQ(nullAtom.impl(), StringView().toString().impl());
// NOTE: All the construction tests also check toString().
}
TEST(StringViewTest, ToAtomicString)
{
- EXPECT_EQ(AtomicString(), nullAtom);
- EXPECT_EQ(AtomicString(""), emptyAtom);
+ EXPECT_EQ(nullAtom.impl(), StringView().toAtomicString());
+ EXPECT_EQ(emptyAtom.impl(), StringView("").toAtomicString());
EXPECT_EQ(AtomicString("12"), StringView(kChars8, 2).toAtomicString());
// AtomicString will convert to 8bit if possible when creating the string.
- EXPECT_EQ(AtomicString("12"), StringView(kChars16, 2).toAtomicString());
+ EXPECT_EQ(AtomicString("12").impl(), StringView(kChars16, 2).toAtomicString().impl());
+}
+
+TEST(StringViewTest, ToStringImplSharing)
+{
+ String string(kChars);
+ EXPECT_EQ(string.impl(), StringView(string).sharedImpl());
+ EXPECT_EQ(string.impl(), StringView(string).toString().impl());
+ EXPECT_EQ(string.impl(), StringView(string).toAtomicString().impl());
}
TEST(StringViewTest, NullString)

Powered by Google App Engine
This is Rietveld 408576698