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

Side by Side Diff: Source/platform/geometry/FloatPointTest.cpp

Issue 1182703002: Fix unit test style in Source/platform/, part 1. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
OLDNEW
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/FloatPoint.h" 6 #include "platform/geometry/FloatPoint.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(FloatPointTest, LengthTest) 13 TEST(FloatPointTest, LengthTest)
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 FloatPoint p1 = FloatPoint(3.f, 4.f); 16 FloatPoint p1 = FloatPoint(3.f, 4.f);
20 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, p1.length(), 5.f); 17 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, p1.length(), 5.f);
21 FloatPoint p2 = FloatPoint(5.f, 12.f); 18 FloatPoint p2 = FloatPoint(5.f, 12.f);
22 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, p2.length(), 13.f); 19 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, p2.length(), 13.f);
23 20
24 // Test very small numbers. This fails under the old implementation of 21 // Test very small numbers. This fails under the old implementation of
25 // FloatPoint::length(): `return sqrtf(lengthSquared());' 22 // FloatPoint::length(): `return sqrtf(lengthSquared());'
26 FloatPoint p3 = FloatPoint(.5e-20f, .5e-20f); 23 FloatPoint p3 = FloatPoint(.5e-20f, .5e-20f);
27 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, p3.length(), .707106781 186548e-20f); 24 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, p3.length(), .707106781 186548e-20f);
28 25
29 // Test very large numbers. 26 // Test very large numbers.
30 FloatPoint p4 = FloatPoint(.5e20f, .5e20f); 27 FloatPoint p4 = FloatPoint(.5e20f, .5e20f);
31 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, p4.length(), .707106781 186548e20f); 28 EXPECT_PRED_FORMAT2(GeometryTest::AssertAlmostEqual, p4.length(), .707106781 186548e20f);
32 } 29 }
33 30
34 } 31 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698