OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkFlate.h" | 8 #include "SkFlate.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "Test.h" | 10 #include "Test.h" |
11 | 11 |
| 12 #if SK_SUPPORT_PDF |
| 13 |
12 DEF_TEST(SkDeflateWStream, r) { | 14 DEF_TEST(SkDeflateWStream, r) { |
13 SkRandom random(123456); | 15 SkRandom random(123456); |
14 for (int i = 0; i < 50; ++i) { | 16 for (int i = 0; i < 50; ++i) { |
15 uint32_t size = random.nextULessThan(10000); | 17 uint32_t size = random.nextULessThan(10000); |
16 SkAutoTMalloc<uint8_t> buffer(size); | 18 SkAutoTMalloc<uint8_t> buffer(size); |
17 for (uint32_t j = 0; j < size; ++j) { | 19 for (uint32_t j = 0; j < size; ++j) { |
18 buffer[j] = random.nextU() & 0xff; | 20 buffer[j] = random.nextU() & 0xff; |
19 } | 21 } |
20 | 22 |
21 SkDynamicMemoryWStream dynamicMemoryWStream; | 23 SkDynamicMemoryWStream dynamicMemoryWStream; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 uint8_t c; | 65 uint8_t c; |
64 SkDEBUGCODE(size_t rb =)decompressed->read(&c, sizeof(uint8_t)); | 66 SkDEBUGCODE(size_t rb =)decompressed->read(&c, sizeof(uint8_t)); |
65 SkASSERT(sizeof(uint8_t) == rb); | 67 SkASSERT(sizeof(uint8_t) == rb); |
66 if (buffer[i] != c) { | 68 if (buffer[i] != c) { |
67 ERRORF(r, "Decompression failed at byte %u.", (unsigned)i); | 69 ERRORF(r, "Decompression failed at byte %u.", (unsigned)i); |
68 break; | 70 break; |
69 } | 71 } |
70 } | 72 } |
71 } | 73 } |
72 } | 74 } |
| 75 #endif // SK_SUPPORT_PDF |
OLD | NEW |