Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PathOpsDLineTest.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 */
13#include "tests/Test.h"
14
15#include <array>
16#include <cstddef>
17
18static const SkDLine tests[] = {
19 {{{2, 1}, {2, 1}}},
20 {{{2, 1}, {1, 1}}},
21 {{{2, 1}, {2, 2}}},
22 {{{1, 1}, {2, 2}}},
23 {{{3, 0}, {2, 1}}},
24 {{{3, 2}, {1, 1}}},
25};
26
27static const size_t tests_count = std::size(tests);
28
29DEF_TEST(PathOpsLineUtilities, reporter) {
30 for (size_t index = 0; index < tests_count; ++index) {
31 const SkDLine& line = tests[index];
32 SkASSERT(ValidLine(line));
33 SkDLine line2;
34 SkPoint pts[2] = {line[0].asSkPoint(), line[1].asSkPoint()};
35 line2.set(pts);
36 REPORTER_ASSERT(reporter, line[0] == line2[0] && line[1] == line2[1]);
37 SkDPoint mid = line.ptAtT(.5);
38 REPORTER_ASSERT(reporter, approximately_equal((line[0].fX + line[1].fX) / 2, mid.fX));
39 REPORTER_ASSERT(reporter, approximately_equal((line[0].fY + line[1].fY) / 2, mid.fY));
40 }
41}
reporter
static const SkDLine tests[]
static const size_t tests_count
bool ValidLine(const SkDLine &line)
#define SkASSERT(cond)
Definition SkAssert.h:116
bool approximately_equal(double x, double y)
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
const SkDLine & set(const SkPoint pts[2])