Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: third_party/WebKit/Source/platform/geometry/FloatQuadTest.cpp

Issue 2733503002: Fix the conditional operator's usage (Closed)
Patch Set: add unittests. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/geometry/FloatQuad.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/geometry/FloatQuad.h" 5 #include "platform/geometry/FloatQuad.h"
6 6
7 #include <limits>
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 #include "wtf/text/WTFString.h" 9 #include "wtf/text/WTFString.h"
9 10
10 namespace blink { 11 namespace blink {
11 12
12 TEST(FloatQuadTest, ToString) { 13 TEST(FloatQuadTest, ToString) {
13 FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13), 14 FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13),
14 FloatPoint(17, 19)); 15 FloatPoint(17, 19));
15 EXPECT_EQ("2,3; 5,7; 11,13; 17,19", quad.toString()); 16 EXPECT_EQ("2,3; 5,7; 11,13; 17,19", quad.toString());
16 } 17 }
17 18
19 TEST(FloatQuadTest, BoundingBox) {
20 FloatQuad quad(FloatPoint(2, 3), FloatPoint(5, 7), FloatPoint(11, 13),
21 FloatPoint(17, 19));
22 FloatRect rect = quad.boundingBox();
23 EXPECT_EQ(rect.x(), 2);
24 EXPECT_EQ(rect.y(), 3);
25 EXPECT_EQ(rect.width(), 17 - 2);
26 EXPECT_EQ(rect.height(), 19 - 3);
27 }
28
29 TEST(FloatQuadTest, BoundingBoxSaturateInf) {
30 double inf = std::numeric_limits<double>::infinity();
31 FloatQuad quad(FloatPoint(-inf, 3), FloatPoint(5, inf), FloatPoint(11, 13),
32 FloatPoint(17, 19));
33 FloatRect rect = quad.boundingBox();
34 EXPECT_EQ(rect.x(), std::numeric_limits<int>::min());
35 EXPECT_EQ(rect.y(), 3.0f);
36 EXPECT_EQ(rect.width(), 17.0f - std::numeric_limits<int>::min());
37 EXPECT_EQ(rect.height(), std::numeric_limits<int>::max() - 3.0f);
38 }
18 } // namespace blink 39 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/geometry/FloatQuad.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698