OLD | NEW |
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 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
13 #include "base/numerics/safe_math.h" | 13 #include "base/numerics/safe_math.h" |
14 #include "base/template_util.h" | |
15 #include "build/build_config.h" | 14 #include "build/build_config.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
17 | 16 |
18 #if defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS) | 17 #if defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS) |
19 #include <mmintrin.h> | 18 #include <mmintrin.h> |
20 #endif | 19 #endif |
21 | 20 |
22 using std::numeric_limits; | 21 using std::numeric_limits; |
23 using base::CheckedNumeric; | 22 using base::CheckedNumeric; |
24 using base::checked_cast; | 23 using base::checked_cast; |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 | 775 |
777 CheckedNumeric<int> too_large = std::numeric_limits<int>::max(); | 776 CheckedNumeric<int> too_large = std::numeric_limits<int>::max(); |
778 EXPECT_TRUE(too_large.IsValid()); | 777 EXPECT_TRUE(too_large.IsValid()); |
779 too_large += d; | 778 too_large += d; |
780 EXPECT_FALSE(too_large.IsValid()); | 779 EXPECT_FALSE(too_large.IsValid()); |
781 too_large -= d; | 780 too_large -= d; |
782 EXPECT_FALSE(too_large.IsValid()); | 781 EXPECT_FALSE(too_large.IsValid()); |
783 too_large /= d; | 782 too_large /= d; |
784 EXPECT_FALSE(too_large.IsValid()); | 783 EXPECT_FALSE(too_large.IsValid()); |
785 } | 784 } |
OLD | NEW |