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

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: add another test with some weird characters Created 6 years, 2 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
« no previous file with comments | « src/core/SkString.cpp ('k') | tools/PictureRenderer.cpp » ('j') | 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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 SkString skia_2d("skia_2d");
188 SkString skia2d("skia-2d");
189 skia_2d.replace('_', '-');
190 REPORTER_ASSERT(reporter, skia_2d == skia2d);
191
192 SkString meat("meat");
193 SkString meet("meet");
194 meat.replace('a', 'e');
195 REPORTER_ASSERT(reporter, meat == meet);
196
197 SkString hangul("\xed\x95\x9c\xea\xb5\xad\xec\x96\xb4");
tfarina 2014/10/18 03:42:27 Mike, could you take another look? Let me know if
198 SkString hangul2("\xb4\x95\x9c\xea\xb5\xad\xec\x96\xb4");
199 hangul.replace('\xed', '\xb4');
200 REPORTER_ASSERT(reporter, hangul == hangul2);
187 } 201 }
188 202
189 DEF_TEST(String_SkStrSplit, r) { 203 DEF_TEST(String_SkStrSplit, r) {
190 SkTArray<SkString> results; 204 SkTArray<SkString> results;
191 205
192 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results); 206 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results);
193 REPORTER_ASSERT(r, results.count() == 6); 207 REPORTER_ASSERT(r, results.count() == 6);
194 REPORTER_ASSERT(r, results[0].equals("a")); 208 REPORTER_ASSERT(r, results[0].equals("a"));
195 REPORTER_ASSERT(r, results[1].equals("b")); 209 REPORTER_ASSERT(r, results[1].equals("b"));
196 REPORTER_ASSERT(r, results[2].equals("c")); 210 REPORTER_ASSERT(r, results[2].equals("c"));
197 REPORTER_ASSERT(r, results[3].equals("dee")); 211 REPORTER_ASSERT(r, results[3].equals("dee"));
198 REPORTER_ASSERT(r, results[4].equals("f")); 212 REPORTER_ASSERT(r, results[4].equals("f"));
199 REPORTER_ASSERT(r, results[5].equals("g")); 213 REPORTER_ASSERT(r, results[5].equals("g"));
200 } 214 }
OLDNEW
« no previous file with comments | « src/core/SkString.cpp ('k') | tools/PictureRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698