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 "SkChecksum.h" |
9 #include "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "Test.h" | 10 #include "Test.h" |
11 #include "TestClassDef.h" | |
12 | 11 |
13 | 12 |
14 // Murmur3 has an optional third seed argument, so we wrap it to fit a uniform t
ype. | 13 // Murmur3 has an optional third seed argument, so we wrap it to fit a uniform t
ype. |
15 static uint32_t murmur_noseed(const uint32_t* d, size_t l) { return SkChecksum::
Murmur3(d, l); } | 14 static uint32_t murmur_noseed(const uint32_t* d, size_t l) { return SkChecksum::
Murmur3(d, l); } |
16 | 15 |
17 #define ASSERT(x) REPORTER_ASSERT(r, x) | 16 #define ASSERT(x) REPORTER_ASSERT(r, x) |
18 | 17 |
19 DEF_TEST(Checksum, r) { | 18 DEF_TEST(Checksum, r) { |
20 // Algorithms to test. They're currently all uint32_t(const uint32_t*, size
_t). | 19 // Algorithms to test. They're currently all uint32_t(const uint32_t*, size
_t). |
21 typedef uint32_t(*algorithmProc)(const uint32_t*, size_t); | 20 typedef uint32_t(*algorithmProc)(const uint32_t*, size_t); |
(...skipping 22 matching lines...) Expand all Loading... |
44 for (size_t j = 0; j < SK_ARRAY_COUNT(tweaked); ++j) { | 43 for (size_t j = 0; j < SK_ARRAY_COUNT(tweaked); ++j) { |
45 const uint32_t saved = tweaked[j]; | 44 const uint32_t saved = tweaked[j]; |
46 tweaked[j] = rand.nextU(); | 45 tweaked[j] = rand.nextU(); |
47 const uint32_t tweakedHash = algorithm(tweaked, kBytes); | 46 const uint32_t tweakedHash = algorithm(tweaked, kBytes); |
48 ASSERT(tweakedHash != hash); | 47 ASSERT(tweakedHash != hash); |
49 ASSERT(tweakedHash == algorithm(tweaked, kBytes)); | 48 ASSERT(tweakedHash == algorithm(tweaked, kBytes)); |
50 tweaked[j] = saved; | 49 tweaked[j] = saved; |
51 } | 50 } |
52 } | 51 } |
53 } | 52 } |
OLD | NEW |