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 "SkReader32.h" | 8 #include "SkReader32.h" |
9 #include "Test.h" | 9 #include "Test.h" |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 REPORTER_ASSERT(reporter, 0 == reader.offset()); | 28 REPORTER_ASSERT(reporter, 0 == reader.offset()); |
29 REPORTER_ASSERT(reporter, 0 == reader.available()); | 29 REPORTER_ASSERT(reporter, 0 == reader.available()); |
30 REPORTER_ASSERT(reporter, !reader.isAvailable(1)); | 30 REPORTER_ASSERT(reporter, !reader.isAvailable(1)); |
31 assert_eof(reporter, reader); | 31 assert_eof(reporter, reader); |
32 assert_start(reporter, reader); | 32 assert_start(reporter, reader); |
33 } | 33 } |
34 | 34 |
35 DEF_TEST(Reader32, reporter) { | 35 DEF_TEST(Reader32, reporter) { |
36 SkReader32 reader; | 36 SkReader32 reader; |
37 assert_empty(reporter, reader); | 37 assert_empty(reporter, reader); |
38 REPORTER_ASSERT(reporter, NULL == reader.base()); | 38 REPORTER_ASSERT(reporter, nullptr == reader.base()); |
39 REPORTER_ASSERT(reporter, NULL == reader.peek()); | 39 REPORTER_ASSERT(reporter, nullptr == reader.peek()); |
40 | 40 |
41 size_t i; | 41 size_t i; |
42 | 42 |
43 const int32_t data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | 43 const int32_t data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; |
44 const SkScalar data2[] = { 0, SK_Scalar1, -SK_Scalar1, SK_Scalar1/2 }; | 44 const SkScalar data2[] = { 0, SK_Scalar1, -SK_Scalar1, SK_Scalar1/2 }; |
45 const size_t bufsize = sizeof(data) > sizeof(data2) ? | 45 const size_t bufsize = sizeof(data) > sizeof(data2) ? |
46 sizeof(data) : sizeof(data2); | 46 sizeof(data) : sizeof(data2); |
47 char buffer[bufsize]; | 47 char buffer[bufsize]; |
48 | 48 |
49 reader.setMemory(data, sizeof(data)); | 49 reader.setMemory(data, sizeof(data)); |
(...skipping 17 matching lines...) Expand all Loading... |
67 REPORTER_ASSERT(reporter, (const void*)data2 == reader.base()); | 67 REPORTER_ASSERT(reporter, (const void*)data2 == reader.base()); |
68 REPORTER_ASSERT(reporter, (const void*)&data2[i] == reader.peek()); | 68 REPORTER_ASSERT(reporter, (const void*)&data2[i] == reader.peek()); |
69 REPORTER_ASSERT(reporter, data2[i] == reader.readScalar()); | 69 REPORTER_ASSERT(reporter, data2[i] == reader.readScalar()); |
70 } | 70 } |
71 assert_eof(reporter, reader); | 71 assert_eof(reporter, reader); |
72 reader.rewind(); | 72 reader.rewind(); |
73 assert_start(reporter, reader); | 73 assert_start(reporter, reader); |
74 reader.read(buffer, sizeof(data2)); | 74 reader.read(buffer, sizeof(data2)); |
75 REPORTER_ASSERT(reporter, !memcmp(data2, buffer, sizeof(data2))); | 75 REPORTER_ASSERT(reporter, !memcmp(data2, buffer, sizeof(data2))); |
76 | 76 |
77 reader.setMemory(NULL, 0); | 77 reader.setMemory(nullptr, 0); |
78 assert_empty(reporter, reader); | 78 assert_empty(reporter, reader); |
79 REPORTER_ASSERT(reporter, NULL == reader.base()); | 79 REPORTER_ASSERT(reporter, nullptr == reader.base()); |
80 REPORTER_ASSERT(reporter, NULL == reader.peek()); | 80 REPORTER_ASSERT(reporter, nullptr == reader.peek()); |
81 } | 81 } |
OLD | NEW |