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

Side by Side Diff: tests/PathOpsDVectorTest.cpp

Issue 117863005: Get rid of DEFINE_TESTCLASS_SHORT() macro. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Mike review Created 6 years, 11 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/PathOpsDTriangleTest.cpp ('k') | tests/PathOpsInverseTest.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 "SkPathOpsPoint.h" 8 #include "SkPathOpsPoint.h"
9 #include "Test.h" 9 #include "Test.h"
10 #include "TestClassDef.h"
10 11
11 static const SkDPoint tests[] = { 12 static const SkDPoint tests[] = {
12 {0, 0}, 13 {0, 0},
13 {1, 0}, 14 {1, 0},
14 {0, 1}, 15 {0, 1},
15 {2, 1}, 16 {2, 1},
16 {1, 2}, 17 {1, 2},
17 {1, 1}, 18 {1, 1},
18 {2, 2} 19 {2, 2}
19 }; 20 };
20 21
21 static const size_t tests_count = SK_ARRAY_COUNT(tests); 22 static const size_t tests_count = SK_ARRAY_COUNT(tests);
22 23
23 static void PathOpsDVectorTest(skiatest::Reporter* reporter) { 24 DEF_TEST(PathOpsDVector, reporter) {
24 for (size_t index = 0; index < tests_count - 1; ++index) { 25 for (size_t index = 0; index < tests_count - 1; ++index) {
25 SkDVector v1 = tests[index + 1] - tests[index]; 26 SkDVector v1 = tests[index + 1] - tests[index];
26 SkASSERT(ValidVector(v1)); 27 SkASSERT(ValidVector(v1));
27 SkDVector v2 = tests[index] - tests[index + 1]; 28 SkDVector v2 = tests[index] - tests[index + 1];
28 SkASSERT(ValidVector(v2)); 29 SkASSERT(ValidVector(v2));
29 v1 += v2; 30 v1 += v2;
30 REPORTER_ASSERT(reporter, v1.fX == 0 && v1.fY == 0); 31 REPORTER_ASSERT(reporter, v1.fX == 0 && v1.fY == 0);
31 SkDPoint p = tests[index + 1] + v2; 32 SkDPoint p = tests[index + 1] + v2;
32 REPORTER_ASSERT(reporter, p == tests[index]); 33 REPORTER_ASSERT(reporter, p == tests[index]);
33 v2 -= v2; 34 v2 -= v2;
34 REPORTER_ASSERT(reporter, v2.fX == 0 && v2.fY == 0); 35 REPORTER_ASSERT(reporter, v2.fX == 0 && v2.fY == 0);
35 v1 = tests[index + 1] - tests[index]; 36 v1 = tests[index + 1] - tests[index];
36 v1 /= 2; 37 v1 /= 2;
37 v1 *= 2; 38 v1 *= 2;
38 v1 -= tests[index + 1] - tests[index]; 39 v1 -= tests[index + 1] - tests[index];
39 REPORTER_ASSERT(reporter, v1.fX == 0 && v1.fY == 0); 40 REPORTER_ASSERT(reporter, v1.fX == 0 && v1.fY == 0);
40 SkVector sv = v1.asSkVector(); 41 SkVector sv = v1.asSkVector();
41 REPORTER_ASSERT(reporter, sv.fX == 0 && sv.fY == 0); 42 REPORTER_ASSERT(reporter, sv.fX == 0 && sv.fY == 0);
42 v1 = tests[index + 1] - tests[index]; 43 v1 = tests[index + 1] - tests[index];
43 double lenSq = v1.lengthSquared(); 44 double lenSq = v1.lengthSquared();
44 double v1Dot = v1.dot(v1); 45 double v1Dot = v1.dot(v1);
45 REPORTER_ASSERT(reporter, lenSq == v1Dot); 46 REPORTER_ASSERT(reporter, lenSq == v1Dot);
46 REPORTER_ASSERT(reporter, approximately_equal(sqrt(lenSq), v1.length())) ; 47 REPORTER_ASSERT(reporter, approximately_equal(sqrt(lenSq), v1.length())) ;
47 double v1Cross = v1.cross(v1); 48 double v1Cross = v1.cross(v1);
48 REPORTER_ASSERT(reporter, v1Cross == 0); 49 REPORTER_ASSERT(reporter, v1Cross == 0);
49 } 50 }
50 } 51 }
51
52 #include "TestClassDef.h"
53 DEFINE_TESTCLASS_SHORT(PathOpsDVectorTest)
OLDNEW
« no previous file with comments | « tests/PathOpsDTriangleTest.cpp ('k') | tests/PathOpsInverseTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698