Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
InfRectTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2011 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
12#include "tests/Test.h"
13
14#include <array>
15#include <cstddef>
16
19 SkRect rect;
20 rect.setLTRB(l, t, r, b);
21 REPORTER_ASSERT(reporter, !rect.isFinite());
22}
23
24// Tests that isFinite() will reject any rect with +/-inf values
25// as one of its coordinates.
26DEF_TEST(InfRect, reporter) {
27 float inf = SK_FloatInfinity;
28 float nan = SK_FloatNaN;
29 SkASSERT(!(nan == nan));
30 SkScalar small = SkIntToScalar(10);
31 SkScalar big = SkIntToScalar(100);
32
34
35 SkRect rect = SkRect::MakeXYWH(small, small, big, big);
36 REPORTER_ASSERT(reporter, rect.isFinite());
37
38 const SkScalar invalid[] = { nan, inf, -inf };
39 for (size_t i = 0; i < std::size(invalid); ++i) {
40 check_invalid(reporter, small, small, big, invalid[i]);
41 check_invalid(reporter, small, small, invalid[i], big);
42 check_invalid(reporter, small, invalid[i], big, big);
43 check_invalid(reporter, invalid[i], small, big, big);
44 }
45}
46
47// need tests for SkStrSearch
static bool invalid(const SkISize &size)
reporter
static void check_invalid(skiatest::Reporter *reporter, SkScalar l, SkScalar t, SkScalar r, SkScalar b)
static bool isFinite(const SkRect &r)
#define SkASSERT(cond)
Definition SkAssert.h:116
constexpr float SK_FloatInfinity
constexpr float SK_FloatNaN
#define SkIntToScalar(x)
Definition SkScalar.h:57
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
float SkScalar
Definition extension.cpp:12
static bool b
static constexpr SkRect MakeEmpty()
Definition SkRect.h:595
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
Definition SkRect.h:659