diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h index 16047258..0dcc3a31 100644 --- a/include/gtest/internal/gtest-internal.h +++ b/include/gtest/internal/gtest-internal.h @@ -51,6 +51,7 @@ #endif #include +#include #include #include #include @@ -294,6 +295,9 @@ class FloatingPoint { return ReinterpretBits(kExponentBitMask); } + // Returns the maximum representable finite floating-point number. + static RawType Max(); + // Non-static methods // Returns the bits that represents this number. @@ -374,6 +378,13 @@ class FloatingPoint { FloatingPointUnion u_; }; +// We cannot use std::numeric_limits::max() as it clashes with the max() +// macro defined by . +template <> +inline float FloatingPoint::Max() { return FLT_MAX; } +template <> +inline double FloatingPoint::Max() { return DBL_MAX; } + // Typedefs the instances of the FloatingPoint template class that we // care to use. typedef FloatingPoint Float; diff --git a/test/gtest-death-test_test.cc b/test/gtest-death-test_test.cc index 4f379963..c2d26df9 100644 --- a/test/gtest-death-test_test.cc +++ b/test/gtest-death-test_test.cc @@ -45,7 +45,6 @@ using testing::internal::AlwaysTrue; # else # include # include // For waitpid. -# include // For std::numeric_limits. # endif // GTEST_OS_WINDOWS # include @@ -1123,17 +1122,16 @@ TEST(AutoHandleTest, AutoHandleWorks) { # if GTEST_OS_WINDOWS typedef unsigned __int64 BiggestParsable; typedef signed __int64 BiggestSignedParsable; -const BiggestParsable kBiggestParsableMax = ULLONG_MAX; -const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX; # else typedef unsigned long long BiggestParsable; typedef signed long long BiggestSignedParsable; -const BiggestParsable kBiggestParsableMax = - ::std::numeric_limits::max(); -const BiggestSignedParsable kBiggestSignedParsableMax = - ::std::numeric_limits::max(); # endif // GTEST_OS_WINDOWS +// We cannot use std::numeric_limits::max() as it clashes with the +// max() macro defined by . +const BiggestParsable kBiggestParsableMax = ULLONG_MAX; +const BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX; + TEST(ParseNaturalNumberTest, RejectsInvalidFormat) { BiggestParsable result = 0;