2 * Copyright 2012 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
7 #include "PathOpsTestCommon.h"
8 #include "SkPathOpsPoint.h"
11 static const SkDPoint tests[] = {
21 static const size_t tests_count = SK_ARRAY_COUNT(tests);
23 DEF_TEST(PathOpsDPoint, reporter) {
24 for (size_t index = 0; index < tests_count; ++index) {
25 const SkDPoint& pt = tests[index];
26 SkASSERT(ValidPoint(pt));
28 REPORTER_ASSERT(reporter, p == pt);
29 REPORTER_ASSERT(reporter, !(pt != pt));
32 REPORTER_ASSERT(reporter, p == pt);
34 REPORTER_ASSERT(reporter, p == pt);
35 REPORTER_ASSERT(reporter, p.approximatelyEqual(pt));
36 SkPoint sPt = pt.asSkPoint();
38 REPORTER_ASSERT(reporter, p == pt);
39 REPORTER_ASSERT(reporter, p.approximatelyEqual(sPt));
40 REPORTER_ASSERT(reporter, p.roughlyEqual(pt));
41 REPORTER_ASSERT(reporter, p.moreRoughlyEqual(pt));
43 REPORTER_ASSERT(reporter, p.fX == 0 && p.fY == 0);
44 REPORTER_ASSERT(reporter, p.approximatelyZero());
45 REPORTER_ASSERT(reporter, pt.distanceSquared(p) == pt.fX * pt.fX + pt.fY * pt.fY);
46 REPORTER_ASSERT(reporter, approximately_equal(pt.distance(p),
47 sqrt(pt.fX * pt.fX + pt.fY * pt.fY)));