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

Side by Side Diff: ui/gfx/geometry/rect_unittest.cc

Issue 1186133003: gfx: Fix ToEnclosing/ToEnclosed math to deal with big numbers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move function 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
« ui/gfx/geometry/rect.h ('K') | « ui/gfx/geometry/rect_conversions.cc ('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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <limits> 5 #include <limits>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/geometry/rect.h" 9 #include "ui/gfx/geometry/rect.h"
10 #include "ui/gfx/geometry/rect_conversions.h" 10 #include "ui/gfx/geometry/rect_conversions.h"
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 EXPECT_FLOAT_EQ( 903 EXPECT_FLOAT_EQ(
904 0.0f, f.ManhattanInternalDistance(gfx::RectF(-1.0f, 0.0f, 1.1f, 1.0f))); 904 0.0f, f.ManhattanInternalDistance(gfx::RectF(-1.0f, 0.0f, 1.1f, 1.0f)));
905 EXPECT_FLOAT_EQ( 905 EXPECT_FLOAT_EQ(
906 0.1f + kEpsilon, 906 0.1f + kEpsilon,
907 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.4f, 1.0f))); 907 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.4f, 1.0f)));
908 EXPECT_FLOAT_EQ( 908 EXPECT_FLOAT_EQ(
909 kEpsilon, 909 kEpsilon,
910 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.5f, 1.0f))); 910 f.ManhattanInternalDistance(gfx::RectF(-1.5f, 0.0f, 1.5f, 1.0f)));
911 } 911 }
912 912
913 TEST(RectTest, SafelyScaleToEnclosingRect) {
914 {
915 Rect input(1, 2, 3, 4);
916 Rect result = SafelyScaleToEnclosingRect(input, 5.f);
917 EXPECT_EQ(Rect(5, 10, 15, 20), result);
918 }
919 {
920 Rect input(-1, -2, 3, 4);
921 Rect result = SafelyScaleToEnclosingRect(input, 0.5f);
922 EXPECT_EQ(Rect(-1, -1, 2, 2), result);
923 }
924 {
925 Rect input(0, 0, std::numeric_limits<int>::max() / 2,
926 std::numeric_limits<int>::max());
927 Rect result = SafelyScaleToEnclosingRect(input, 2.f);
928 EXPECT_EQ(Rect(0, 0, std::numeric_limits<int>::max(),
929 std::numeric_limits<int>::max()),
930 result);
931 }
932 {
933 Rect input(std::numeric_limits<int>::min() / 2,
934 std::numeric_limits<int>::min() / 2,
935 std::numeric_limits<int>::max(),
936 std::numeric_limits<int>::max());
937 Rect result = SafelyScaleToEnclosingRect(input, 2.f);
938 EXPECT_EQ(
939 Rect(std::numeric_limits<int>::min(), std::numeric_limits<int>::min(),
940 std::numeric_limits<int>::max(), std::numeric_limits<int>::max()),
941 result);
942 }
943 {
944 Rect input(std::numeric_limits<int>::max() / 2,
945 std::numeric_limits<int>::max() / 2,
946 std::numeric_limits<int>::max(),
947 std::numeric_limits<int>::max());
948 Rect result = SafelyScaleToEnclosingRect(input, 2.f);
949 EXPECT_EQ(Rect(std::numeric_limits<int>::max(),
950 std::numeric_limits<int>::max(), 0, 0),
951 result);
952 }
953 }
954
955
913 } // namespace gfx 956 } // namespace gfx
OLDNEW
« ui/gfx/geometry/rect.h ('K') | « ui/gfx/geometry/rect_conversions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698