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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 DEF_TEST(RWBuffer, reporter) { | 287 DEF_TEST(RWBuffer, reporter) { |
288 // Knowing that the default capacity is 4096, choose N large enough so we fo
rce it to use | 288 // Knowing that the default capacity is 4096, choose N large enough so we fo
rce it to use |
289 // multiple buffers internally. | 289 // multiple buffers internally. |
290 const int N = 1000; | 290 const int N = 1000; |
291 SkROBuffer* readers[N]; | 291 SkROBuffer* readers[N]; |
292 SkStream* streams[N]; | 292 SkStream* streams[N]; |
293 | 293 |
294 { | 294 { |
295 SkRWBuffer buffer; | 295 SkRWBuffer buffer; |
296 for (int i = 0; i < N; ++i) { | 296 for (int i = 0; i < N; ++i) { |
297 if (0 == (i & 1)) { | 297 buffer.append(gABC, 26); |
298 buffer.append(gABC, 26); | |
299 } else { | |
300 memcpy(buffer.append(26), gABC, 26); | |
301 } | |
302 readers[i] = buffer.newRBufferSnapshot(); | 298 readers[i] = buffer.newRBufferSnapshot(); |
303 streams[i] = buffer.newStreamSnapshot(); | 299 streams[i] = buffer.newStreamSnapshot(); |
304 } | 300 } |
305 REPORTER_ASSERT(reporter, N*26 == buffer.size()); | 301 REPORTER_ASSERT(reporter, N*26 == buffer.size()); |
306 } | 302 } |
307 | 303 |
308 for (int i = 0; i < N; ++i) { | 304 for (int i = 0; i < N; ++i) { |
309 REPORTER_ASSERT(reporter, (i + 1) * 26U == readers[i]->size()); | 305 REPORTER_ASSERT(reporter, (i + 1) * 26U == readers[i]->size()); |
310 check_alphabet_buffer(reporter, readers[i]); | 306 check_alphabet_buffer(reporter, readers[i]); |
311 check_alphabet_stream(reporter, streams[i]); | 307 check_alphabet_stream(reporter, streams[i]); |
(...skipping 16 matching lines...) Expand all Loading... |
328 REPORTER_ASSERT(r, !iter.next()); | 324 REPORTER_ASSERT(r, !iter.next()); |
329 REPORTER_ASSERT(r, 0 == iter.size()); | 325 REPORTER_ASSERT(r, 0 == iter.size()); |
330 } | 326 } |
331 | 327 |
332 // Tests that it is safe to destruct an SkRWBuffer without appending | 328 // Tests that it is safe to destruct an SkRWBuffer without appending |
333 // anything to it. | 329 // anything to it. |
334 DEF_TEST(RWBuffer_noAppend, r) { | 330 DEF_TEST(RWBuffer_noAppend, r) { |
335 SkRWBuffer buffer; | 331 SkRWBuffer buffer; |
336 REPORTER_ASSERT(r, 0 == buffer.size()); | 332 REPORTER_ASSERT(r, 0 == buffer.size()); |
337 } | 333 } |
OLD | NEW |