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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 writer.reset(); | 225 writer.reset(); |
226 test2(reporter, &writer); | 226 test2(reporter, &writer); |
227 | 227 |
228 writer.reset(); | 228 writer.reset(); |
229 testWritePad(reporter, &writer); | 229 testWritePad(reporter, &writer); |
230 | 230 |
231 writer.reset(); | 231 writer.reset(); |
232 testOverwriteT(reporter, &writer); | 232 testOverwriteT(reporter, &writer); |
233 } | 233 } |
234 | 234 |
235 DEF_TEST(Writer32_contiguous, reporter) { | |
236 uint32_t storage[256]; | |
237 SkWriter32 writer; | |
238 writer.reset(storage, sizeof(storage)); | |
239 // This write is small enough to fit in storage, so it's contiguous. | |
240 test1(reporter, &writer); | |
241 REPORTER_ASSERT(reporter, writer.contiguousArray() != nullptr); | |
242 | |
243 // Everything other aspect of contiguous/non-contiguous is an | |
244 // implementation detail, not part of the public contract for | |
245 // SkWriter32, and so not tested here. | |
246 } | |
247 | |
248 DEF_TEST(Writer32_small, reporter) { | 235 DEF_TEST(Writer32_small, reporter) { |
249 SkSWriter32<8 * sizeof(intptr_t)> writer; | 236 SkSWriter32<8 * sizeof(intptr_t)> writer; |
250 test1(reporter, &writer); | 237 test1(reporter, &writer); |
251 writer.reset(); // should just rewind our storage | 238 writer.reset(); // should just rewind our storage |
252 test2(reporter, &writer); | 239 test2(reporter, &writer); |
253 | 240 |
254 writer.reset(); | 241 writer.reset(); |
255 testWritePad(reporter, &writer); | 242 testWritePad(reporter, &writer); |
256 | 243 |
257 writer.reset(); | 244 writer.reset(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 d2(reader.readData()); | 299 d2(reader.readData()); |
313 | 300 |
314 REPORTER_ASSERT(reporter, 0 == d0->size()); | 301 REPORTER_ASSERT(reporter, 0 == d0->size()); |
315 REPORTER_ASSERT(reporter, strlen(str)+1 == d1->size()); | 302 REPORTER_ASSERT(reporter, strlen(str)+1 == d1->size()); |
316 REPORTER_ASSERT(reporter, !memcmp(str, d1->data(), strlen(str)+1)); | 303 REPORTER_ASSERT(reporter, !memcmp(str, d1->data(), strlen(str)+1)); |
317 REPORTER_ASSERT(reporter, 0 == d2->size()); | 304 REPORTER_ASSERT(reporter, 0 == d2->size()); |
318 | 305 |
319 REPORTER_ASSERT(reporter, reader.offset() == sizeWritten); | 306 REPORTER_ASSERT(reporter, reader.offset() == sizeWritten); |
320 REPORTER_ASSERT(reporter, reader.eof()); | 307 REPORTER_ASSERT(reporter, reader.eof()); |
321 } | 308 } |
OLD | NEW |