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

Unified Diff: base/numerics/safe_numerics_unittest.cc

Issue 2516153002: Move the remaining CheckedNumeric logic out of the macro (Closed)
Patch Set: nit Created 4 years, 1 month 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
« base/numerics/safe_math_impl.h ('K') | « base/numerics/safe_math_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/numerics/safe_numerics_unittest.cc
diff --git a/base/numerics/safe_numerics_unittest.cc b/base/numerics/safe_numerics_unittest.cc
index ac7a5ba5f80c563bf9bba5c1faf548a9b406a059..430f7700b5d08e4c53d9cb90752e9f2172dd9455 100644
--- a/base/numerics/safe_numerics_unittest.cc
+++ b/base/numerics/safe_numerics_unittest.cc
@@ -62,20 +62,31 @@ Dst GetMaxConvertibleToFloat() {
return static_cast<Dst>(max);
}
+namespace base {
+namespace internal {
+template <typename U>
+U GetNumericValueForTest(const CheckedNumeric<U>& src) {
+ return src.state_.value();
+}
+} // namespace internal.
+} // namespace base.
+
+using base::internal::GetNumericValueForTest;
+
// Helper macros to wrap displaying the conversion types and line numbers.
#define TEST_EXPECTED_VALIDITY(expected, actual) \
EXPECT_EQ(expected, CheckedNumeric<Dst>(actual).IsValid()) \
- << "Result test: Value " << +(actual).ValueUnsafe() << " as " << dst \
- << " on line " << line
+ << "Result test: Value " << GetNumericValueForTest(actual) << " as " \
+ << dst << " on line " << line
#define TEST_EXPECTED_SUCCESS(actual) TEST_EXPECTED_VALIDITY(true, actual)
#define TEST_EXPECTED_FAILURE(actual) TEST_EXPECTED_VALIDITY(false, actual)
-#define TEST_EXPECTED_VALUE(expected, actual) \
- EXPECT_EQ(static_cast<Dst>(expected), \
- CheckedNumeric<Dst>(actual).ValueOrDie()) \
- << "Result test: Value " << +((actual).ValueUnsafe()) << " as " << dst \
- << " on line " << line
+#define TEST_EXPECTED_VALUE(expected, actual) \
+ EXPECT_EQ(static_cast<Dst>(expected), \
+ CheckedNumeric<Dst>(actual).ValueOrDie()) \
+ << "Result test: Value " << GetNumericValueForTest(actual) << " as " \
+ << dst << " on line " << line
// Signed integer arithmetic.
template <typename Dst>
« base/numerics/safe_math_impl.h ('K') | « base/numerics/safe_math_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698