7#include "gtest/gtest.h"
19 EXPECT_EQ(
static_cast<float>(
a.
x()),
b.x());
20 EXPECT_EQ(
static_cast<float>(
a.
y()),
b.y());
24 EXPECT_FALSE(
Point(1, 0).IsOrigin());
25 EXPECT_FALSE(
Point(0, 1).IsOrigin());
26 EXPECT_FALSE(
Point(1, 2).IsOrigin());
27 EXPECT_FALSE(
Point(-1, 0).IsOrigin());
28 EXPECT_FALSE(
Point(0, -1).IsOrigin());
29 EXPECT_FALSE(
Point(-1, -2).IsOrigin());
32 EXPECT_FALSE(
PointF(0.1f, 0).IsOrigin());
33 EXPECT_FALSE(
PointF(0, 0.1f).IsOrigin());
34 EXPECT_FALSE(
PointF(0.1f, 2).IsOrigin());
35 EXPECT_FALSE(
PointF(-0.1f, 0).IsOrigin());
36 EXPECT_FALSE(
PointF(0, -0.1f).IsOrigin());
37 EXPECT_FALSE(
PointF(-0.1f, -2).IsOrigin());
41TEST(PointTest, VectorArithmetic) {
57 for (
size_t i = 0;
i < 7; ++
i)
58 EXPECT_EQ(
tests[
i].expected.ToString(),
tests[
i].actual.ToString());
61TEST(PointTest, OffsetFromPoint) {
139 a.SetToMax(
PointF(2.5f, 4.5f));
141 a.SetToMax(
PointF(3.5f, 5.5f));
143 a.SetToMax(
PointF(4.5f, 2.5f));
145 a.SetToMax(
PointF(8.5f, 10.5f));
148 a.SetToMin(
PointF(9.5f, 11.5f));
150 a.SetToMin(
PointF(8.5f, 10.5f));
152 a.SetToMin(
PointF(11.5f, 9.5f));
154 a.SetToMin(
PointF(7.5f, 11.5f));
156 a.SetToMin(
PointF(3.5f, 5.5f));
173 EXPECT_EQ(test2,
Point(-2, 12));
176TEST(PointTest, IntegerOverflow) {
180 Point max_point(int_max, int_max);
181 Point min_point(int_min, int_min);
185 test.Offset(int_max, int_max);
186 EXPECT_EQ(
test, max_point);
189 test.Offset(int_min, int_min);
190 EXPECT_EQ(
test, min_point);
193 test.Offset(int_max, int_max);
194 EXPECT_EQ(
test, max_point);
197 test.Offset(int_min, int_min);
198 EXPECT_EQ(
test, min_point);
202 EXPECT_EQ(
test, max_point);
206 EXPECT_EQ(
test, min_point);
210 EXPECT_EQ(
test, max_point);
214 EXPECT_EQ(
test, min_point);
218 EXPECT_EQ(
test,
Point(-int_max, -int_max));
222 EXPECT_EQ(
test, max_point);
226 EXPECT_EQ(
test, max_point);
230 EXPECT_EQ(
test, min_point);
std::string ToString() const
static float max(float r, float g, float b)
static float min(float r, float g, float b)
Point ToRoundedPoint(const PointF &point)
PointF ScalePoint(const PointF &p, float x_scale, float y_scale)
TEST(PointTest, ToPointF)
static std::string ToString(CompilerBackend::Type type)
#define EXPECT_TRUE(handle)