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 "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkRect.h" | 10 #include "SkRect.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 { { 0, 0, 10, 7 }, { 5, 3 } }, | 28 { { 0, 0, 10, 7 }, { 5, 3 } }, |
29 { { 0, 0, 11, 6 }, { 5, 3 } }, | 29 { { 0, 0, 11, 6 }, { 5, 3 } }, |
30 }; | 30 }; |
31 for (size_t index = 0; index < SK_ARRAY_COUNT(gData); ++index) { | 31 for (size_t index = 0; index < SK_ARRAY_COUNT(gData); ++index) { |
32 REPORTER_ASSERT(reporter, | 32 REPORTER_ASSERT(reporter, |
33 gData[index].fRect.centerX() == gData[index].fCenter.x()
); | 33 gData[index].fRect.centerX() == gData[index].fCenter.x()
); |
34 REPORTER_ASSERT(reporter, | 34 REPORTER_ASSERT(reporter, |
35 gData[index].fRect.centerY() == gData[index].fCenter.y()
); | 35 gData[index].fRect.centerY() == gData[index].fCenter.y()
); |
36 } | 36 } |
37 | 37 |
38 SkMWCRandom rand; | 38 SkRandom rand; |
39 for (int i = 0; i < 10000; ++i) { | 39 for (int i = 0; i < 10000; ++i) { |
40 SkIRect r; | 40 SkIRect r; |
41 | 41 |
42 r.set(rand.nextS() >> 2, rand.nextS() >> 2, | 42 r.set(rand.nextS() >> 2, rand.nextS() >> 2, |
43 rand.nextS() >> 2, rand.nextS() >> 2); | 43 rand.nextS() >> 2, rand.nextS() >> 2); |
44 int cx = r.centerX(); | 44 int cx = r.centerX(); |
45 int cy = r.centerY(); | 45 int cy = r.centerY(); |
46 REPORTER_ASSERT(reporter, ((r.left() + r.right()) >> 1) == cx); | 46 REPORTER_ASSERT(reporter, ((r.left() + r.right()) >> 1) == cx); |
47 REPORTER_ASSERT(reporter, ((r.top() + r.bottom()) >> 1) == cy); | 47 REPORTER_ASSERT(reporter, ((r.top() + r.bottom()) >> 1) == cy); |
48 } | 48 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 check_invalid(reporter, invalid[i], small, big, big); | 82 check_invalid(reporter, invalid[i], small, big, big); |
83 } | 83 } |
84 | 84 |
85 test_center(reporter); | 85 test_center(reporter); |
86 } | 86 } |
87 | 87 |
88 // need tests for SkStrSearch | 88 // need tests for SkStrSearch |
89 | 89 |
90 #include "TestClassDef.h" | 90 #include "TestClassDef.h" |
91 DEFINE_TESTCLASS("InfRect", InfRectTestClass, TestInfRect) | 91 DEFINE_TESTCLASS("InfRect", InfRectTestClass, TestInfRect) |
OLD | NEW |