OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
11 #include "SkTSort.h" | 11 #include "SkTSort.h" |
12 | 12 |
13 static bool anderson_darling_test(double p[32]) { | 13 static bool anderson_darling_test(double p[32]) { |
14 // Min and max Anderson-Darling values allowable for k=32 | 14 // Min and max Anderson-Darling values allowable for k=32 |
15 const double kADMin32 = 0.202; // p-value of ~0.1 | 15 const double kADMin32 = 0.202; // p-value of ~0.1 |
16 const double kADMax32 = 3.89; // p-value of ~0.99 | 16 const double kADMax32 = 3.89; // p-value of ~0.99 |
17 | 17 |
18 // sort p values | 18 // sort p values |
19 SkTQSort<double>(p, p + 31); | 19 SkTQSort<double>(p, p + 31); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 memset(bins, 0, sizeof(int)*256); | 171 memset(bins, 0, sizeof(int)*256); |
172 for (int i = 0; i < 256*10000; ++i) { | 172 for (int i = 0; i < 256*10000; ++i) { |
173 unsigned int u = rand.nextRangeU(17, 17+255); | 173 unsigned int u = rand.nextRangeU(17, 17+255); |
174 REPORTER_ASSERT(reporter, 17 <= u && u <= 17+255); | 174 REPORTER_ASSERT(reporter, 17 <= u && u <= 17+255); |
175 bins[u - 17]++; | 175 bins[u - 17]++; |
176 } | 176 } |
177 | 177 |
178 REPORTER_ASSERT(reporter, chi_square_test(bins, 10000)); | 178 REPORTER_ASSERT(reporter, chi_square_test(bins, 10000)); |
179 } | 179 } |
180 | 180 |
181 static void TestRandom(skiatest::Reporter* reporter) { | 181 DEF_TEST(Random, reporter) { |
182 // check uniform distributions of each byte in 32-bit word | 182 // check uniform distributions of each byte in 32-bit word |
183 test_random_byte(reporter, 0); | 183 test_random_byte(reporter, 0); |
184 test_random_byte(reporter, 8); | 184 test_random_byte(reporter, 8); |
185 test_random_byte(reporter, 16); | 185 test_random_byte(reporter, 16); |
186 test_random_byte(reporter, 24); | 186 test_random_byte(reporter, 24); |
187 | 187 |
188 test_random_float(reporter); | 188 test_random_float(reporter); |
189 | 189 |
190 test_gorilla(reporter); | 190 test_gorilla(reporter); |
191 | 191 |
192 test_range(reporter); | 192 test_range(reporter); |
193 } | 193 } |
194 | |
195 #include "TestClassDef.h" | |
196 DEFINE_TESTCLASS("Random", RandomTestClass, TestRandom) | |
OLD | NEW |