OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 */ |
| 7 |
8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
9 #include "SkSize.h" | 10 #include "SkSize.h" |
10 | 11 |
11 static void TestISize(skiatest::Reporter* reporter) { | 12 static void TestISize(skiatest::Reporter* reporter) { |
12 SkISize a, b; | 13 SkISize a, b; |
13 | 14 |
14 a.set(0, 0); | 15 a.set(0, 0); |
15 REPORTER_ASSERT(reporter, a.isEmpty()); | 16 REPORTER_ASSERT(reporter, a.isEmpty()); |
16 a.set(5, -5); | 17 a.set(5, -5); |
17 REPORTER_ASSERT(reporter, a.isEmpty()); | 18 REPORTER_ASSERT(reporter, a.isEmpty()); |
18 a.clampNegToZero(); | 19 a.clampNegToZero(); |
19 REPORTER_ASSERT(reporter, a.isEmpty()); | 20 REPORTER_ASSERT(reporter, a.isEmpty()); |
20 b.set(5, 0); | 21 b.set(5, 0); |
21 REPORTER_ASSERT(reporter, a == b); | 22 REPORTER_ASSERT(reporter, a == b); |
22 | 23 |
23 a.set(3, 5); | 24 a.set(3, 5); |
24 REPORTER_ASSERT(reporter, !a.isEmpty()); | 25 REPORTER_ASSERT(reporter, !a.isEmpty()); |
25 b = a; | 26 b = a; |
26 REPORTER_ASSERT(reporter, !b.isEmpty()); | 27 REPORTER_ASSERT(reporter, !b.isEmpty()); |
27 REPORTER_ASSERT(reporter, a == b); | 28 REPORTER_ASSERT(reporter, a == b); |
28 REPORTER_ASSERT(reporter, !(a != b)); | 29 REPORTER_ASSERT(reporter, !(a != b)); |
29 REPORTER_ASSERT(reporter, | 30 REPORTER_ASSERT(reporter, |
30 a.fWidth == b.fWidth && a.fHeight == b.fHeight); | 31 a.fWidth == b.fWidth && a.fHeight == b.fHeight); |
31 } | 32 } |
32 | 33 |
33 static void TestSize(skiatest::Reporter* reporter) { | 34 DEF_TEST(Size, reporter) { |
34 TestISize(reporter); | 35 TestISize(reporter); |
35 | 36 |
36 SkSize a, b; | 37 SkSize a, b; |
37 int ix = 5; | 38 int ix = 5; |
38 int iy = 3; | 39 int iy = 3; |
39 SkScalar x = SkIntToScalar(ix); | 40 SkScalar x = SkIntToScalar(ix); |
40 SkScalar y = SkIntToScalar(iy); | 41 SkScalar y = SkIntToScalar(iy); |
41 | 42 |
42 a.set(0, 0); | 43 a.set(0, 0); |
43 REPORTER_ASSERT(reporter, a.isEmpty()); | 44 REPORTER_ASSERT(reporter, a.isEmpty()); |
(...skipping 10 matching lines...) Expand all Loading... |
54 REPORTER_ASSERT(reporter, !b.isEmpty()); | 55 REPORTER_ASSERT(reporter, !b.isEmpty()); |
55 REPORTER_ASSERT(reporter, a == b); | 56 REPORTER_ASSERT(reporter, a == b); |
56 REPORTER_ASSERT(reporter, !(a != b)); | 57 REPORTER_ASSERT(reporter, !(a != b)); |
57 REPORTER_ASSERT(reporter, | 58 REPORTER_ASSERT(reporter, |
58 a.fWidth == b.fWidth && a.fHeight == b.fHeight); | 59 a.fWidth == b.fWidth && a.fHeight == b.fHeight); |
59 | 60 |
60 SkISize ia; | 61 SkISize ia; |
61 ia.set(ix, iy); | 62 ia.set(ix, iy); |
62 a.set(x, y); | 63 a.set(x, y); |
63 REPORTER_ASSERT(reporter, a.toRound() == ia); | 64 REPORTER_ASSERT(reporter, a.toRound() == ia); |
64 }; | 65 } |
65 | |
66 #include "TestClassDef.h" | |
67 DEFINE_TESTCLASS("Size", TestSizeClass, TestSize) | |
OLD | NEW |