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

Side by Side 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 unified diff | Download patch
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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 char buffer [40]; 177 char buffer [40];
178 memset(buffer, 'a', 40); 178 memset(buffer, 'a', 40);
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
188 DEF_TEST(String_Replace, r) {
189 SkString str("skia_2d");
190 str.replace('_', '-');
191 REPORTER_ASSERT(r, str.equals("skia-2d"));
192
193 str.set("meat");
194 str.replace('a', 'e');
195 REPORTER_ASSERT(r, str.equals("meet"));
196
197 str.set("hello, world!");
198 str.replace('h', 'h');
199 REPORTER_ASSERT(r, str.equals("hello, world!"));
200 str.replace('x', 'x');
201 REPORTER_ASSERT(r, str.equals("hello, world!"));
202 str.replace('o', 'u');
203 REPORTER_ASSERT(r, str.equals("hellu, wurld!"));
204 str.replace('x', 'u');
205 REPORTER_ASSERT(r, str.equals("hellu, wurld!"));
206 str.replace('x', 'y');
207 REPORTER_ASSERT(r, str.equals("hellu, wurld!"));
208
209 str.set("");
210 str.replace('a', 'b');
211 REPORTER_ASSERT(r, str.equals(""));
212
213 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
214 //SkString hangul2("\xb4\x95\x9c\xea\xb5\xad\xec\x96\xb4");
215 str.replace('\xed', '\xb4');
216 //REPORTER_ASSERT(r, hangul == hangul2);
187 } 217 }
188 218
189 DEF_TEST(String_SkStrSplit, r) { 219 DEF_TEST(String_SkStrSplit, r) {
190 SkTArray<SkString> results; 220 SkTArray<SkString> results;
191 221
192 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results); 222 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results);
193 REPORTER_ASSERT(r, results.count() == 6); 223 REPORTER_ASSERT(r, results.count() == 6);
194 REPORTER_ASSERT(r, results[0].equals("a")); 224 REPORTER_ASSERT(r, results[0].equals("a"));
195 REPORTER_ASSERT(r, results[1].equals("b")); 225 REPORTER_ASSERT(r, results[1].equals("b"));
196 REPORTER_ASSERT(r, results[2].equals("c")); 226 REPORTER_ASSERT(r, results[2].equals("c"));
197 REPORTER_ASSERT(r, results[3].equals("dee")); 227 REPORTER_ASSERT(r, results[3].equals("dee"));
198 REPORTER_ASSERT(r, results[4].equals("f")); 228 REPORTER_ASSERT(r, results[4].equals("f"));
199 REPORTER_ASSERT(r, results[5].equals("g")); 229 REPORTER_ASSERT(r, results[5].equals("g"));
200 } 230 }
OLDNEW
« 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