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

Side by Side Diff: tests/StringTest.cpp

Issue 322253005: add replace_char() method to SkString API (skbug.com/2651) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Shift tests into DEF_TEST as requested Created 6 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 unified diff | Download patch
« include/core/SkString.h ('K') | « src/core/SkString.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 REPORTER_ASSERT(reporter, buffer[18] == 'a'); 179 REPORTER_ASSERT(reporter, buffer[18] == 'a');
180 REPORTER_ASSERT(reporter, buffer[19] == 'a'); 180 REPORTER_ASSERT(reporter, buffer[19] == 'a');
181 REPORTER_ASSERT(reporter, buffer[20] == 'a'); 181 REPORTER_ASSERT(reporter, buffer[20] == 'a');
182 printfAnalog(buffer, 20, "%30d", 0); 182 printfAnalog(buffer, 20, "%30d", 0);
183 REPORTER_ASSERT(reporter, buffer[18] == ' '); 183 REPORTER_ASSERT(reporter, buffer[18] == ' ');
184 REPORTER_ASSERT(reporter, buffer[19] == 0); 184 REPORTER_ASSERT(reporter, buffer[19] == 0);
185 REPORTER_ASSERT(reporter, buffer[20] == 'a'); 185 REPORTER_ASSERT(reporter, buffer[20] == 'a');
186 186
187 } 187 }
188 188
189 DEF_TEST(String_ReplaceChar, r) {
190 a.set("hello world");
191 a.replaceChar('h', 'h');
192 REPORTER_ASSERT(reporter, a.equals("hello world"));
193 a.replaceChar('x', 'x');
194 REPORTER_ASSERT(reporter, a.equals("hello world"));
195 a.replaceChar('o', 'e');
196 REPORTER_ASSERT(reporter, a.equals("helle werld"));
197 a.replaceChar('x', 'e');
198 REPORTER_ASSERT(reporter, a.equals("helle werld"));
199 a.replaceChar('x', 'z');
200 REPORTER_ASSERT(reporter, a.equals("helle werld"));
201 a.set("");
202 a.replaceChar('a', 'b');
203 REPORTER_ASSERT(reporter, a.equals(""));
204 }
205
189 DEF_TEST(String_SkStrSplit, r) { 206 DEF_TEST(String_SkStrSplit, r) {
190 SkTArray<SkString> results; 207 SkTArray<SkString> results;
191 208
192 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results); 209 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results);
193 REPORTER_ASSERT(r, results.count() == 6); 210 REPORTER_ASSERT(r, results.count() == 6);
194 REPORTER_ASSERT(r, results[0].equals("a")); 211 REPORTER_ASSERT(r, results[0].equals("a"));
195 REPORTER_ASSERT(r, results[1].equals("b")); 212 REPORTER_ASSERT(r, results[1].equals("b"));
196 REPORTER_ASSERT(r, results[2].equals("c")); 213 REPORTER_ASSERT(r, results[2].equals("c"));
197 REPORTER_ASSERT(r, results[3].equals("dee")); 214 REPORTER_ASSERT(r, results[3].equals("dee"));
198 REPORTER_ASSERT(r, results[4].equals("f")); 215 REPORTER_ASSERT(r, results[4].equals("f"));
199 REPORTER_ASSERT(r, results[5].equals("g")); 216 REPORTER_ASSERT(r, results[5].equals("g"));
200 } 217 }
OLDNEW
« include/core/SkString.h ('K') | « src/core/SkString.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698