OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/safe_integer_conversions.h" | 5 #include "ui/gfx/geometry/safe_integer_conversions.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace gfx { | 11 namespace gfx { |
12 | 12 |
13 TEST(SafeIntegerConversions, ClampToInt) { | 13 TEST(SafeIntegerConversions, ClampToInt) { |
14 EXPECT_EQ(0, ClampToInt(std::numeric_limits<float>::quiet_NaN())); | 14 EXPECT_EQ(0, ClampToInt(std::numeric_limits<float>::quiet_NaN())); |
15 | 15 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 EXPECT_EQ(100, ToRoundedInt(100.1f)); | 100 EXPECT_EQ(100, ToRoundedInt(100.1f)); |
101 EXPECT_EQ(101, ToRoundedInt(100.5f)); | 101 EXPECT_EQ(101, ToRoundedInt(100.5f)); |
102 EXPECT_EQ(101, ToRoundedInt(100.9f)); | 102 EXPECT_EQ(101, ToRoundedInt(100.9f)); |
103 | 103 |
104 EXPECT_EQ(int_min, ToRoundedInt(-infinity)); | 104 EXPECT_EQ(int_min, ToRoundedInt(-infinity)); |
105 EXPECT_EQ(int_min, ToRoundedInt(min)); | 105 EXPECT_EQ(int_min, ToRoundedInt(min)); |
106 EXPECT_EQ(int_min, ToRoundedInt(min - 100)); | 106 EXPECT_EQ(int_min, ToRoundedInt(min - 100)); |
107 } | 107 } |
108 | 108 |
109 } // namespace gfx | 109 } // namespace gfx |
OLD | NEW |