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

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: Faster replacement + added unit tests 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 a.set(""); 141 a.set("");
142 a.appendU64(0x8000000000000001ULL, 0); 142 a.appendU64(0x8000000000000001ULL, 0);
143 REPORTER_ASSERT(reporter, a.equals("9223372036854775809")); 143 REPORTER_ASSERT(reporter, a.equals("9223372036854775809"));
144 a.set(""); 144 a.set("");
145 a.appendU64(0xFFFFFFFFFFFFFFFFULL, 0); 145 a.appendU64(0xFFFFFFFFFFFFFFFFULL, 0);
146 REPORTER_ASSERT(reporter, a.equals("18446744073709551615")); 146 REPORTER_ASSERT(reporter, a.equals("18446744073709551615"));
147 a.set(""); 147 a.set("");
148 a.appendU64(0x0000000001000000ULL, 15); 148 a.appendU64(0x0000000001000000ULL, 15);
149 REPORTER_ASSERT(reporter, a.equals("000000016777216")); 149 REPORTER_ASSERT(reporter, a.equals("000000016777216"));
150 150
151 a.set("hello world");
tfarina 2014/06/13 17:02:10 If Elliot and Mike don't mind, could you set up a
152 a.replaceChar('h', 'h');
153 REPORTER_ASSERT(reporter, a.equals("hello world"));
154 a.replaceChar('x', 'x');
155 REPORTER_ASSERT(reporter, a.equals("hello world"));
156 a.replaceChar('o', 'e');
157 REPORTER_ASSERT(reporter, a.equals("helle werld"));
158 a.replaceChar('x', 'e');
159 REPORTER_ASSERT(reporter, a.equals("helle werld"));
160 a.replaceChar('x', 'z');
161 REPORTER_ASSERT(reporter, a.equals("helle werld"));
162 a.set("");
163 a.replaceChar('a', 'b');
164 REPORTER_ASSERT(reporter, a.equals(""));
165
151 static const struct { 166 static const struct {
152 SkScalar fValue; 167 SkScalar fValue;
153 const char* fString; 168 const char* fString;
154 } gRec[] = { 169 } gRec[] = {
155 { 0, "0" }, 170 { 0, "0" },
156 { SK_Scalar1, "1" }, 171 { SK_Scalar1, "1" },
157 { -SK_Scalar1, "-1" }, 172 { -SK_Scalar1, "-1" },
158 { SK_Scalar1/2, "0.5" }, 173 { SK_Scalar1/2, "0.5" },
159 #ifdef SK_BUILD_FOR_WIN 174 #ifdef SK_BUILD_FOR_WIN
160 { 3.4028234e38f, "3.4028235e+038" }, 175 { 3.4028234e38f, "3.4028235e+038" },
(...skipping 30 matching lines...) Expand all
191 206
192 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results); 207 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results);
193 REPORTER_ASSERT(r, results.count() == 6); 208 REPORTER_ASSERT(r, results.count() == 6);
194 REPORTER_ASSERT(r, results[0].equals("a")); 209 REPORTER_ASSERT(r, results[0].equals("a"));
195 REPORTER_ASSERT(r, results[1].equals("b")); 210 REPORTER_ASSERT(r, results[1].equals("b"));
196 REPORTER_ASSERT(r, results[2].equals("c")); 211 REPORTER_ASSERT(r, results[2].equals("c"));
197 REPORTER_ASSERT(r, results[3].equals("dee")); 212 REPORTER_ASSERT(r, results[3].equals("dee"));
198 REPORTER_ASSERT(r, results[4].equals("f")); 213 REPORTER_ASSERT(r, results[4].equals("f"));
199 REPORTER_ASSERT(r, results[5].equals("g")); 214 REPORTER_ASSERT(r, results[5].equals("g"));
200 } 215 }
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