Index: tests/StringTest.cpp |
diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp |
index f621dc96aff6c56f080351623b50b02bed1f08ca..9e41c48c845d689c740d1544c731a1652750f44c 100644 |
--- a/tests/StringTest.cpp |
+++ b/tests/StringTest.cpp |
@@ -201,9 +201,62 @@ DEF_TEST(String_SkStrSplit, r) { |
results.reset(); |
SkStrSplit("\n", "\n", &results); |
- REPORTER_ASSERT(r, results.count() == 1); |
+ REPORTER_ASSERT(r, results.count() == 0); |
results.reset(); |
SkStrSplit("", "\n", &results); |
REPORTER_ASSERT(r, results.count() == 0); |
+ |
+ results.reset(); |
+ SkStrSplit("a", "\n", &results); |
+ REPORTER_ASSERT(r, results.count() == 1); |
+ REPORTER_ASSERT(r, results[0].equals("a")); |
+} |
+DEF_TEST(String_SkStrSplit_All, r) { |
+ SkTArray<SkString> results; |
+ SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", kStrict_SkStrSplitMode, &results); |
+ REPORTER_ASSERT(r, results.count() == 13); |
+ REPORTER_ASSERT(r, results[0].equals("a")); |
+ REPORTER_ASSERT(r, results[1].equals("")); |
+ REPORTER_ASSERT(r, results[2].equals("b")); |
+ REPORTER_ASSERT(r, results[3].equals("c")); |
+ REPORTER_ASSERT(r, results[4].equals("dee")); |
+ REPORTER_ASSERT(r, results[5].equals("")); |
+ REPORTER_ASSERT(r, results[6].equals("f")); |
+ REPORTER_ASSERT(r, results[7].equals("")); |
+ REPORTER_ASSERT(r, results[8].equals("")); |
+ REPORTER_ASSERT(r, results[9].equals("")); |
+ REPORTER_ASSERT(r, results[10].equals("")); |
+ REPORTER_ASSERT(r, results[11].equals("g")); |
+ REPORTER_ASSERT(r, results[12].equals("")); |
+ |
+ results.reset(); |
+ SkStrSplit("\n", "\n", kStrict_SkStrSplitMode, &results); |
+ REPORTER_ASSERT(r, results.count() == 2); |
+ REPORTER_ASSERT(r, results[0].equals("")); |
+ REPORTER_ASSERT(r, results[1].equals("")); |
+ |
+ results.reset(); |
+ SkStrSplit("", "\n", kStrict_SkStrSplitMode, &results); |
+ REPORTER_ASSERT(r, results.count() == 0); |
+ |
+ results.reset(); |
+ SkStrSplit("a", "\n", kStrict_SkStrSplitMode, &results); |
+ REPORTER_ASSERT(r, results.count() == 1); |
+ REPORTER_ASSERT(r, results[0].equals("a")); |
+ |
+ results.reset(); |
+ SkStrSplit(",,", ",", kStrict_SkStrSplitMode, &results); |
+ REPORTER_ASSERT(r, results.count() == 3); |
+ REPORTER_ASSERT(r, results[0].equals("")); |
+ REPORTER_ASSERT(r, results[1].equals("")); |
+ REPORTER_ASSERT(r, results[2].equals("")); |
+ |
+ results.reset(); |
+ SkStrSplit(",a,b,", ",", kStrict_SkStrSplitMode, &results); |
+ REPORTER_ASSERT(r, results.count() == 4); |
+ REPORTER_ASSERT(r, results[0].equals("")); |
+ REPORTER_ASSERT(r, results[1].equals("a")); |
+ REPORTER_ASSERT(r, results[2].equals("b")); |
+ REPORTER_ASSERT(r, results[3].equals("")); |
} |