| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 char buffer [40]; | 178 char buffer [40]; |
| 179 memset(buffer, 'a', 40); | 179 memset(buffer, 'a', 40); |
| 180 REPORTER_ASSERT(reporter, buffer[18] == 'a'); | 180 REPORTER_ASSERT(reporter, buffer[18] == 'a'); |
| 181 REPORTER_ASSERT(reporter, buffer[19] == 'a'); | 181 REPORTER_ASSERT(reporter, buffer[19] == 'a'); |
| 182 REPORTER_ASSERT(reporter, buffer[20] == 'a'); | 182 REPORTER_ASSERT(reporter, buffer[20] == 'a'); |
| 183 printfAnalog(buffer, 20, "%30d", 0); | 183 printfAnalog(buffer, 20, "%30d", 0); |
| 184 REPORTER_ASSERT(reporter, buffer[18] == ' '); | 184 REPORTER_ASSERT(reporter, buffer[18] == ' '); |
| 185 REPORTER_ASSERT(reporter, buffer[19] == 0); | 185 REPORTER_ASSERT(reporter, buffer[19] == 0); |
| 186 REPORTER_ASSERT(reporter, buffer[20] == 'a'); | 186 REPORTER_ASSERT(reporter, buffer[20] == 'a'); |
| 187 | 187 |
| 188 SkString h("b"); |
| 189 for (int i = 2; i < 10; ++i) { |
| 190 h.resize(i); |
| 191 char* writeChar = h.writable_str() + i - 1; |
| 192 *writeChar = (char) ('a' + i); |
| 193 REPORTER_ASSERT(reporter, !strncmp("bcdefghijk", h.c_str(), i)); |
| 194 } |
| 188 } | 195 } |
| 189 | 196 |
| 190 DEF_TEST(String_SkStrSplit, r) { | 197 DEF_TEST(String_SkStrSplit, r) { |
| 191 SkTArray<SkString> results; | 198 SkTArray<SkString> results; |
| 192 | 199 |
| 193 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results); | 200 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results); |
| 194 REPORTER_ASSERT(r, results.count() == 6); | 201 REPORTER_ASSERT(r, results.count() == 6); |
| 195 REPORTER_ASSERT(r, results[0].equals("a")); | 202 REPORTER_ASSERT(r, results[0].equals("a")); |
| 196 REPORTER_ASSERT(r, results[1].equals("b")); | 203 REPORTER_ASSERT(r, results[1].equals("b")); |
| 197 REPORTER_ASSERT(r, results[2].equals("c")); | 204 REPORTER_ASSERT(r, results[2].equals("c")); |
| 198 REPORTER_ASSERT(r, results[3].equals("dee")); | 205 REPORTER_ASSERT(r, results[3].equals("dee")); |
| 199 REPORTER_ASSERT(r, results[4].equals("f")); | 206 REPORTER_ASSERT(r, results[4].equals("f")); |
| 200 REPORTER_ASSERT(r, results[5].equals("g")); | 207 REPORTER_ASSERT(r, results[5].equals("g")); |
| 201 } | 208 } |
| OLD | NEW |