| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
| 6 #include "platform/geometry/FloatSize.h" | 6 #include "platform/geometry/FloatSize.h" |
| 7 | 7 |
| 8 #include "platform/geometry/GeometryTestHelpers.h" | 8 #include "platform/geometry/GeometryTestHelpers.h" |
| 9 | |
| 10 #include <gtest/gtest.h> | 9 #include <gtest/gtest.h> |
| 11 | 10 |
| 12 using namespace blink; | 11 namespace blink { |
| 13 | |
| 14 namespace { | |
| 15 | 12 |
| 16 TEST(FloatSizeTest, DiagonalLengthTest) | 13 TEST(FloatSizeTest, DiagonalLengthTest) |
| 17 { | 14 { |
| 18 // Sanity check the Pythagorean triples 3-4-5 and 5-12-13 | 15 // Sanity check the Pythagorean triples 3-4-5 and 5-12-13 |
| 19 FloatSize s1 = FloatSize(3.f, 4.f); | 16 FloatSize s1 = FloatSize(3.f, 4.f); |
| 20 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, s1.diagonalLength(), 5.
f); | 17 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, s1.diagonalLength(), 5.
f); |
| 21 FloatSize s2 = FloatSize(5.f, 12.f); | 18 FloatSize s2 = FloatSize(5.f, 12.f); |
| 22 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, s2.diagonalLength(), 13
.f); | 19 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, s2.diagonalLength(), 13
.f); |
| 23 | 20 |
| 24 // Test very small numbers. | 21 // Test very small numbers. |
| 25 FloatSize s3 = FloatSize(.5e-20f, .5e-20f); | 22 FloatSize s3 = FloatSize(.5e-20f, .5e-20f); |
| 26 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, s3.diagonalLength(), .7
07106781186548e-20f); | 23 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, s3.diagonalLength(), .7
07106781186548e-20f); |
| 27 | 24 |
| 28 // Test very large numbers. | 25 // Test very large numbers. |
| 29 FloatSize s4 = FloatSize(.5e20f, .5e20f); | 26 FloatSize s4 = FloatSize(.5e20f, .5e20f); |
| 30 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, s4.diagonalLength(), .7
07106781186548e20f); | 27 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, s4.diagonalLength(), .7
07106781186548e20f); |
| 31 } | 28 } |
| 32 | 29 |
| 33 } | 30 } // namespace blink |
| OLD | NEW |