OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "Test.h" | 8 #include "Test.h" |
9 #include "Sk2x.h" | 9 #include "Sk2x.h" |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 // Math | 43 // Math |
44 REPORTER_ASSERT(r, eq(a + d, 6, 9)); | 44 REPORTER_ASSERT(r, eq(a + d, 6, 9)); |
45 REPORTER_ASSERT(r, eq(a - d, 2, -1)); | 45 REPORTER_ASSERT(r, eq(a - d, 2, -1)); |
46 REPORTER_ASSERT(r, eq(a * d, 8, 20)); | 46 REPORTER_ASSERT(r, eq(a * d, 8, 20)); |
47 REPORTER_ASSERT(r, eq(a / d, 2, 0.8)); | 47 REPORTER_ASSERT(r, eq(a / d, 2, 0.8)); |
48 | 48 |
49 REPORTER_ASSERT(r, nearly_eq(0.001, a.rsqrt(), 0.5, 0.5)); | 49 REPORTER_ASSERT(r, nearly_eq(0.001, a.rsqrt(), 0.5, 0.5)); |
50 REPORTER_ASSERT(r, eq(a.sqrt(), 2, 2)); | 50 REPORTER_ASSERT(r, eq(a.sqrt(), 2, 2)); |
51 | 51 |
| 52 REPORTER_ASSERT(r, nearly_eq(0.001, d.approxInvert(), 0.5, 0.2)); |
| 53 REPORTER_ASSERT(r, eq(d.invert(), 0.5, 0.2)); |
| 54 |
52 REPORTER_ASSERT(r, eq(Sk2x<T>::Min(a, d), 2, 4)); | 55 REPORTER_ASSERT(r, eq(Sk2x<T>::Min(a, d), 2, 4)); |
53 REPORTER_ASSERT(r, eq(Sk2x<T>::Max(a, d), 4, 5)); | 56 REPORTER_ASSERT(r, eq(Sk2x<T>::Max(a, d), 4, 5)); |
54 | 57 |
55 REPORTER_ASSERT(r, eq(-d, -2, -5)); | 58 REPORTER_ASSERT(r, eq(-d, -2, -5)); |
56 | 59 |
57 // A bit of both. | 60 // A bit of both. |
58 a += d; | 61 a += d; |
59 a *= d; | 62 a *= d; |
60 a -= d; | 63 a -= d; |
61 REPORTER_ASSERT(r, eq(a, 10, 40)); | 64 REPORTER_ASSERT(r, eq(a, 10, 40)); |
62 } | 65 } |
63 | 66 |
64 DEF_TEST(Sk2f, r) { test< float>(r); } | 67 DEF_TEST(Sk2f, r) { test< float>(r); } |
65 DEF_TEST(Sk2d, r) { test<double>(r); } | 68 DEF_TEST(Sk2d, r) { test<double>(r); } |
OLD | NEW |