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

Side by Side Diff: tests/PathOpsDVectorTest.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
« tests/PathOpsDLineTest.cpp ('K') | « tests/PathOpsDTriangleTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 firstDVectorTest = 0;
22
23 void DVectorTest(skiatest::Reporter* reporter) {
24 for (size_t index = firstDVectorTest; index < tests_count - 1; ++index) {
25 SkDVector v1 = tests[index + 1] - tests[index];
26 SkDVector v2 = tests[index] - tests[index + 1];
27 v1 += v2;
28 REPORTER_ASSERT(reporter, v1.fX == 0 && v1.fY == 0);
29 SkDPoint p = tests[index + 1] + v2;
30 REPORTER_ASSERT(reporter, p == tests[index]);
31 v2 -= v2;
32 REPORTER_ASSERT(reporter, v2.fX == 0 && v2.fY == 0);
33 v1 = tests[index + 1] - tests[index];
34 v1 /= 2;
35 v1 *= 2;
36 v1 -= tests[index + 1] - tests[index];
37 REPORTER_ASSERT(reporter, v1.fX == 0 && v1.fY == 0);
38 SkVector sv = v1.asSkVector();
39 REPORTER_ASSERT(reporter, sv.fX == 0 && sv.fY == 0);
40 v1 = tests[index + 1] - tests[index];
41 double lenSq = v1.lengthSquared();
42 double v1Dot = v1.dot(v1);
43 REPORTER_ASSERT(reporter, lenSq == v1Dot);
44 REPORTER_ASSERT(reporter, approximately_equal(sqrt(lenSq), v1.length())) ;
45 double v1Cross = v1.cross(v1);
46 REPORTER_ASSERT(reporter, v1Cross == 0);
47 }
48 }
49
50 #include "TestClassDef.h"
51 DEFINE_TESTCLASS("PathOpsDVector", PathOpsDVectorClass, DVectorTest)
OLDNEW
« tests/PathOpsDLineTest.cpp ('K') | « tests/PathOpsDTriangleTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698