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

Side by Side Diff: tests/PathOpsDPointTest.cpp

Issue 12827020: Add base types for path ops (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 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
OLDNEW
(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 "SkPathOpsPoint.h"
8 #include "Test.h"
9
10 const SkDPoint tests[] = {
11 {0, 0},
12 {1, 0},
13 {0, 1},
14 {2, 1},
15 {1, 2},
16 {1, 1},
17 {2, 2}
18 };
19
20 const size_t tests_count = sizeof(tests) / sizeof(tests[0]);
21 static size_t firstDPointTest = 0;
22
23 void DPointTest(skiatest::Reporter* reporter) {
24 for (size_t index = firstDPointTest; index < tests_count; ++index) {
25 const SkDPoint& pt = tests[index];
26 SkDPoint p = pt;
27 REPORTER_ASSERT(reporter, p == pt);
28 REPORTER_ASSERT(reporter, !(pt != pt));
29 SkDVector v = p - pt;
30 p += v;
31 REPORTER_ASSERT(reporter, p == pt);
32 p -= v;
33 REPORTER_ASSERT(reporter, p == pt);
34 REPORTER_ASSERT(reporter, p.approximatelyEqual(pt));
35 SkPoint sPt = pt.asSkPoint();
36 p.set(sPt);
37 REPORTER_ASSERT(reporter, p == pt);
38 REPORTER_ASSERT(reporter, p.approximatelyEqual(sPt));
39 REPORTER_ASSERT(reporter, p.roughlyEqual(pt));
40 REPORTER_ASSERT(reporter, p.moreRoughlyEqual(pt));
41 p.fX = p.fY = 0;
42 REPORTER_ASSERT(reporter, p.fX == 0 && p.fY == 0);
43 REPORTER_ASSERT(reporter, p.approximatelyZero());
44 REPORTER_ASSERT(reporter, pt.distanceSquared(p) == pt.fX * pt.fX + pt.fY * pt.fY);
45 REPORTER_ASSERT(reporter, approximately_equal(pt.distance(p),
46 sqrt(pt.fX * pt.fX + pt.fY * pt.fY)));
47 }
48 }
49
50 #include "TestClassDef.h"
51 DEFINE_TESTCLASS("PathOpsDPoint", PathOpsDPointClass, DPointTest)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698