OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2012 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 #include "CurveIntersection.h" | |
8 #include "Intersection_Tests.h" | |
9 #include "QuadraticIntersection_TestData.h" | |
10 #include "TestUtilities.h" | |
11 | |
12 static const Quadratic testSet[] = { | |
13 {{1, 1}, {2, 2}, {1, 1.000003}}, | |
14 {{1, 0}, {2, 6}, {3, 0}} | |
15 }; | |
16 | |
17 static const size_t testSetCount = sizeof(testSet) / sizeof(testSet[0]); | |
18 | |
19 | |
20 static void oneOffTest() { | |
21 SkDebugf("%s FLT_EPSILON=%1.9g\n", __FUNCTION__, FLT_EPSILON); | |
22 for (size_t index = 0; index < testSetCount; ++index) { | |
23 const Quadratic& quad = testSet[index]; | |
24 Quadratic reduce; | |
25 SkDEBUGCODE(int result = ) reduceOrder(quad, reduce, kReduceOrder_TreatA
sFill); | |
26 SkASSERT(result == 3); | |
27 } | |
28 } | |
29 | |
30 static void standardTestCases() { | |
31 size_t index; | |
32 Quadratic reduce; | |
33 int order; | |
34 enum { | |
35 RunAll, | |
36 RunQuadraticLines, | |
37 RunQuadraticModLines, | |
38 RunNone | |
39 } run = RunAll; | |
40 int firstTestIndex = 0; | |
41 #if 0 | |
42 run = RunQuadraticLines; | |
43 firstTestIndex = 1; | |
44 #endif | |
45 int firstQuadraticLineTest = run == RunAll ? 0 : run == RunQuadraticLines ?
firstTestIndex : SK_MaxS32; | |
46 int firstQuadraticModLineTest = run == RunAll ? 0 : run == RunQuadraticModLi
nes ? firstTestIndex : SK_MaxS32; | |
47 | |
48 for (index = firstQuadraticLineTest; index < quadraticLines_count; ++index)
{ | |
49 const Quadratic& quad = quadraticLines[index]; | |
50 order = reduceOrder(quad, reduce, kReduceOrder_TreatAsFill); | |
51 if (order != 2) { | |
52 printf("[%d] line quad order=%d\n", (int) index, order); | |
53 } | |
54 } | |
55 for (index = firstQuadraticModLineTest; index < quadraticModEpsilonLines_cou
nt; ++index) { | |
56 const Quadratic& quad = quadraticModEpsilonLines[index]; | |
57 order = reduceOrder(quad, reduce, kReduceOrder_TreatAsFill); | |
58 if (order != 3) { | |
59 printf("[%d] line mod quad order=%d\n", (int) index, order); | |
60 } | |
61 } | |
62 } | |
63 | |
64 void QuadraticReduceOrder_Test() { | |
65 oneOffTest(); | |
66 standardTestCases(); | |
67 } | |
OLD | NEW |