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 "SkRandom.h" | 8 #include "SkRandom.h" |
9 #include "SkReader32.h" | 9 #include "SkReader32.h" |
10 #include "SkWriter32.h" | 10 #include "SkWriter32.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // fit in external storage if you used it. This would crash in debug mode. | 24 // fit in external storage if you used it. This would crash in debug mode. |
25 uint8_t storage[4]; | 25 uint8_t storage[4]; |
26 SkWriter32 writer(storage, sizeof(storage)); | 26 SkWriter32 writer(storage, sizeof(storage)); |
27 writer.reserve(40); | 27 writer.reserve(40); |
28 } | 28 } |
29 | 29 |
30 static void test_string_null(skiatest::Reporter* reporter) { | 30 static void test_string_null(skiatest::Reporter* reporter) { |
31 uint8_t storage[8]; | 31 uint8_t storage[8]; |
32 SkWriter32 writer(storage, sizeof(storage)); | 32 SkWriter32 writer(storage, sizeof(storage)); |
33 | 33 |
34 // Can we write NULL? | 34 // Can we write nullptr? |
35 writer.writeString(NULL); | 35 writer.writeString(nullptr); |
36 const int32_t expected[] = { 0x0, 0x0 }; | 36 const int32_t expected[] = { 0x0, 0x0 }; |
37 check_contents(reporter, writer, expected, sizeof(expected)); | 37 check_contents(reporter, writer, expected, sizeof(expected)); |
38 } | 38 } |
39 | 39 |
40 static void test_rewind(skiatest::Reporter* reporter) { | 40 static void test_rewind(skiatest::Reporter* reporter) { |
41 SkSWriter32<32> writer; | 41 SkSWriter32<32> writer; |
42 int32_t array[3] = { 1, 2, 4 }; | 42 int32_t array[3] = { 1, 2, 4 }; |
43 | 43 |
44 REPORTER_ASSERT(reporter, 0 == writer.bytesWritten()); | 44 REPORTER_ASSERT(reporter, 0 == writer.bytesWritten()); |
45 for (size_t i = 0; i < SK_ARRAY_COUNT(array); ++i) { | 45 for (size_t i = 0; i < SK_ARRAY_COUNT(array); ++i) { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 writer.reset(); | 234 writer.reset(); |
235 testOverwriteT(reporter, &writer); | 235 testOverwriteT(reporter, &writer); |
236 } | 236 } |
237 | 237 |
238 DEF_TEST(Writer32_contiguous, reporter) { | 238 DEF_TEST(Writer32_contiguous, reporter) { |
239 uint32_t storage[256]; | 239 uint32_t storage[256]; |
240 SkWriter32 writer; | 240 SkWriter32 writer; |
241 writer.reset(storage, sizeof(storage)); | 241 writer.reset(storage, sizeof(storage)); |
242 // This write is small enough to fit in storage, so it's contiguous. | 242 // This write is small enough to fit in storage, so it's contiguous. |
243 test1(reporter, &writer); | 243 test1(reporter, &writer); |
244 REPORTER_ASSERT(reporter, writer.contiguousArray() != NULL); | 244 REPORTER_ASSERT(reporter, writer.contiguousArray() != nullptr); |
245 | 245 |
246 // Everything other aspect of contiguous/non-contiguous is an | 246 // Everything other aspect of contiguous/non-contiguous is an |
247 // implementation detail, not part of the public contract for | 247 // implementation detail, not part of the public contract for |
248 // SkWriter32, and so not tested here. | 248 // SkWriter32, and so not tested here. |
249 } | 249 } |
250 | 250 |
251 DEF_TEST(Writer32_small, reporter) { | 251 DEF_TEST(Writer32_small, reporter) { |
252 SkSWriter32<8 * sizeof(intptr_t)> writer; | 252 SkSWriter32<8 * sizeof(intptr_t)> writer; |
253 test1(reporter, &writer); | 253 test1(reporter, &writer); |
254 writer.reset(); // should just rewind our storage | 254 writer.reset(); // should just rewind our storage |
(...skipping 19 matching lines...) Expand all Loading... |
274 testOverwriteT(reporter, &writer); | 274 testOverwriteT(reporter, &writer); |
275 } | 275 } |
276 | 276 |
277 DEF_TEST(Writer32_misc, reporter) { | 277 DEF_TEST(Writer32_misc, reporter) { |
278 test_reserve(reporter); | 278 test_reserve(reporter); |
279 test_string_null(reporter); | 279 test_string_null(reporter); |
280 test_ptr(reporter); | 280 test_ptr(reporter); |
281 test_rewind(reporter); | 281 test_rewind(reporter); |
282 } | 282 } |
283 | 283 |
OLD | NEW |