OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
| 7 |
8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
9 #include "SkRandom.h" | 10 #include "SkRandom.h" |
10 #include "SkRefCnt.h" | 11 #include "SkRefCnt.h" |
11 #include "SkTSearch.h" | 12 #include "SkTSearch.h" |
12 #include "SkTSort.h" | 13 #include "SkTSort.h" |
13 #include "SkUtils.h" | 14 #include "SkUtils.h" |
14 | 15 |
15 class RefClass : public SkRefCnt { | 16 class RefClass : public SkRefCnt { |
16 public: | 17 public: |
17 SK_DECLARE_INST_COUNT(RefClass) | 18 SK_DECLARE_INST_COUNT(RefClass) |
18 | 19 |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 REPORTER_ASSERT(reporter, count == 2); | 177 REPORTER_ASSERT(reporter, count == 2); |
177 size_t count2 = SkUTF16_CountUnichars(buf, 2); | 178 size_t count2 = SkUTF16_CountUnichars(buf, 2); |
178 REPORTER_ASSERT(reporter, count2 == 1); | 179 REPORTER_ASSERT(reporter, count2 == 1); |
179 const uint16_t* ptr = buf; | 180 const uint16_t* ptr = buf; |
180 SkUnichar c = SkUTF16_NextUnichar(&ptr); | 181 SkUnichar c = SkUTF16_NextUnichar(&ptr); |
181 REPORTER_ASSERT(reporter, c == gUni[i]); | 182 REPORTER_ASSERT(reporter, c == gUni[i]); |
182 REPORTER_ASSERT(reporter, ptr - buf == 2); | 183 REPORTER_ASSERT(reporter, ptr - buf == 2); |
183 } | 184 } |
184 } | 185 } |
185 | 186 |
186 static void TestUTF(skiatest::Reporter* reporter) { | 187 DEF_TEST(Utils, reporter) { |
187 static const struct { | 188 static const struct { |
188 const char* fUtf8; | 189 const char* fUtf8; |
189 SkUnichar fUni; | 190 SkUnichar fUni; |
190 } gTest[] = { | 191 } gTest[] = { |
191 { "a", 'a' }, | 192 { "a", 'a' }, |
192 { "\x7f", 0x7f }, | 193 { "\x7f", 0x7f }, |
193 { "\xC2\x80", 0x80 }, | 194 { "\xC2\x80", 0x80 }, |
194 { "\xC3\x83", (3 << 6) | 3 }, | 195 { "\xC3\x83", (3 << 6) | 3 }, |
195 { "\xDF\xBF", 0x7ff }, | 196 { "\xDF\xBF", 0x7ff }, |
196 { "\xE0\xA0\x80", 0x800 }, | 197 { "\xE0\xA0\x80", 0x800 }, |
(...skipping 15 matching lines...) Expand all Loading... |
212 REPORTER_ASSERT(reporter, u0 == gTest[i].fUni); | 213 REPORTER_ASSERT(reporter, u0 == gTest[i].fUni); |
213 REPORTER_ASSERT(reporter, | 214 REPORTER_ASSERT(reporter, |
214 p - gTest[i].fUtf8 == (int)strlen(gTest[i].fUtf8)); | 215 p - gTest[i].fUtf8 == (int)strlen(gTest[i].fUtf8)); |
215 } | 216 } |
216 | 217 |
217 test_utf16(reporter); | 218 test_utf16(reporter); |
218 test_search(reporter); | 219 test_search(reporter); |
219 test_autounref(reporter); | 220 test_autounref(reporter); |
220 test_autostarray(reporter); | 221 test_autostarray(reporter); |
221 } | 222 } |
222 | |
223 #include "TestClassDef.h" | |
224 DEFINE_TESTCLASS("Utils", UtfTestClass, TestUTF) | |
OLD | NEW |