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

Unified Diff: third_party/WebKit/Source/platform/wtf/text/StringBuilderTest.cpp

Issue 2956603002: Add StringBuilder::erase(index) (Closed)
Patch Set: Removed last character optimization Created 3 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
« no previous file with comments | « third_party/WebKit/Source/platform/wtf/text/StringBuilder.cpp ('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/platform/wtf/text/StringBuilderTest.cpp
diff --git a/third_party/WebKit/Source/platform/wtf/text/StringBuilderTest.cpp b/third_party/WebKit/Source/platform/wtf/text/StringBuilderTest.cpp
index 175b4f639b0304d9a2ac4019c25ceca042470250..3b2c056481e37f91ce29cd66a3301a03005284bd 100644
--- a/third_party/WebKit/Source/platform/wtf/text/StringBuilderTest.cpp
+++ b/third_party/WebKit/Source/platform/wtf/text/StringBuilderTest.cpp
@@ -210,6 +210,35 @@ TEST(StringBuilderTest, Resize) {
ExpectEmpty(builder);
}
+TEST(StringBuilderTest, Erase) {
+ StringBuilder builder;
+ builder.Append(String("01234"));
+ // Erase from String.
+ builder.erase(3);
+ ExpectBuilderContent("0124", builder);
+ // Erase from buffer.
+ builder.erase(1);
+ ExpectBuilderContent("024", builder);
+}
+
+TEST(StringBuilderTest, Erase16) {
+ StringBuilder builder;
+ builder.Append(String(u"\uFF10\uFF11\uFF12\uFF13\uFF14"));
+ // Erase from String.
+ builder.erase(3);
+ ExpectBuilderContent(u"\uFF10\uFF11\uFF12\uFF14", builder);
+ // Erase from buffer.
+ builder.erase(1);
+ ExpectBuilderContent(u"\uFF10\uFF12\uFF14", builder);
+}
+
+TEST(StringBuilderTest, EraseLast) {
+ StringBuilder builder;
+ builder.Append("01234");
+ builder.erase(4);
+ ExpectBuilderContent("0123", builder);
+}
+
TEST(StringBuilderTest, Equal) {
StringBuilder builder1;
StringBuilder builder2;
« no previous file with comments | « third_party/WebKit/Source/platform/wtf/text/StringBuilder.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698