| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkTSort.h" | 9 #include "SkTSort.h" |
| 10 #include "Test.h" | 10 #include "Test.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // pre-seed our string value | 112 // pre-seed our string value |
| 113 int value = 0; | 113 int value = 0; |
| 114 for (int i = 0; i < kWordWidth-1; ++i) { | 114 for (int i = 0; i < kWordWidth-1; ++i) { |
| 115 value <<= 1; | 115 value <<= 1; |
| 116 unsigned int rnd = rand.nextU(); | 116 unsigned int rnd = rand.nextU(); |
| 117 value |= ((rnd >> shift) & 0x1); | 117 value |= ((rnd >> shift) & 0x1); |
| 118 } | 118 } |
| 119 | 119 |
| 120 // now make some strings and track them | 120 // now make some strings and track them |
| 121 for (int i = 0; i < kN; ++i) { | 121 for (int i = 0; i < kN; ++i) { |
| 122 value <<= 1; | 122 value = SkLeftShift(value, 1); |
| 123 unsigned int rnd = rand.nextU(); | 123 unsigned int rnd = rand.nextU(); |
| 124 value |= ((rnd >> shift) & 0x1); | 124 value |= ((rnd >> shift) & 0x1); |
| 125 | 125 |
| 126 int index = value & (kNumEntries-1); | 126 int index = value & (kNumEntries-1); |
| 127 SkASSERT(index < kNumEntries); | 127 SkASSERT(index < kNumEntries); |
| 128 int entry_shift = (value >> (kWordWidth-5)) & 0x1f; | 128 int entry_shift = (value >> (kWordWidth-5)) & 0x1f; |
| 129 entries[index] |= (0x1 << entry_shift); | 129 entries[index] |= (0x1 << entry_shift); |
| 130 } | 130 } |
| 131 | 131 |
| 132 // count entries | 132 // count entries |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 test_random_byte(reporter, 8); | 183 test_random_byte(reporter, 8); |
| 184 test_random_byte(reporter, 16); | 184 test_random_byte(reporter, 16); |
| 185 test_random_byte(reporter, 24); | 185 test_random_byte(reporter, 24); |
| 186 | 186 |
| 187 test_random_float(reporter); | 187 test_random_float(reporter); |
| 188 | 188 |
| 189 test_gorilla(reporter); | 189 test_gorilla(reporter); |
| 190 | 190 |
| 191 test_range(reporter); | 191 test_range(reporter); |
| 192 } | 192 } |
| OLD | NEW |