OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkChecksum.h" |
8 #include "SkOpts.h" | 9 #include "SkOpts.h" |
9 #include "SkRandom.h" | 10 #include "SkRandom.h" |
10 #include "Test.h" | 11 #include "Test.h" |
11 | 12 |
12 DEF_TEST(Checksum, r) { | 13 DEF_TEST(Checksum, r) { |
13 // Put 128 random bytes into two identical buffers. Any multiple of 4 will
do. | 14 // Put 128 random bytes into two identical buffers. Any multiple of 4 will
do. |
14 const size_t kBytes = SkAlign4(128); | 15 const size_t kBytes = SkAlign4(128); |
15 SkRandom rand; | 16 SkRandom rand; |
16 uint32_t data[kBytes/4], tweaked[kBytes/4]; | 17 uint32_t data[kBytes/4], tweaked[kBytes/4]; |
17 for (size_t i = 0; i < SK_ARRAY_COUNT(tweaked); ++i) { | 18 for (size_t i = 0; i < SK_ARRAY_COUNT(tweaked); ++i) { |
(...skipping 16 matching lines...) Expand all Loading... |
34 REPORTER_ASSERT(r, tweakedHash == SkOpts::hash(tweaked, kBytes)); | 35 REPORTER_ASSERT(r, tweakedHash == SkOpts::hash(tweaked, kBytes)); |
35 tweaked[j] = saved; | 36 tweaked[j] = saved; |
36 } | 37 } |
37 } | 38 } |
38 | 39 |
39 DEF_TEST(GoodHash, r) { | 40 DEF_TEST(GoodHash, r) { |
40 // 4 bytes --> hits SkChecksum::Mix fast path. | 41 // 4 bytes --> hits SkChecksum::Mix fast path. |
41 REPORTER_ASSERT(r, SkGoodHash()(( int32_t)4) == 614249093); | 42 REPORTER_ASSERT(r, SkGoodHash()(( int32_t)4) == 614249093); |
42 REPORTER_ASSERT(r, SkGoodHash()((uint32_t)4) == 614249093); | 43 REPORTER_ASSERT(r, SkGoodHash()((uint32_t)4) == 614249093); |
43 } | 44 } |
OLD | NEW |