Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: tests/PathOpsLineParametetersTest.cpp

Issue 2426173002: fix fuzzers (Closed)
Patch Set: fix dm Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/PathOpsDRectTest.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
11 // tests to verify that distance calculations are coded correctly 11 // tests to verify that distance calculations are coded correctly
12 static const SkDCubic tests[] = { 12 static const CubicPts tests[] = {
13 {{{0, 0}, {1, 1}, {2, 2}, {0, 3}}}, 13 {{{0, 0}, {1, 1}, {2, 2}, {0, 3}}},
14 {{{0, 0}, {1, 1}, {2, 2}, {3, 0}}}, 14 {{{0, 0}, {1, 1}, {2, 2}, {3, 0}}},
15 {{{0, 0}, {5, 0}, {-2, 4}, {3, 4}}}, 15 {{{0, 0}, {5, 0}, {-2, 4}, {3, 4}}},
16 {{{0, 2}, {1, 0}, {2, 0}, {3, 0}}}, 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, .02}, {1, 0}, {2, 0}, {3, 0}}}, 18 {{{0, .02}, {1, 0}, {2, 0}, {3, 0}}},
19 {{{0, .002}, {1, 0}, {2, 0}, {3, 0}}}, 19 {{{0, .002}, {1, 0}, {2, 0}, {3, 0}}},
20 {{{0, .0002}, {1, 0}, {2, 0}, {3, 0}}}, 20 {{{0, .0002}, {1, 0}, {2, 0}, {3, 0}}},
21 {{{0, .00002}, {1, 0}, {2, 0}, {3, 0}}}, 21 {{{0, .00002}, {1, 0}, {2, 0}, {3, 0}}},
22 {{{0, FLT_EPSILON * 2}, {1, 0}, {2, 0}, {3, 0}}}, 22 {{{0, FLT_EPSILON * 2}, {1, 0}, {2, 0}, {3, 0}}},
(...skipping 10 matching lines...) Expand all
33 {0.000133333333, 6.666666652e-05}, 33 {0.000133333333, 6.666666652e-05},
34 {1.333333333e-05, 6.666666667e-06}, 34 {1.333333333e-05, 6.666666667e-06},
35 {1.5894571940104115e-07, 7.9472859700520577e-08}, 35 {1.5894571940104115e-07, 7.9472859700520577e-08},
36 }; 36 };
37 37
38 static const size_t tests_count = SK_ARRAY_COUNT(tests); 38 static const size_t tests_count = SK_ARRAY_COUNT(tests);
39 39
40 DEF_TEST(PathOpsLineParameters, reporter) { 40 DEF_TEST(PathOpsLineParameters, reporter) {
41 for (size_t index = 0; index < tests_count; ++index) { 41 for (size_t index = 0; index < tests_count; ++index) {
42 SkLineParameters lineParameters; 42 SkLineParameters lineParameters;
43 const SkDCubic& cubic = tests[index]; 43 const CubicPts& c = tests[index];
44 SkDCubic cubic;
45 cubic.debugSet(c.fPts);
44 SkASSERT(ValidCubic(cubic)); 46 SkASSERT(ValidCubic(cubic));
45 lineParameters.cubicEndPoints(cubic, 0, 3); 47 lineParameters.cubicEndPoints(cubic, 0, 3);
46 double denormalizedDistance[2]; 48 double denormalizedDistance[2];
47 denormalizedDistance[0] = lineParameters.controlPtDistance(cubic, 1); 49 denormalizedDistance[0] = lineParameters.controlPtDistance(cubic, 1);
48 denormalizedDistance[1] = lineParameters.controlPtDistance(cubic, 2); 50 denormalizedDistance[1] = lineParameters.controlPtDistance(cubic, 2);
49 double normalSquared = lineParameters.normalSquared(); 51 double normalSquared = lineParameters.normalSquared();
50 size_t inner; 52 size_t inner;
51 for (inner = 0; inner < 2; ++inner) { 53 for (inner = 0; inner < 2; ++inner) {
52 double distSq = denormalizedDistance[inner]; 54 double distSq = denormalizedDistance[inner];
53 distSq *= distSq; 55 distSq *= distSq;
(...skipping 16 matching lines...) Expand all
70 if (AlmostEqualUlps(fabs(normalizedDistance[inner]), answers[index][ inner])) { 72 if (AlmostEqualUlps(fabs(normalizedDistance[inner]), answers[index][ inner])) {
71 continue; 73 continue;
72 } 74 }
73 SkDebugf("%s [%d,%d] normalizedDistance:%1.9g != answer:%g\n", 75 SkDebugf("%s [%d,%d] normalizedDistance:%1.9g != answer:%g\n",
74 __FUNCTION__, static_cast<int>(index), (int)inner, 76 __FUNCTION__, static_cast<int>(index), (int)inner,
75 normalizedDistance[inner], answers[index][inner]); 77 normalizedDistance[inner], answers[index][inner]);
76 REPORTER_ASSERT(reporter, 0); 78 REPORTER_ASSERT(reporter, 0);
77 } 79 }
78 } 80 }
79 } 81 }
OLDNEW
« no previous file with comments | « tests/PathOpsDRectTest.cpp ('k') | tests/PathOpsOpTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698