Flutter Engine
Loading...
Searching...
No Matches
rational_unittests.cc
Go to the documentation of this file.
1
// Copyright 2013 The Flutter Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
#include "
flutter/impeller/geometry/rational.h
"
6
7
#include "gtest/gtest.h"
8
9
namespace
impeller
{
10
11
TEST
(RationalTest, Make) {
12
Rational
value
(1, 2);
13
EXPECT_EQ(
value
.GetNumerator(), 1);
14
EXPECT_EQ(
value
.GetDenominator(), 2u);
15
}
16
17
TEST
(RationalTest, EqualsSameDen) {
18
EXPECT_TRUE(
Rational
(1, 2) ==
Rational
(1, 2));
19
}
20
21
TEST
(RationalTest, NotEqualsSameDen) {
22
EXPECT_FALSE(
Rational
(3, 2) ==
Rational
(1, 2));
23
}
24
25
TEST
(RationalTest, EqualsDifferentDen) {
26
EXPECT_TRUE(
Rational
(1, 2) ==
Rational
(2, 4));
27
}
28
29
TEST
(RationalTest, NegationNotEquals) {
30
EXPECT_FALSE(
Rational
(1, 2) ==
Rational
(-1, 2));
31
}
32
33
TEST
(RationalTest, LessThanSameDen) {
34
EXPECT_TRUE(
Rational
(1, 2) <
Rational
(2, 2));
35
}
36
37
TEST
(RationalTest, LessThanNegation) {
38
EXPECT_TRUE(
Rational
(-1, 2) <
Rational
(2, 23));
39
}
40
41
TEST
(RationalTest, LessThanDifferentDen) {
42
EXPECT_TRUE(
Rational
(1, 2) <
Rational
(25, 23));
43
}
44
45
TEST
(RationalTest, NotLessThanDifferentDen) {
46
EXPECT_FALSE(
Rational
(25, 23) <
Rational
(1, 2));
47
}
48
49
TEST
(RationalTest, SameHashes) {
50
EXPECT_EQ(
Rational
(1, 2).GetHash(),
Rational
(2, 4).GetHash());
51
}
52
53
TEST
(RationalTest, DifferentHashes) {
54
EXPECT_NE(
Rational
(2, 2).GetHash(),
Rational
(2, 4).GetHash());
55
}
56
57
}
// namespace impeller
impeller::Rational
Definition
rational.h:13
value
int32_t value
Definition
dl_golden_unittests.cc:459
impeller
Definition
texture.h:16
impeller::TEST
TEST(RationalTest, Make)
Definition
rational_unittests.cc:11
rational.h
impeller
geometry
rational_unittests.cc
Generated on Thu Nov 6 2025 16:11:23 for Flutter Engine by
1.9.8