Flutter Engine
The Flutter Engine
PathOpsDPointTest.cpp
Go to the documentation of this file.
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 */
12#include "tests/Test.h"
13
14#include <array>
15#include <cmath>
16#include <cstddef>
17
18static const SkDPoint tests[] = {
19 {0, 0},
20 {1, 0},
21 {0, 1},
22 {2, 1},
23 {1, 2},
24 {1, 1},
25 {2, 2}
26};
27
28static const size_t tests_count = std::size(tests);
29
30DEF_TEST(PathOpsDPoint, reporter) {
31 for (size_t index = 0; index < tests_count; ++index) {
32 const SkDPoint& pt = tests[index];
34 SkDPoint p = pt;
36 REPORTER_ASSERT(reporter, !(pt != pt));
37 SkDVector v = p - pt;
38 p += v;
40 p -= v;
42 REPORTER_ASSERT(reporter, p.approximatelyEqual(pt));
43 SkPoint sPt = pt.asSkPoint();
44 p.set(sPt);
46 REPORTER_ASSERT(reporter, p.approximatelyEqual(sPt));
47 REPORTER_ASSERT(reporter, p.roughlyEqual(pt));
48 p.fX = p.fY = 0;
49 REPORTER_ASSERT(reporter, p.fX == 0 && p.fY == 0);
50 REPORTER_ASSERT(reporter, p.approximatelyZero());
51 REPORTER_ASSERT(reporter, pt.distanceSquared(p) == pt.fX * pt.fX + pt.fY * pt.fY);
53 sqrt(pt.fX * pt.fX + pt.fY * pt.fY)));
54 }
55}
reporter
Definition: FontMgrTest.cpp:39
DEF_TEST(PathOpsDPoint, reporter)
static const size_t tests_count
static const SkDPoint tests[]
bool ValidPoint(const SkDPoint &pt)
#define SkASSERT(cond)
Definition: SkAssert.h:116
bool approximately_equal(double x, double y)
#define REPORTER_ASSERT(r, cond,...)
Definition: Test.h:286
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
Definition: SkVx.h:706
double distanceSquared(const SkDPoint &a) const
SkPoint asSkPoint() const
double distance(const SkDPoint &a) const