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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 REPORTER_ASSERT(reporter, reader.readInt() == 0x33); | 95 REPORTER_ASSERT(reporter, reader.readInt() == 0x33); |
96 REPORTER_ASSERT(reporter, reader.readPtr() == p1); | 96 REPORTER_ASSERT(reporter, reader.readPtr() == p1); |
97 REPORTER_ASSERT(reporter, reader.readInt() == 0x66); | 97 REPORTER_ASSERT(reporter, reader.readInt() == 0x66); |
98 } | 98 } |
99 | 99 |
100 static void test1(skiatest::Reporter* reporter, SkWriter32* writer) { | 100 static void test1(skiatest::Reporter* reporter, SkWriter32* writer) { |
101 const uint32_t data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | 101 const uint32_t data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; |
102 for (size_t i = 0; i < SK_ARRAY_COUNT(data); ++i) { | 102 for (size_t i = 0; i < SK_ARRAY_COUNT(data); ++i) { |
103 REPORTER_ASSERT(reporter, i*4 == writer->bytesWritten()); | 103 REPORTER_ASSERT(reporter, i*4 == writer->bytesWritten()); |
104 writer->write32(data[i]); | 104 writer->write32(data[i]); |
105 uint32_t* addr = writer->peek32(i * 4); | 105 REPORTER_ASSERT(reporter, data[i] == writer->read32At(i*4)); |
106 REPORTER_ASSERT(reporter, data[i] == *addr); | |
107 } | 106 } |
108 | 107 |
109 char buffer[sizeof(data)]; | 108 char buffer[sizeof(data)]; |
110 REPORTER_ASSERT(reporter, sizeof(buffer) == writer->bytesWritten()); | 109 REPORTER_ASSERT(reporter, sizeof(buffer) == writer->bytesWritten()); |
111 writer->flatten(buffer); | 110 writer->flatten(buffer); |
112 REPORTER_ASSERT(reporter, !memcmp(data, buffer, sizeof(buffer))); | 111 REPORTER_ASSERT(reporter, !memcmp(data, buffer, sizeof(buffer))); |
113 } | 112 } |
114 | 113 |
115 static void test2(skiatest::Reporter* reporter, SkWriter32* writer) { | 114 static void test2(skiatest::Reporter* reporter, SkWriter32* writer) { |
116 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz"; | 115 static const char gStr[] = "abcdefghimjklmnopqrstuvwxyz"; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 writer.reset(); | 235 writer.reset(); |
237 testWritePad(reporter, &writer); | 236 testWritePad(reporter, &writer); |
238 } | 237 } |
239 | 238 |
240 DEF_TEST(Writer32_misc, reporter) { | 239 DEF_TEST(Writer32_misc, reporter) { |
241 test_reserve(reporter); | 240 test_reserve(reporter); |
242 test_string_null(reporter); | 241 test_string_null(reporter); |
243 test_ptr(reporter); | 242 test_ptr(reporter); |
244 test_rewind(reporter); | 243 test_rewind(reporter); |
245 } | 244 } |
OLD | NEW |