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

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

Issue 425333002: Roll gtest and gmock DEPS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Numeric fix Created 6 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 | « DEPS ('k') | build/secondary/testing/gtest/BUILD.gn » ('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 #if defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS) 5 #if defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS)
6 #include <mmintrin.h> 6 #include <mmintrin.h>
7 #endif 7 #endif
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 16 matching lines...) Expand all
27 using base::enable_if; 27 using base::enable_if;
28 28
29 // MSVS 2013 ia32 may not reset the FPU between calculations, and the test 29 // MSVS 2013 ia32 may not reset the FPU between calculations, and the test
30 // framework masks the exceptions. So we just force a manual reset after NaN. 30 // framework masks the exceptions. So we just force a manual reset after NaN.
31 inline void ResetFloatingPointUnit() { 31 inline void ResetFloatingPointUnit() {
32 #if defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS) 32 #if defined(COMPILER_MSVC) && defined(ARCH_CPU_32_BITS)
33 _mm_empty(); 33 _mm_empty();
34 #endif 34 #endif
35 } 35 }
36 36
37 // These tests deliberately cause arithmetic overflows. If the compiler is
38 // aggressive enough, it can const fold these overflows. Disable warnings about
39 // overflows for const expressions.
40 #if defined(OS_WIN)
41 #pragma warning(disable:4756)
42 #endif
43
37 // Helper macros to wrap displaying the conversion types and line numbers. 44 // Helper macros to wrap displaying the conversion types and line numbers.
38 #define TEST_EXPECTED_VALIDITY(expected, actual) \ 45 #define TEST_EXPECTED_VALIDITY(expected, actual) \
39 EXPECT_EQ(expected, CheckedNumeric<Dst>(actual).validity()) \ 46 EXPECT_EQ(expected, CheckedNumeric<Dst>(actual).validity()) \
40 << "Result test: Value " << +(actual).ValueUnsafe() << " as " << dst \ 47 << "Result test: Value " << +(actual).ValueUnsafe() << " as " << dst \
41 << " on line " << line; 48 << " on line " << line;
42 49
43 #define TEST_EXPECTED_VALUE(expected, actual) \ 50 #define TEST_EXPECTED_VALUE(expected, actual) \
44 EXPECT_EQ(static_cast<Dst>(expected), \ 51 EXPECT_EQ(static_cast<Dst>(expected), \
45 CheckedNumeric<Dst>(actual).ValueUnsafe()) \ 52 CheckedNumeric<Dst>(actual).ValueUnsafe()) \
46 << "Result test: Value " << +((actual).ValueUnsafe()) << " as " << dst \ 53 << "Result test: Value " << +((actual).ValueUnsafe()) << " as " << dst \
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 static_cast<int>(small_positive)); 578 static_cast<int>(small_positive));
572 EXPECT_EQ(saturated_cast<unsigned>(small_negative), 579 EXPECT_EQ(saturated_cast<unsigned>(small_negative),
573 static_cast<unsigned>(0)); 580 static_cast<unsigned>(0));
574 EXPECT_EQ(saturated_cast<int>(double_small), 581 EXPECT_EQ(saturated_cast<int>(double_small),
575 static_cast<int>(double_small)); 582 static_cast<int>(double_small));
576 EXPECT_EQ(saturated_cast<int>(double_large), numeric_limits<int>::max()); 583 EXPECT_EQ(saturated_cast<int>(double_large), numeric_limits<int>::max());
577 EXPECT_EQ(saturated_cast<float>(double_large), double_infinity); 584 EXPECT_EQ(saturated_cast<float>(double_large), double_infinity);
578 EXPECT_EQ(saturated_cast<float>(-double_large), -double_infinity); 585 EXPECT_EQ(saturated_cast<float>(-double_large), -double_infinity);
579 } 586 }
580 587
OLDNEW
« no previous file with comments | « DEPS ('k') | build/secondary/testing/gtest/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698