diff options
author | Xiaoyi Zhang <zhangxy@google.com> | 2019-11-04 16:43:27 (GMT) |
---|---|---|
committer | Xiaoyi Zhang <zhangxy@google.com> | 2019-11-04 16:43:27 (GMT) |
commit | 8697709e0308af4cd5b09dc108480804e5447cf0 (patch) | |
tree | c28c9fae6cb42e78fdb0750a63fcf8a814966b0d /googletest/test | |
parent | e8a82dc7ede61c4af3b9d75aa0e953b8cecfc8bb (diff) | |
parent | 6e87238c9b14bcd749364e9b7125622a985a8a20 (diff) | |
download | googletest-8697709e0308af4cd5b09dc108480804e5447cf0.zip googletest-8697709e0308af4cd5b09dc108480804e5447cf0.tar.gz googletest-8697709e0308af4cd5b09dc108480804e5447cf0.tar.bz2 |
Merge pull request #2453 from kuzkry:gtest-port-clean-up_kMaxBiggestInt
PiperOrigin-RevId: 278008286
Diffstat (limited to 'googletest/test')
-rw-r--r-- | googletest/test/googletest-printers-test.cc | 25 | ||||
-rw-r--r-- | googletest/test/gtest_unittest.cc | 6 |
2 files changed, 15 insertions, 16 deletions
diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index cebd6ac..58be7d1 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -83,12 +83,10 @@ void PrintTo(EnumWithPrintTo e, std::ostream* os) { *os << (e == kEWPT1 ? "kEWPT1" : "invalid"); } -// A class implicitly convertible to std::intmax_t. -class IntMaxConvertible { +// A class implicitly convertible to BiggestInt. +class BiggestIntConvertible { public: - constexpr operator std::intmax_t() const { // NOLINT(runtime/explicit) - return 42; - } + operator ::testing::internal::BiggestInt() const { return 42; } }; // A user-defined unprintable class template in the global namespace. @@ -269,10 +267,10 @@ TEST(PrintEnumTest, EnumWithPrintTo) { EXPECT_EQ("invalid", Print(static_cast<EnumWithPrintTo>(0))); } -// Tests printing a class implicitly convertible to std::intmax_t. +// Tests printing a class implicitly convertible to BiggestInt. -TEST(PrintClassTest, IntMaxConvertible) { - EXPECT_EQ("42", Print(IntMaxConvertible())); +TEST(PrintClassTest, BiggestIntConvertible) { + EXPECT_EQ("42", Print(BiggestIntConvertible())); } // Tests printing various char types. @@ -527,9 +525,10 @@ TEST(PrintPointerTest, NonMemberFunctionPointer) { // standard disallows casting between pointers to functions and // pointers to objects, and some compilers (e.g. GCC 3.4) enforce // this limitation. - EXPECT_EQ(PrintPointer(reinterpret_cast<const void*>( - reinterpret_cast<std::intptr_t>(&MyFunction))), - Print(&MyFunction)); + EXPECT_EQ( + PrintPointer(reinterpret_cast<const void*>( + reinterpret_cast<internal::BiggestInt>(&MyFunction))), + Print(&MyFunction)); int (*p)(bool) = NULL; // NOLINT EXPECT_EQ("NULL", Print(p)); } @@ -1121,8 +1120,8 @@ TEST(PrintReferenceTest, HandlesFunctionPointer) { // standard disallows casting between pointers to functions and // pointers to objects, and some compilers (e.g. GCC 3.4) enforce // this limitation. - const std::string fp_string = PrintPointer( - reinterpret_cast<const void*>(reinterpret_cast<std::intptr_t>(fp))); + const std::string fp_string = PrintPointer(reinterpret_cast<const void*>( + reinterpret_cast<internal::BiggestInt>(fp))); EXPECT_EQ("@" + fp_pointer_string + " " + fp_string, PrintByRef(fp)); } diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index ae8834d..d17a155 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -55,11 +55,11 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) { EXPECT_TRUE(dummy || !dummy); // Suppresses warning that dummy is unused. } +#include <limits.h> // For INT_MAX. #include <stdlib.h> #include <string.h> #include <time.h> -#include <limits> #include <map> #include <ostream> #include <type_traits> @@ -3952,11 +3952,11 @@ enum { // On Linux, kCaseB and kCaseA have the same value when truncated to // int size. We want to test whether this will confuse the // assertions. - kCaseB = (std::numeric_limits<std::intmax_t>::max)(), + kCaseB = testing::internal::kMaxBiggestInt, # else - kCaseB = (std::numeric_limits<int>::max)(), + kCaseB = INT_MAX, # endif // GTEST_OS_LINUX |