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

Side by Side Diff: base/numerics/safe_numerics_unittest.cc

Issue 2213933003: Change EXPECT/ASSERT_DCHECK_DEATH macro to not expose the |regex| parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@b2b0_simplethreadJoinable
Patch Set: Disabling a death test which crashed instead of DCHECKing : http://crbug.com/634552 Created 4 years, 4 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
« no previous file with comments | « base/metrics/sample_vector_unittest.cc ('k') | base/synchronization/atomic_flag_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <limits> 8 #include <limits>
9 #include <type_traits> 9 #include <type_traits>
10 10
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 std::numeric_limits<float>::infinity(); 649 std::numeric_limits<float>::infinity();
650 EXPECT_TRUE(std::isnan(not_a_number)); 650 EXPECT_TRUE(std::isnan(not_a_number));
651 EXPECT_EQ(0, saturated_cast<int>(not_a_number)); 651 EXPECT_EQ(0, saturated_cast<int>(not_a_number));
652 } 652 }
653 653
654 TEST(SafeNumerics, SaturatedCastChecks) { 654 TEST(SafeNumerics, SaturatedCastChecks) {
655 float not_a_number = std::numeric_limits<float>::infinity() - 655 float not_a_number = std::numeric_limits<float>::infinity() -
656 std::numeric_limits<float>::infinity(); 656 std::numeric_limits<float>::infinity();
657 EXPECT_TRUE(std::isnan(not_a_number)); 657 EXPECT_TRUE(std::isnan(not_a_number));
658 EXPECT_DCHECK_DEATH( 658 EXPECT_DCHECK_DEATH(
659 (saturated_cast<int, base::SaturatedCastNaNBehaviorCheck>(not_a_number)), 659 (saturated_cast<int, base::SaturatedCastNaNBehaviorCheck>(not_a_number)));
660 "");
661 } 660 }
662 661
663 TEST(SafeNumerics, IsValueInRangeForNumericType) { 662 TEST(SafeNumerics, IsValueInRangeForNumericType) {
664 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(0)); 663 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(0));
665 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(1)); 664 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(1));
666 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(2)); 665 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(2));
667 EXPECT_FALSE(IsValueInRangeForNumericType<uint32_t>(-1)); 666 EXPECT_FALSE(IsValueInRangeForNumericType<uint32_t>(-1));
668 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(0xffffffffu)); 667 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(0xffffffffu));
669 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(UINT64_C(0xffffffff))); 668 EXPECT_TRUE(IsValueInRangeForNumericType<uint32_t>(UINT64_C(0xffffffff)));
670 EXPECT_FALSE(IsValueInRangeForNumericType<uint32_t>(UINT64_C(0x100000000))); 669 EXPECT_FALSE(IsValueInRangeForNumericType<uint32_t>(UINT64_C(0x100000000)));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 750
752 CheckedNumeric<int> too_large = std::numeric_limits<int>::max(); 751 CheckedNumeric<int> too_large = std::numeric_limits<int>::max();
753 EXPECT_TRUE(too_large.IsValid()); 752 EXPECT_TRUE(too_large.IsValid());
754 too_large += d; 753 too_large += d;
755 EXPECT_FALSE(too_large.IsValid()); 754 EXPECT_FALSE(too_large.IsValid());
756 too_large -= d; 755 too_large -= d;
757 EXPECT_FALSE(too_large.IsValid()); 756 EXPECT_FALSE(too_large.IsValid());
758 too_large /= d; 757 too_large /= d;
759 EXPECT_FALSE(too_large.IsValid()); 758 EXPECT_FALSE(too_large.IsValid());
760 } 759 }
OLDNEW
« no previous file with comments | « base/metrics/sample_vector_unittest.cc ('k') | base/synchronization/atomic_flag_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698