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

Side by Side Diff: tests/PathOpsDPointTest.cpp

Issue 19374003: harden and speed up path op unit tests (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rename threaded to single Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « tests/PathOpsDLineTest.cpp ('k') | tests/PathOpsDQuadTest.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 "SkPathOpsPoint.h" 8 #include "SkPathOpsPoint.h"
8 #include "Test.h" 9 #include "Test.h"
9 10
10 static const SkDPoint tests[] = { 11 static const SkDPoint tests[] = {
11 {0, 0}, 12 {0, 0},
12 {1, 0}, 13 {1, 0},
13 {0, 1}, 14 {0, 1},
14 {2, 1}, 15 {2, 1},
15 {1, 2}, 16 {1, 2},
16 {1, 1}, 17 {1, 1},
17 {2, 2} 18 {2, 2}
18 }; 19 };
19 20
20 static const size_t tests_count = SK_ARRAY_COUNT(tests); 21 static const size_t tests_count = SK_ARRAY_COUNT(tests);
21 22
22 static void PathOpsDPointTest(skiatest::Reporter* reporter) { 23 static void PathOpsDPointTest(skiatest::Reporter* reporter) {
23 for (size_t index = 0; index < tests_count; ++index) { 24 for (size_t index = 0; index < tests_count; ++index) {
24 const SkDPoint& pt = tests[index]; 25 const SkDPoint& pt = tests[index];
26 SkASSERT(ValidPoint(pt));
25 SkDPoint p = pt; 27 SkDPoint p = pt;
26 REPORTER_ASSERT(reporter, p == pt); 28 REPORTER_ASSERT(reporter, p == pt);
27 REPORTER_ASSERT(reporter, !(pt != pt)); 29 REPORTER_ASSERT(reporter, !(pt != pt));
28 SkDVector v = p - pt; 30 SkDVector v = p - pt;
29 p += v; 31 p += v;
30 REPORTER_ASSERT(reporter, p == pt); 32 REPORTER_ASSERT(reporter, p == pt);
31 p -= v; 33 p -= v;
32 REPORTER_ASSERT(reporter, p == pt); 34 REPORTER_ASSERT(reporter, p == pt);
33 REPORTER_ASSERT(reporter, p.approximatelyEqual(pt)); 35 REPORTER_ASSERT(reporter, p.approximatelyEqual(pt));
34 SkPoint sPt = pt.asSkPoint(); 36 SkPoint sPt = pt.asSkPoint();
35 p.set(sPt); 37 p.set(sPt);
36 REPORTER_ASSERT(reporter, p == pt); 38 REPORTER_ASSERT(reporter, p == pt);
37 REPORTER_ASSERT(reporter, p.approximatelyEqual(sPt)); 39 REPORTER_ASSERT(reporter, p.approximatelyEqual(sPt));
38 REPORTER_ASSERT(reporter, p.roughlyEqual(pt)); 40 REPORTER_ASSERT(reporter, p.roughlyEqual(pt));
39 REPORTER_ASSERT(reporter, p.moreRoughlyEqual(pt)); 41 REPORTER_ASSERT(reporter, p.moreRoughlyEqual(pt));
40 p.fX = p.fY = 0; 42 p.fX = p.fY = 0;
41 REPORTER_ASSERT(reporter, p.fX == 0 && p.fY == 0); 43 REPORTER_ASSERT(reporter, p.fX == 0 && p.fY == 0);
42 REPORTER_ASSERT(reporter, p.approximatelyZero()); 44 REPORTER_ASSERT(reporter, p.approximatelyZero());
43 REPORTER_ASSERT(reporter, pt.distanceSquared(p) == pt.fX * pt.fX + pt.fY * pt.fY); 45 REPORTER_ASSERT(reporter, pt.distanceSquared(p) == pt.fX * pt.fX + pt.fY * pt.fY);
44 REPORTER_ASSERT(reporter, approximately_equal(pt.distance(p), 46 REPORTER_ASSERT(reporter, approximately_equal(pt.distance(p),
45 sqrt(pt.fX * pt.fX + pt.fY * pt.fY))); 47 sqrt(pt.fX * pt.fX + pt.fY * pt.fY)));
46 } 48 }
47 } 49 }
48 50
49 #include "TestClassDef.h" 51 #include "TestClassDef.h"
50 DEFINE_TESTCLASS_SHORT(PathOpsDPointTest) 52 DEFINE_TESTCLASS_SHORT(PathOpsDPointTest)
OLDNEW
« no previous file with comments | « tests/PathOpsDLineTest.cpp ('k') | tests/PathOpsDQuadTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698