OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #include "Test.h" | 8 #include "Test.h" |
9 #include "gradients/SkClampRange.h" | 9 #include "gradients/SkClampRange.h" |
10 #include "SkRandom.h" | 10 #include "SkRandom.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 test_range(-10, 1, 20); | 100 test_range(-10, 1, 20); |
101 test_range(10, -1, 20); | 101 test_range(10, -1, 20); |
102 test_range(-10, 3, 20); | 102 test_range(-10, 3, 20); |
103 test_range(10, -3, 20); | 103 test_range(10, -3, 20); |
104 | 104 |
105 test_range(ff(1), ff(16384), 100); | 105 test_range(ff(1), ff(16384), 100); |
106 test_range(ff(-1), ff(-16384), 100); | 106 test_range(ff(-1), ff(-16384), 100); |
107 test_range(ff(1)/2, ff(16384), 100); | 107 test_range(ff(1)/2, ff(16384), 100); |
108 test_range(ff(1)/2, ff(-16384), 100); | 108 test_range(ff(1)/2, ff(-16384), 100); |
109 | 109 |
110 SkMWCRandom rand; | 110 SkRandom rand; |
111 | 111 |
112 // test non-overflow cases | 112 // test non-overflow cases |
113 for (int i = 0; i < 1000000; i++) { | 113 for (int i = 0; i < 1000000; i++) { |
114 SkFixed fx = rand.nextS() >> 1; | 114 SkFixed fx = rand.nextS() >> 1; |
115 SkFixed sx = rand.nextS() >> 1; | 115 SkFixed sx = rand.nextS() >> 1; |
116 int count = rand.nextU() % 1000 + 1; | 116 int count = rand.nextU() % 1000 + 1; |
117 SkFixed dx = (sx - fx) / count; | 117 SkFixed dx = (sx - fx) / count; |
118 test_range(fx, dx, count); | 118 test_range(fx, dx, count); |
119 } | 119 } |
120 | 120 |
121 // test overflow cases | 121 // test overflow cases |
122 for (int i = 0; i < 100000; i++) { | 122 for (int i = 0; i < 100000; i++) { |
123 SkFixed fx = rand.nextS(); | 123 SkFixed fx = rand.nextS(); |
124 SkFixed dx = rand.nextS(); | 124 SkFixed dx = rand.nextS(); |
125 int count = rand.nextU() % 1000 + 1; | 125 int count = rand.nextU() % 1000 + 1; |
126 test_range(fx, dx, count); | 126 test_range(fx, dx, count); |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 #ifdef USE_REPORTER | 130 #ifdef USE_REPORTER |
131 | 131 |
132 #include "TestClassDef.h" | 132 #include "TestClassDef.h" |
133 DEFINE_TESTCLASS("ClampRange", ClampRangeClass, TestClampRange) | 133 DEFINE_TESTCLASS("ClampRange", ClampRangeClass, TestClampRange) |
134 | 134 |
135 #endif | 135 #endif |
OLD | NEW |