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

Unified Diff: base/numerics/safe_numerics_unittest.cc

Issue 1164063005: Replace gfx::ClampToInt with base::saturated_cast. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: clamp: . 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 side-by-side diff with in-line comments
Download patch
Index: base/numerics/safe_numerics_unittest.cc
diff --git a/base/numerics/safe_numerics_unittest.cc b/base/numerics/safe_numerics_unittest.cc
index b8098c40a8fe067e4812d0024694defb7203b5c9..6f9a966c0156431e654e71d483d81083fe555690 100644
--- a/base/numerics/safe_numerics_unittest.cc
+++ b/base/numerics/safe_numerics_unittest.cc
@@ -562,6 +562,8 @@ TEST(SafeNumerics, CastTests) {
double double_small = 1.0;
double double_large = numeric_limits<double>::max();
double double_infinity = numeric_limits<float>::infinity();
+ double double_large_int = numeric_limits<int>::max();
+ double double_small_int = numeric_limits<int>::min();
// Just test that the casts compile, since the other tests cover logic.
EXPECT_EQ(0, checked_cast<int>(static_cast<size_t>(0)));
@@ -594,5 +596,7 @@ TEST(SafeNumerics, CastTests) {
EXPECT_EQ(saturated_cast<int>(double_large), numeric_limits<int>::max());
EXPECT_EQ(saturated_cast<float>(double_large), double_infinity);
EXPECT_EQ(saturated_cast<float>(-double_large), -double_infinity);
+ EXPECT_EQ(numeric_limits<int>::min(), saturated_cast<int>(double_small_int));
+ EXPECT_EQ(numeric_limits<int>::max(), saturated_cast<int>(double_large_int));
}
« no previous file with comments | « base/numerics/safe_conversions_impl.h ('k') | chrome/browser/ui/views/extensions/bookmark_app_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698