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 "SkData.h" | 8 #include "SkData.h" |
9 #include "SkDataTable.h" | 9 #include "SkDataTable.h" |
10 #include "SkOSFile.h" | 10 #include "SkOSFile.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 REPORTER_ASSERT(reporter, stream->read(array, 26) == 26); | 264 REPORTER_ASSERT(reporter, stream->read(array, 26) == 26); |
265 check_abcs(reporter, array, 26); | 265 check_abcs(reporter, array, 26); |
266 REPORTER_ASSERT(reporter, stream->getPosition() == offset); | 266 REPORTER_ASSERT(reporter, stream->getPosition() == offset); |
267 } | 267 } |
268 } | 268 } |
269 | 269 |
270 // reader should contains an integral number of copies of gABC. | 270 // reader should contains an integral number of copies of gABC. |
271 static void check_alphabet_buffer(skiatest::Reporter* reporter, const SkROBuffer
* reader) { | 271 static void check_alphabet_buffer(skiatest::Reporter* reporter, const SkROBuffer
* reader) { |
272 size_t size = reader->size(); | 272 size_t size = reader->size(); |
273 REPORTER_ASSERT(reporter, size % 26 == 0); | 273 REPORTER_ASSERT(reporter, size % 26 == 0); |
274 | 274 |
275 SkAutoTMalloc<char> storage(size); | 275 SkAutoTMalloc<char> storage(size); |
276 SkROBuffer::Iter iter(reader); | 276 SkROBuffer::Iter iter(reader); |
277 size_t offset = 0; | 277 size_t offset = 0; |
278 do { | 278 do { |
279 SkASSERT(offset + iter.size() <= size); | 279 SkASSERT(offset + iter.size() <= size); |
280 memcpy(storage.get() + offset, iter.data(), iter.size()); | 280 memcpy(storage.get() + offset, iter.data(), iter.size()); |
281 offset += iter.size(); | 281 offset += iter.size(); |
282 } while (iter.next()); | 282 } while (iter.next()); |
283 REPORTER_ASSERT(reporter, offset == size); | 283 REPORTER_ASSERT(reporter, offset == size); |
284 check_abcs(reporter, storage.get(), size); | 284 check_abcs(reporter, storage.get(), size); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 REPORTER_ASSERT(r, !iter.next()); | 328 REPORTER_ASSERT(r, !iter.next()); |
329 REPORTER_ASSERT(r, 0 == iter.size()); | 329 REPORTER_ASSERT(r, 0 == iter.size()); |
330 } | 330 } |
331 | 331 |
332 // Tests that it is safe to destruct an SkRWBuffer without appending | 332 // Tests that it is safe to destruct an SkRWBuffer without appending |
333 // anything to it. | 333 // anything to it. |
334 DEF_TEST(RWBuffer_noAppend, r) { | 334 DEF_TEST(RWBuffer_noAppend, r) { |
335 SkRWBuffer buffer; | 335 SkRWBuffer buffer; |
336 REPORTER_ASSERT(r, 0 == buffer.size()); | 336 REPORTER_ASSERT(r, 0 == buffer.size()); |
337 } | 337 } |
OLD | NEW |