OLD | NEW |
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/FloatRect.h" | 5 #include "platform/geometry/FloatRect.h" |
6 | 6 |
7 #include "platform/geometry/FloatPoint.h" | 7 #include "platform/geometry/FloatPoint.h" |
8 #include "platform/geometry/GeometryTestHelpers.h" | 8 #include "platform/geometry/GeometryTestHelpers.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "wtf/text/WTFString.h" | 10 #include "wtf/text/WTFString.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 // `8` case | 106 // `8` case |
107 FloatPoint p23(180, 300); | 107 FloatPoint p23(180, 300); |
108 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p2
3), 2500.f); | 108 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p2
3), 2500.f); |
109 | 109 |
110 // `9` case | 110 // `9` case |
111 FloatPoint p24(450, 450); | 111 FloatPoint p24(450, 450); |
112 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p2
4), 50000.f); | 112 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, r1.squaredDistanceTo(p2
4), 50000.f); |
113 } | 113 } |
114 | 114 |
115 #ifndef NDEBUG | |
116 TEST(FloatRectTest, ToString) | 115 TEST(FloatRectTest, ToString) |
117 { | 116 { |
118 FloatRect emptyRect = FloatRect(); | 117 FloatRect emptyRect = FloatRect(); |
119 EXPECT_EQ(String("0.000000,0.000000 0.000000x0.000000"), emptyRect.toString(
)); | 118 EXPECT_EQ("0,0 0x0", emptyRect.toString()); |
120 | 119 |
121 FloatRect rect(1, 2, 3, 4); | 120 FloatRect rect(1, 2, 3, 4); |
122 EXPECT_EQ(String("1.000000,2.000000 3.000000x4.000000"), rect.toString()); | 121 EXPECT_EQ("1,2 3x4", rect.toString()); |
123 | 122 |
124 FloatRect granularRect(1.6f, 2.7f, 3.8f, 4.9f); | 123 FloatRect granularRect(1.6f, 2.7f, 3.8f, 4.9f); |
125 EXPECT_EQ(String("1.600000,2.700000 3.800000x4.900000"), granularRect.toStri
ng()); | 124 EXPECT_EQ("1.6,2.7 3.8x4.9", granularRect.toString()); |
| 125 |
| 126 FloatRect minMaxRect(std::numeric_limits<float>::min(), std::numeric_limits<
float>::max(), std::numeric_limits<float>::min(), std::numeric_limits<float>::ma
x()); |
| 127 EXPECT_EQ("1.17549e-38,3.40282e+38 1.17549e-38x3.40282e+38", minMaxRect.toSt
ring()); |
| 128 |
| 129 FloatRect infiniteRect(-std::numeric_limits<float>::infinity(), -std::numeri
c_limits<float>::infinity(), std::numeric_limits<float>::infinity(), std::numeri
c_limits<float>::infinity()); |
| 130 EXPECT_EQ("-inf,-inf infxinf", infiniteRect.toString()); |
| 131 |
| 132 FloatRect nanRect(0, 0, std::numeric_limits<float>::signaling_NaN(), std::nu
meric_limits<float>::signaling_NaN()); |
| 133 EXPECT_EQ("0,0 nanxnan", nanRect.toString()); |
126 } | 134 } |
127 #endif | |
128 | 135 |
129 } // namespace blink | 136 } // namespace blink |
OLD | NEW |