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

Unified Diff: ui/gfx/safe_integer_conversions_unittest.cc

Issue 109433013: Move geometric types to a separate, more lightweight target. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/safe_integer_conversions_unittest.cc
diff --git a/ui/gfx/safe_integer_conversions_unittest.cc b/ui/gfx/safe_integer_conversions_unittest.cc
deleted file mode 100644
index 1268f8bbf32ac7994f54fb7c35b14b1a96fc46f2..0000000000000000000000000000000000000000
--- a/ui/gfx/safe_integer_conversions_unittest.cc
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/gfx/safe_integer_conversions.h"
-
-#include <limits>
-
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace gfx {
-
-TEST(SafeIntegerConversions, ClampToInt) {
- EXPECT_EQ(0, ClampToInt(std::numeric_limits<float>::quiet_NaN()));
-
- float max = std::numeric_limits<int>::max();
- float min = std::numeric_limits<int>::min();
- float infinity = std::numeric_limits<float>::infinity();
-
- int int_max = std::numeric_limits<int>::max();
- int int_min = std::numeric_limits<int>::min();
-
- EXPECT_EQ(int_max, ClampToInt(infinity));
- EXPECT_EQ(int_max, ClampToInt(max));
- EXPECT_EQ(int_max, ClampToInt(max + 100));
-
- EXPECT_EQ(-100, ClampToInt(-100.5f));
- EXPECT_EQ(0, ClampToInt(0));
- EXPECT_EQ(100, ClampToInt(100.5f));
-
- EXPECT_EQ(int_min, ClampToInt(-infinity));
- EXPECT_EQ(int_min, ClampToInt(min));
- EXPECT_EQ(int_min, ClampToInt(min - 100));
-}
-
-TEST(SafeIntegerConversions, ToFlooredInt) {
- EXPECT_EQ(0, ToFlooredInt(std::numeric_limits<float>::quiet_NaN()));
-
- float max = std::numeric_limits<int>::max();
- float min = std::numeric_limits<int>::min();
- float infinity = std::numeric_limits<float>::infinity();
-
- int int_max = std::numeric_limits<int>::max();
- int int_min = std::numeric_limits<int>::min();
-
- EXPECT_EQ(int_max, ToFlooredInt(infinity));
- EXPECT_EQ(int_max, ToFlooredInt(max));
- EXPECT_EQ(int_max, ToFlooredInt(max + 100));
-
- EXPECT_EQ(-101, ToFlooredInt(-100.5f));
- EXPECT_EQ(0, ToFlooredInt(0));
- EXPECT_EQ(100, ToFlooredInt(100.5f));
-
- EXPECT_EQ(int_min, ToFlooredInt(-infinity));
- EXPECT_EQ(int_min, ToFlooredInt(min));
- EXPECT_EQ(int_min, ToFlooredInt(min - 100));
-}
-
-TEST(SafeIntegerConversions, ToCeiledInt) {
- EXPECT_EQ(0, ToCeiledInt(std::numeric_limits<float>::quiet_NaN()));
-
- float max = std::numeric_limits<int>::max();
- float min = std::numeric_limits<int>::min();
- float infinity = std::numeric_limits<float>::infinity();
-
- int int_max = std::numeric_limits<int>::max();
- int int_min = std::numeric_limits<int>::min();
-
- EXPECT_EQ(int_max, ToCeiledInt(infinity));
- EXPECT_EQ(int_max, ToCeiledInt(max));
- EXPECT_EQ(int_max, ToCeiledInt(max + 100));
-
- EXPECT_EQ(-100, ToCeiledInt(-100.5f));
- EXPECT_EQ(0, ToCeiledInt(0));
- EXPECT_EQ(101, ToCeiledInt(100.5f));
-
- EXPECT_EQ(int_min, ToCeiledInt(-infinity));
- EXPECT_EQ(int_min, ToCeiledInt(min));
- EXPECT_EQ(int_min, ToCeiledInt(min - 100));
-}
-
-TEST(SafeIntegerConversions, ToRoundedInt) {
- EXPECT_EQ(0, ToRoundedInt(std::numeric_limits<float>::quiet_NaN()));
-
- float max = std::numeric_limits<int>::max();
- float min = std::numeric_limits<int>::min();
- float infinity = std::numeric_limits<float>::infinity();
-
- int int_max = std::numeric_limits<int>::max();
- int int_min = std::numeric_limits<int>::min();
-
- EXPECT_EQ(int_max, ToRoundedInt(infinity));
- EXPECT_EQ(int_max, ToRoundedInt(max));
- EXPECT_EQ(int_max, ToRoundedInt(max + 100));
-
- EXPECT_EQ(-100, ToRoundedInt(-100.1f));
- EXPECT_EQ(-101, ToRoundedInt(-100.5f));
- EXPECT_EQ(-101, ToRoundedInt(-100.9f));
- EXPECT_EQ(0, ToRoundedInt(0));
- EXPECT_EQ(100, ToRoundedInt(100.1f));
- EXPECT_EQ(101, ToRoundedInt(100.5f));
- EXPECT_EQ(101, ToRoundedInt(100.9f));
-
- EXPECT_EQ(int_min, ToRoundedInt(-infinity));
- EXPECT_EQ(int_min, ToRoundedInt(min));
- EXPECT_EQ(int_min, ToRoundedInt(min - 100));
-}
-
-} // namespace gfx
« ui/aura/aura.gyp ('K') | « ui/gfx/safe_integer_conversions.h ('k') | ui/gfx/size.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698