aboutsummaryrefslogtreecommitdiffstats
path: root/googletest/include
diff options
context:
space:
mode:
authorvslashg <gfalcon@google.com>2019-11-01 16:02:16 -0400
committervslashg <gfalcon@google.com>2019-11-01 16:02:16 -0400
commite8a82dc7ede61c4af3b9d75aa0e953b8cecfc8bb (patch)
tree2c85a4c08b20e6ce31a4c5e1f8814d9b837a94bd /googletest/include
parent057ee5063d00a67fd0a83029e8cf26ea9bc1bb69 (diff)
parent6e87238c9b14bcd749364e9b7125622a985a8a20 (diff)
downloadgoogletest-e8a82dc7ede61c4af3b9d75aa0e953b8cecfc8bb.tar.gz
googletest-e8a82dc7ede61c4af3b9d75aa0e953b8cecfc8bb.tar.bz2
googletest-e8a82dc7ede61c4af3b9d75aa0e953b8cecfc8bb.zip
Merge pull request #2453 from kuzkry:gtest-port-clean-up_kMaxBiggestInt
PiperOrigin-RevId: 277979766
Diffstat (limited to 'googletest/include')
-rw-r--r--googletest/include/gtest/gtest-printers.h35
-rw-r--r--googletest/include/gtest/gtest.h48
-rw-r--r--googletest/include/gtest/internal/gtest-port.h14
3 files changed, 39 insertions, 58 deletions
diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h
index 56a05450..808d3197 100644
--- a/googletest/include/gtest/gtest-printers.h
+++ b/googletest/include/gtest/gtest-printers.h
@@ -133,7 +133,7 @@ GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,
// nor PrintTo().
enum TypeKind {
kProtobuf, // a protobuf type
- kConvertibleToInteger, // a type implicitly convertible to BiggestInt
+ kConvertibleToInteger, // a type implicitly convertible to std::intmax_t
// (e.g. a named or unnamed enum type)
#if GTEST_HAS_ABSL
kConvertibleToStringView, // a type implicitly convertible to
@@ -179,14 +179,14 @@ template <typename T>
class TypeWithoutFormatter<T, kConvertibleToInteger> {
public:
// Since T has no << operator or PrintTo() but can be implicitly
- // converted to BiggestInt, we print it as a BiggestInt.
+ // converted to the maximum width integer, we print it as a std::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
+ // 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(const T& value, ::std::ostream* os) {
- const internal::BiggestInt kBigInt = value;
+ const std::intmax_t kBigInt = value;
*os << kBigInt;
}
};
@@ -204,10 +204,10 @@ class TypeWithoutFormatter<T, kConvertibleToStringView> {
};
#endif
-// Prints the given value to the given ostream. If the value is a
+// Prints the given value to the given ostream. If the value is a
// protocol message, its debug string is printed; if it's an enum or
-// of a type implicitly convertible to BiggestInt, it's printed as an
-// integer; otherwise the bytes in the value are printed. This is
+// of a type implicitly convertible to std::intmax_t, it's printed as an
+// integer; otherwise the bytes in the value are printed. This is
// what UniversalPrinter<T>::Print() does when it knows nothing about
// type T and T has neither << operator nor PrintTo().
//
@@ -231,19 +231,18 @@ class TypeWithoutFormatter<T, kConvertibleToStringView> {
template <typename Char, typename CharTraits, typename T>
::std::basic_ostream<Char, CharTraits>& operator<<(
::std::basic_ostream<Char, CharTraits>& os, const T& x) {
- TypeWithoutFormatter<T, (internal::IsAProtocolMessage<T>::value
- ? kProtobuf
- : std::is_convertible<
- const T&, internal::BiggestInt>::value
- ? kConvertibleToInteger
- :
+ TypeWithoutFormatter<
+ T, (internal::IsAProtocolMessage<T>::value
+ ? kProtobuf
+ : std::is_convertible<const T&, std::intmax_t>::value
+ ? kConvertibleToInteger
+ :
#if GTEST_HAS_ABSL
- std::is_convertible<
- const T&, absl::string_view>::value
- ? kConvertibleToStringView
- :
+ std::is_convertible<const T&, absl::string_view>::value
+ ? kConvertibleToStringView
+ :
#endif
- kOtherType)>::PrintValue(x, &os);
+ kOtherType)>::PrintValue(x, &os);
return os;
}
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 8eda6eac..0e1c4f7e 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -1531,13 +1531,11 @@ AssertionResult CmpHelperEQ(const char* lhs_expression,
return CmpHelperEQFailure(lhs_expression, rhs_expression, lhs, rhs);
}
-// 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.
+// With this overloaded version, we allow anonymous enums to be used in
+// {ASSERT|EXPECT}_EQ as anonymous enums can be implicitly cast to integers.
GTEST_API_ AssertionResult CmpHelperEQ(const char* lhs_expression,
const char* rhs_expression,
- BiggestInt lhs,
- BiggestInt rhs);
+ std::intmax_t lhs, std::intmax_t rhs);
class EqHelper {
public:
@@ -1554,16 +1552,14 @@ class EqHelper {
return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
}
- // 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.
+ // With this overloaded version, we allow anonymous enums to be used in
+ // {ASSERT|EXPECT}_EQ as anonymous enums can be implicitly cast to integers.
//
// 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, std::intmax_t lhs,
+ std::intmax_t rhs) {
return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
}
@@ -1596,24 +1592,24 @@ AssertionResult CmpHelperOpFailure(const char* expr1, const char* expr2,
// of similar code.
//
// For each templatized helper function, we also define an overloaded
-// version for BiggestInt in order to reduce code bloat and allow
-// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled
-// with gcc 4.
+// version for std::intmax_t in order to reduce code bloat and allow
+// anonymous enums to be used with {ASSERT|EXPECT}_??.
//
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
-#define GTEST_IMPL_CMP_HELPER_(op_name, op)\
-template <typename T1, typename T2>\
-AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
- const T1& val1, const T2& val2) {\
- if (val1 op val2) {\
- return AssertionSuccess();\
- } else {\
- return CmpHelperOpFailure(expr1, expr2, val1, val2, #op);\
- }\
-}\
-GTEST_API_ AssertionResult CmpHelper##op_name(\
- const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)
+#define GTEST_IMPL_CMP_HELPER_(op_name, op) \
+ template <typename T1, typename T2> \
+ AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \
+ const T1& val1, const T2& val2) { \
+ if (val1 op val2) { \
+ return AssertionSuccess(); \
+ } else { \
+ return CmpHelperOpFailure(expr1, expr2, val1, val2, #op); \
+ } \
+ } \
+ GTEST_API_ AssertionResult CmpHelper##op_name( \
+ const char* expr1, const char* expr2, std::intmax_t val1, \
+ std::intmax_t val2)
// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 90be25e2..6bb8f51f 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -225,7 +225,6 @@
// TypeWithSize - maps an integer to a int type.
// Int32, UInt32, Int64, UInt64, TimeInMillis
// - integers of known sizes.
-// BiggestInt - the biggest signed integer type.
//
// Command-line utilities:
// GTEST_DECLARE_*() - declares a flag.
@@ -1876,12 +1875,9 @@ GTEST_API_ size_t GetThreadCount();
#if GTEST_OS_WINDOWS
# define GTEST_PATH_SEP_ "\\"
# define GTEST_HAS_ALT_PATH_SEP_ 1
-// The biggest signed integer type the compiler supports.
-typedef __int64 BiggestInt;
#else
# define GTEST_PATH_SEP_ "/"
# define GTEST_HAS_ALT_PATH_SEP_ 0
-typedef long long BiggestInt; // NOLINT
#endif // GTEST_OS_WINDOWS
// Utilities for char.
@@ -2084,16 +2080,6 @@ GTEST_DISABLE_MSC_DEPRECATED_POP_()
# define GTEST_SNPRINTF_ snprintf
#endif
-// The maximum number a BiggestInt can represent. This definition
-// works no matter BiggestInt is represented in one's complement or
-// two's complement.
-//
-// We cannot rely on numeric_limits in STL, as __int64 and long long
-// are not part of standard C++ and numeric_limits doesn't need to be
-// defined for them.
-const BiggestInt kMaxBiggestInt =
- ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));
-
// 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.