OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include "SkString.h" | 10 #include "SkString.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 REPORTER_ASSERT(r, results.count() == 6); | 194 REPORTER_ASSERT(r, results.count() == 6); |
195 REPORTER_ASSERT(r, results[0].equals("a")); | 195 REPORTER_ASSERT(r, results[0].equals("a")); |
196 REPORTER_ASSERT(r, results[1].equals("b")); | 196 REPORTER_ASSERT(r, results[1].equals("b")); |
197 REPORTER_ASSERT(r, results[2].equals("c")); | 197 REPORTER_ASSERT(r, results[2].equals("c")); |
198 REPORTER_ASSERT(r, results[3].equals("dee")); | 198 REPORTER_ASSERT(r, results[3].equals("dee")); |
199 REPORTER_ASSERT(r, results[4].equals("f")); | 199 REPORTER_ASSERT(r, results[4].equals("f")); |
200 REPORTER_ASSERT(r, results[5].equals("g")); | 200 REPORTER_ASSERT(r, results[5].equals("g")); |
201 | 201 |
202 results.reset(); | 202 results.reset(); |
203 SkStrSplit("\n", "\n", &results); | 203 SkStrSplit("\n", "\n", &results); |
204 REPORTER_ASSERT(r, results.count() == 1); | 204 REPORTER_ASSERT(r, results.count() == 0); |
205 | 205 |
206 results.reset(); | 206 results.reset(); |
207 SkStrSplit("", "\n", &results); | 207 SkStrSplit("", "\n", &results); |
208 REPORTER_ASSERT(r, results.count() == 0); | 208 REPORTER_ASSERT(r, results.count() == 0); |
| 209 |
| 210 results.reset(); |
| 211 SkStrSplit("a", "\n", &results); |
| 212 REPORTER_ASSERT(r, results.count() == 1); |
| 213 REPORTER_ASSERT(r, results[0].equals("a")); |
209 } | 214 } |
| 215 DEF_TEST(String_SkStrSplit_All, r) { |
| 216 SkTArray<SkString> results; |
| 217 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", kStrict_SkStrSplitMode, &results); |
| 218 REPORTER_ASSERT(r, results.count() == 13); |
| 219 REPORTER_ASSERT(r, results[0].equals("a")); |
| 220 REPORTER_ASSERT(r, results[1].equals("")); |
| 221 REPORTER_ASSERT(r, results[2].equals("b")); |
| 222 REPORTER_ASSERT(r, results[3].equals("c")); |
| 223 REPORTER_ASSERT(r, results[4].equals("dee")); |
| 224 REPORTER_ASSERT(r, results[5].equals("")); |
| 225 REPORTER_ASSERT(r, results[6].equals("f")); |
| 226 REPORTER_ASSERT(r, results[7].equals("")); |
| 227 REPORTER_ASSERT(r, results[8].equals("")); |
| 228 REPORTER_ASSERT(r, results[9].equals("")); |
| 229 REPORTER_ASSERT(r, results[10].equals("")); |
| 230 REPORTER_ASSERT(r, results[11].equals("g")); |
| 231 REPORTER_ASSERT(r, results[12].equals("")); |
| 232 |
| 233 results.reset(); |
| 234 SkStrSplit("\n", "\n", kStrict_SkStrSplitMode, &results); |
| 235 REPORTER_ASSERT(r, results.count() == 2); |
| 236 REPORTER_ASSERT(r, results[0].equals("")); |
| 237 REPORTER_ASSERT(r, results[1].equals("")); |
| 238 |
| 239 results.reset(); |
| 240 SkStrSplit("", "\n", kStrict_SkStrSplitMode, &results); |
| 241 REPORTER_ASSERT(r, results.count() == 0); |
| 242 |
| 243 results.reset(); |
| 244 SkStrSplit("a", "\n", kStrict_SkStrSplitMode, &results); |
| 245 REPORTER_ASSERT(r, results.count() == 1); |
| 246 REPORTER_ASSERT(r, results[0].equals("a")); |
| 247 |
| 248 results.reset(); |
| 249 SkStrSplit(",,", ",", kStrict_SkStrSplitMode, &results); |
| 250 REPORTER_ASSERT(r, results.count() == 3); |
| 251 REPORTER_ASSERT(r, results[0].equals("")); |
| 252 REPORTER_ASSERT(r, results[1].equals("")); |
| 253 REPORTER_ASSERT(r, results[2].equals("")); |
| 254 |
| 255 results.reset(); |
| 256 SkStrSplit(",a,b,", ",", kStrict_SkStrSplitMode, &results); |
| 257 REPORTER_ASSERT(r, results.count() == 4); |
| 258 REPORTER_ASSERT(r, results[0].equals("")); |
| 259 REPORTER_ASSERT(r, results[1].equals("a")); |
| 260 REPORTER_ASSERT(r, results[2].equals("b")); |
| 261 REPORTER_ASSERT(r, results[3].equals("")); |
| 262 } |
OLD | NEW |