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

Unified Diff: tests/StringTest.cpp

Issue 646213002: Eliminate one copy of replace_char() function. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bad... Created 6 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
Index: tests/StringTest.cpp
diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp
index 13ee5ec2153ff6da775bef64887fc16f759da2f4..d2fa1500db28853f2fc6672d0e36ac6284849932 100644
--- a/tests/StringTest.cpp
+++ b/tests/StringTest.cpp
@@ -183,7 +183,37 @@ DEF_TEST(String, reporter) {
REPORTER_ASSERT(reporter, buffer[18] == ' ');
REPORTER_ASSERT(reporter, buffer[19] == 0);
REPORTER_ASSERT(reporter, buffer[20] == 'a');
+}
+DEF_TEST(String_Replace, r) {
+ SkString str("skia_2d");
+ str.replace('_', '-');
+ REPORTER_ASSERT(r, str.equals("skia-2d"));
+
+ str.set("meat");
+ str.replace('a', 'e');
+ REPORTER_ASSERT(r, str.equals("meet"));
+
+ str.set("hello, world!");
+ str.replace('h', 'h');
+ REPORTER_ASSERT(r, str.equals("hello, world!"));
+ str.replace('x', 'x');
+ REPORTER_ASSERT(r, str.equals("hello, world!"));
+ str.replace('o', 'u');
+ REPORTER_ASSERT(r, str.equals("hellu, wurld!"));
+ str.replace('x', 'u');
+ REPORTER_ASSERT(r, str.equals("hellu, wurld!"));
+ str.replace('x', 'y');
+ REPORTER_ASSERT(r, str.equals("hellu, wurld!"));
+
+ str.set("");
+ str.replace('a', 'b');
+ REPORTER_ASSERT(r, str.equals(""));
+
+ str.set("\xed\x95\x9c\xea\xb5\xad\xec\x96\xb4");
tfarina 2014/11/12 01:41:34 Could you suggest another string to test that SkUT
reed1 2014/11/12 14:11:25 Why not build the string with a set of known Unich
+ //SkString hangul2("\xb4\x95\x9c\xea\xb5\xad\xec\x96\xb4");
+ str.replace('\xed', '\xb4');
+ //REPORTER_ASSERT(r, hangul == hangul2);
}
DEF_TEST(String_SkStrSplit, r) {
« src/core/SkString.cpp ('K') | « src/core/SkString.cpp ('k') | tools/PictureRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698