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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 } | 196 } |
197 | 197 |
198 DEF_TEST(Writer32_contiguous, reporter) { | 198 DEF_TEST(Writer32_contiguous, reporter) { |
199 uint32_t storage[256]; | 199 uint32_t storage[256]; |
200 SkWriter32 writer; | 200 SkWriter32 writer; |
201 writer.reset(storage, sizeof(storage)); | 201 writer.reset(storage, sizeof(storage)); |
202 // This write is small enough to fit in storage, so it's contiguous. | 202 // This write is small enough to fit in storage, so it's contiguous. |
203 test1(reporter, &writer); | 203 test1(reporter, &writer); |
204 REPORTER_ASSERT(reporter, writer.contiguousArray() != NULL); | 204 REPORTER_ASSERT(reporter, writer.contiguousArray() != NULL); |
205 | 205 |
206 // This write is too big for the 32 byte storage block we provide. | 206 // Everything other aspect of contiguous/non-contiguous is an |
207 writer.reset(storage, 32); | 207 // implementation detail, not part of the public contract for |
208 test2(reporter, &writer); | 208 // SkWriter32, and so not tested here. |
209 // Some data is in storage, some in writer's internal storage. | |
210 REPORTER_ASSERT(reporter, writer.contiguousArray() == NULL); | |
211 | |
212 writer.reset(); | |
213 test2(reporter, &writer); | |
214 // There is no external storage. All the data is in internal storage, | |
215 // so we can always read it contiguously. | |
216 REPORTER_ASSERT(reporter, writer.contiguousArray() != NULL); | |
217 } | 209 } |
218 | 210 |
219 DEF_TEST(Writer32_small, reporter) { | 211 DEF_TEST(Writer32_small, reporter) { |
220 SkSWriter32<8 * sizeof(intptr_t)> writer; | 212 SkSWriter32<8 * sizeof(intptr_t)> writer; |
221 test1(reporter, &writer); | 213 test1(reporter, &writer); |
222 writer.reset(); // should just rewind our storage | 214 writer.reset(); // should just rewind our storage |
223 test2(reporter, &writer); | 215 test2(reporter, &writer); |
224 | 216 |
225 writer.reset(); | 217 writer.reset(); |
226 testWritePad(reporter, &writer); | 218 testWritePad(reporter, &writer); |
227 } | 219 } |
228 | 220 |
229 DEF_TEST(Writer32_large, reporter) { | 221 DEF_TEST(Writer32_large, reporter) { |
230 SkSWriter32<1024 * sizeof(intptr_t)> writer; | 222 SkSWriter32<1024 * sizeof(intptr_t)> writer; |
231 test1(reporter, &writer); | 223 test1(reporter, &writer); |
232 writer.reset(); // should just rewind our storage | 224 writer.reset(); // should just rewind our storage |
233 test2(reporter, &writer); | 225 test2(reporter, &writer); |
234 | 226 |
235 writer.reset(); | 227 writer.reset(); |
236 testWritePad(reporter, &writer); | 228 testWritePad(reporter, &writer); |
237 } | 229 } |
238 | 230 |
239 DEF_TEST(Writer32_misc, reporter) { | 231 DEF_TEST(Writer32_misc, reporter) { |
240 test_reserve(reporter); | 232 test_reserve(reporter); |
241 test_string_null(reporter); | 233 test_string_null(reporter); |
242 test_ptr(reporter); | 234 test_ptr(reporter); |
243 test_rewind(reporter); | 235 test_rewind(reporter); |
244 } | 236 } |
OLD | NEW |