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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 REPORTER_ASSERT(reporter, a.equals("000000016777216")); | 149 REPORTER_ASSERT(reporter, a.equals("000000016777216")); |
150 | 150 |
151 static const struct { | 151 static const struct { |
152 SkScalar fValue; | 152 SkScalar fValue; |
153 const char* fString; | 153 const char* fString; |
154 } gRec[] = { | 154 } gRec[] = { |
155 { 0, "0" }, | 155 { 0, "0" }, |
156 { SK_Scalar1, "1" }, | 156 { SK_Scalar1, "1" }, |
157 { -SK_Scalar1, "-1" }, | 157 { -SK_Scalar1, "-1" }, |
158 { SK_Scalar1/2, "0.5" }, | 158 { SK_Scalar1/2, "0.5" }, |
159 #ifdef SK_BUILD_FOR_WIN | 159 #if defined(SK_BUILD_FOR_WIN) && (_MSC_VER < 1900) |
160 { 3.4028234e38f, "3.4028235e+038" }, | 160 { 3.4028234e38f, "3.4028235e+038" }, |
161 { -3.4028234e38f, "-3.4028235e+038" }, | 161 { -3.4028234e38f, "-3.4028235e+038" }, |
162 #else | 162 #else |
163 { 3.4028234e38f, "3.4028235e+38" }, | 163 { 3.4028234e38f, "3.4028235e+38" }, |
164 { -3.4028234e38f, "-3.4028235e+38" }, | 164 { -3.4028234e38f, "-3.4028235e+38" }, |
165 #endif | 165 #endif |
166 }; | 166 }; |
167 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { | 167 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
168 a.reset(); | 168 a.reset(); |
169 a.appendScalar(gRec[i].fValue); | 169 a.appendScalar(gRec[i].fValue); |
170 REPORTER_ASSERT(reporter, a.size() <= SkStrAppendScalar_MaxSize); | 170 REPORTER_ASSERT(reporter, a.size() <= SkStrAppendScalar_MaxSize); |
171 // SkDebugf(" received <%s> expected <%s>\n", a.c_str(), gRec[i].fString)
; | 171 if (!a.equals(gRec[i].fString)) { |
172 REPORTER_ASSERT(reporter, a.equals(gRec[i].fString)); | 172 ERRORF(reporter, "received <%s> expected <%s>\n", a.c_str(), gRec[i]
.fString); |
| 173 } |
173 } | 174 } |
174 | 175 |
175 REPORTER_ASSERT(reporter, SkStringPrintf("%i", 0).equals("0")); | 176 REPORTER_ASSERT(reporter, SkStringPrintf("%i", 0).equals("0")); |
176 | 177 |
177 char buffer [40]; | 178 char buffer [40]; |
178 memset(buffer, 'a', 40); | 179 memset(buffer, 'a', 40); |
179 REPORTER_ASSERT(reporter, buffer[18] == 'a'); | 180 REPORTER_ASSERT(reporter, buffer[18] == 'a'); |
180 REPORTER_ASSERT(reporter, buffer[19] == 'a'); | 181 REPORTER_ASSERT(reporter, buffer[19] == 'a'); |
181 REPORTER_ASSERT(reporter, buffer[20] == 'a'); | 182 REPORTER_ASSERT(reporter, buffer[20] == 'a'); |
182 printfAnalog(buffer, 20, "%30d", 0); | 183 printfAnalog(buffer, 20, "%30d", 0); |
183 REPORTER_ASSERT(reporter, buffer[18] == ' '); | 184 REPORTER_ASSERT(reporter, buffer[18] == ' '); |
184 REPORTER_ASSERT(reporter, buffer[19] == 0); | 185 REPORTER_ASSERT(reporter, buffer[19] == 0); |
185 REPORTER_ASSERT(reporter, buffer[20] == 'a'); | 186 REPORTER_ASSERT(reporter, buffer[20] == 'a'); |
186 | 187 |
187 } | 188 } |
188 | 189 |
189 DEF_TEST(String_SkStrSplit, r) { | 190 DEF_TEST(String_SkStrSplit, r) { |
190 SkTArray<SkString> results; | 191 SkTArray<SkString> results; |
191 | 192 |
192 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results); | 193 SkStrSplit("a-_b_c-dee--f-_-_-g-", "-_", &results); |
193 REPORTER_ASSERT(r, results.count() == 6); | 194 REPORTER_ASSERT(r, results.count() == 6); |
194 REPORTER_ASSERT(r, results[0].equals("a")); | 195 REPORTER_ASSERT(r, results[0].equals("a")); |
195 REPORTER_ASSERT(r, results[1].equals("b")); | 196 REPORTER_ASSERT(r, results[1].equals("b")); |
196 REPORTER_ASSERT(r, results[2].equals("c")); | 197 REPORTER_ASSERT(r, results[2].equals("c")); |
197 REPORTER_ASSERT(r, results[3].equals("dee")); | 198 REPORTER_ASSERT(r, results[3].equals("dee")); |
198 REPORTER_ASSERT(r, results[4].equals("f")); | 199 REPORTER_ASSERT(r, results[4].equals("f")); |
199 REPORTER_ASSERT(r, results[5].equals("g")); | 200 REPORTER_ASSERT(r, results[5].equals("g")); |
200 } | 201 } |
OLD | NEW |