diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index f647ee69..1288313b 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -104,6 +104,8 @@ #ifndef GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ #define GOOGLETEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ +#include + #include #include #include @@ -279,15 +281,13 @@ struct ProtobufPrinter { struct ConvertibleToIntegerPrinter { // Since T has no << operator or PrintTo() but can be implicitly - // converted to BiggestInt, we print it as a BiggestInt. + // converted to intmax_t, we print it as an intmax_t. // // Most likely T is an enum type (either named or unnamed), in which // case printing it as an integer is the desired behavior. In case // T is not an enum, printing it as an integer is the best we can do // given that it has no user-defined printer. - static void PrintValue(internal::BiggestInt value, ::std::ostream* os) { - *os << value; - } + static void PrintValue(intmax_t value, ::std::ostream* os) { *os << value; } }; struct ConvertibleToStringViewPrinter { @@ -347,7 +347,7 @@ struct FindFirstPrinter< // - Print object pointers. // - Print protocol buffers. // - Use the stream operator, if available. -// - Print types convertible to BiggestInt. +// - Print types convertible to intmax_t. // - Print types convertible to StringView, if available. // - Fallback to printing the raw bytes of the object. template diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h index 9fe7fb44..7c003c5d 100644 --- a/googletest/include/gtest/gtest.h +++ b/googletest/include/gtest/gtest.h @@ -1419,14 +1419,14 @@ class [[nodiscard]] EqHelper { } // With this overloaded version, we allow anonymous enums to be used - // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous - // enums can be implicitly cast to BiggestInt. + // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums can be + // implicitly cast to intmax_t. // // Even though its body looks the same as the above version, we // cannot merge the two, as it will make anonymous enums unhappy. static AssertionResult Compare(const char* lhs_expression, - const char* rhs_expression, BiggestInt lhs, - BiggestInt rhs) { + const char* rhs_expression, intmax_t lhs, + intmax_t rhs) { return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs); } diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 94a56ce3..116cb6f9 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -236,7 +236,6 @@ // Integer types: // TypeWithSize - maps an integer to a int type. // TimeInMillis - integers of known sizes. -// BiggestInt - the biggest signed integer type. // // Command-line utilities: // GetInjectableArgvs() - returns the command line as a vector of strings. @@ -2303,14 +2302,6 @@ GTEST_DISABLE_DEPRECATED_POP_() #define GTEST_SNPRINTF_ snprintf #endif -// The biggest signed integer type the compiler supports. -// -// long long is guaranteed to be at least 64-bits in C++11. -using BiggestInt = long long; // NOLINT - -// The maximum number a BiggestInt can represent. -constexpr BiggestInt kMaxBiggestInt = (std::numeric_limits::max)(); - // This template class serves as a compile-time function from size to // type. It maps a size in bytes to a primitive type with that // size. e.g. diff --git a/googletest/test/googletest-printers-test.cc b/googletest/test/googletest-printers-test.cc index d694d6f1..19466509 100644 --- a/googletest/test/googletest-printers-test.cc +++ b/googletest/test/googletest-printers-test.cc @@ -95,10 +95,12 @@ void PrintTo(EnumWithPrintTo e, std::ostream* os) { *os << (e == kEWPT1 ? "kEWPT1" : "invalid"); } -// A class implicitly convertible to BiggestInt. +// A class implicitly convertible to intmax_t. class BiggestIntConvertible { public: - operator ::testing::internal::BiggestInt() const { return 42; } + operator intmax_t() const { // NOLINT(google-explicit-constructor) + return 42; + } }; // A parent class with two child classes. The parent and one of the kids have @@ -356,7 +358,7 @@ TEST(PrintEnumTest, EnumWithPrintTo) { TEST(PrintClassTest, AbslStringify) { EXPECT_EQ("(10, 20)", Print(Point())); } #endif -// Tests printing a class implicitly convertible to BiggestInt. +// Tests printing a class implicitly convertible to intmax_t. TEST(PrintClassTest, BiggestIntConvertible) { EXPECT_EQ("42", Print(BiggestIntConvertible())); @@ -773,7 +775,7 @@ TEST(PrintPointerTest, NonMemberFunctionPointer) { // pointers to objects, and some compilers (e.g. GCC 3.4) enforce // this limitation. EXPECT_EQ(PrintPointer(reinterpret_cast( - reinterpret_cast(&MyFunction))), + reinterpret_cast(&MyFunction))), Print(&MyFunction)); int (*p)(bool) = NULL; // NOLINT EXPECT_EQ("NULL", Print(p)); @@ -1474,8 +1476,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( - reinterpret_cast(fp))); + const std::string fp_string = PrintPointer( + reinterpret_cast(reinterpret_cast(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 f4d71897..9a0765ac 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -34,6 +34,7 @@ #include "gtest/gtest.h" #include +#include // Verifies that the command line flag variables can be accessed in // code once "gtest.h" has been #included. @@ -4029,7 +4030,7 @@ 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 = testing::internal::kMaxBiggestInt, + kCaseB = (std::numeric_limits::max)(), #else