OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 #include "PathOpsTestCommon.h" | 7 #include "PathOpsTestCommon.h" |
8 #include "SkLineParameters.h" | 8 #include "SkLineParameters.h" |
9 #include "Test.h" | 9 #include "Test.h" |
| 10 #include "TestClassDef.h" |
10 | 11 |
11 // tests to verify that distance calculations are coded correctly | 12 // tests to verify that distance calculations are coded correctly |
12 static const SkDCubic tests[] = { | 13 static const SkDCubic tests[] = { |
13 {{{0, 0}, {1, 1}, {2, 2}, {0, 3}}}, | 14 {{{0, 0}, {1, 1}, {2, 2}, {0, 3}}}, |
14 {{{0, 0}, {1, 1}, {2, 2}, {3, 0}}}, | 15 {{{0, 0}, {1, 1}, {2, 2}, {3, 0}}}, |
15 {{{0, 0}, {5, 0}, {-2, 4}, {3, 4}}}, | 16 {{{0, 0}, {5, 0}, {-2, 4}, {3, 4}}}, |
16 {{{0, 2}, {1, 0}, {2, 0}, {3, 0}}}, | 17 {{{0, 2}, {1, 0}, {2, 0}, {3, 0}}}, |
17 {{{0, .2}, {1, 0}, {2, 0}, {3, 0}}}, | 18 {{{0, .2}, {1, 0}, {2, 0}, {3, 0}}}, |
18 {{{0, .02}, {1, 0}, {2, 0}, {3, 0}}}, | 19 {{{0, .02}, {1, 0}, {2, 0}, {3, 0}}}, |
19 {{{0, .002}, {1, 0}, {2, 0}, {3, 0}}}, | 20 {{{0, .002}, {1, 0}, {2, 0}, {3, 0}}}, |
(...skipping 10 matching lines...) Expand all Loading... |
30 {0.133038021, 0.06651901052}, | 31 {0.133038021, 0.06651901052}, |
31 {0.0133330370, 0.006666518523}, | 32 {0.0133330370, 0.006666518523}, |
32 {0.001333333037, 0.0006666665185}, | 33 {0.001333333037, 0.0006666665185}, |
33 {0.000133333333, 6.666666652e-05}, | 34 {0.000133333333, 6.666666652e-05}, |
34 {1.333333333e-05, 6.666666667e-06}, | 35 {1.333333333e-05, 6.666666667e-06}, |
35 {1.5894571940104115e-07, 7.9472859700520577e-08}, | 36 {1.5894571940104115e-07, 7.9472859700520577e-08}, |
36 }; | 37 }; |
37 | 38 |
38 static const size_t tests_count = SK_ARRAY_COUNT(tests); | 39 static const size_t tests_count = SK_ARRAY_COUNT(tests); |
39 | 40 |
40 static void PathOpsLineParametersTest(skiatest::Reporter* reporter) { | 41 DEF_TEST(PathOpsLineParameters, reporter) { |
41 for (size_t index = 0; index < tests_count; ++index) { | 42 for (size_t index = 0; index < tests_count; ++index) { |
42 SkLineParameters lineParameters; | 43 SkLineParameters lineParameters; |
43 const SkDCubic& cubic = tests[index]; | 44 const SkDCubic& cubic = tests[index]; |
44 SkASSERT(ValidCubic(cubic)); | 45 SkASSERT(ValidCubic(cubic)); |
45 lineParameters.cubicEndPoints(cubic, 0, 3); | 46 lineParameters.cubicEndPoints(cubic, 0, 3); |
46 double denormalizedDistance[2]; | 47 double denormalizedDistance[2]; |
47 denormalizedDistance[0] = lineParameters.controlPtDistance(cubic, 1); | 48 denormalizedDistance[0] = lineParameters.controlPtDistance(cubic, 1); |
48 denormalizedDistance[1] = lineParameters.controlPtDistance(cubic, 2); | 49 denormalizedDistance[1] = lineParameters.controlPtDistance(cubic, 2); |
49 double normalSquared = lineParameters.normalSquared(); | 50 double normalSquared = lineParameters.normalSquared(); |
50 size_t inner; | 51 size_t inner; |
(...skipping 19 matching lines...) Expand all Loading... |
70 if (AlmostEqualUlps(fabs(normalizedDistance[inner]), answers[index][
inner])) { | 71 if (AlmostEqualUlps(fabs(normalizedDistance[inner]), answers[index][
inner])) { |
71 continue; | 72 continue; |
72 } | 73 } |
73 SkDebugf("%s [%d,%d] normalizedDistance:%1.9g != answer:%g\n", | 74 SkDebugf("%s [%d,%d] normalizedDistance:%1.9g != answer:%g\n", |
74 __FUNCTION__, static_cast<int>(index), (int)inner, | 75 __FUNCTION__, static_cast<int>(index), (int)inner, |
75 normalizedDistance[inner], answers[index][inner]); | 76 normalizedDistance[inner], answers[index][inner]); |
76 REPORTER_ASSERT(reporter, 0); | 77 REPORTER_ASSERT(reporter, 0); |
77 } | 78 } |
78 } | 79 } |
79 } | 80 } |
80 | |
81 #include "TestClassDef.h" | |
82 DEFINE_TESTCLASS_SHORT(PathOpsLineParametersTest) | |
OLD | NEW |