diff options
author | Abseil Team <absl-team@google.com> | 2019-11-20 19:36:06 (GMT) |
---|---|---|
committer | Gennadiy Civil <misterg@google.com> | 2019-11-22 21:33:15 (GMT) |
commit | 717ce7feb87278b81dad756d973693024621f8e8 (patch) | |
tree | 2c016351f4359b94f75fa2af762d2138998d8063 /googletest/src/gtest-port.cc | |
parent | 200ff599496e20f4e39566feeaf2f6734ca7570f (diff) | |
download | googletest-717ce7feb87278b81dad756d973693024621f8e8.zip googletest-717ce7feb87278b81dad756d973693024621f8e8.tar.gz googletest-717ce7feb87278b81dad756d973693024621f8e8.tar.bz2 |
Googletest export
Use standard C++11 integer types in gtest-port.h.
Remove testing::internal::{Int,Uint}{32,64} in favor of types
guaranteed to be in <cstdint> since C++11.
Tests for built-in integer type coverage are switched from
{Int,Uint}64 to [unsigned] long long, which is guaranteed by
C++11 to exist and be at least 64-bit wide.
PiperOrigin-RevId: 281565263
Diffstat (limited to 'googletest/src/gtest-port.cc')
-rw-r--r-- | googletest/src/gtest-port.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/googletest/src/gtest-port.cc b/googletest/src/gtest-port.cc index fc5ba6b..c6df26d 100644 --- a/googletest/src/gtest-port.cc +++ b/googletest/src/gtest-port.cc @@ -34,6 +34,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <cstdint> #include <fstream> #include <memory> @@ -1286,7 +1287,7 @@ static std::string FlagToEnvVar(const char* flag) { // Parses 'str' for a 32-bit signed integer. If successful, writes // the result to *value and returns true; otherwise leaves *value // unchanged and returns false. -bool ParseInt32(const Message& src_text, const char* str, Int32* value) { +bool ParseInt32(const Message& src_text, const char* str, int32_t* value) { // Parses the environment variable as a decimal integer. char* end = nullptr; const long long_value = strtol(str, &end, 10); // NOLINT @@ -1303,13 +1304,13 @@ bool ParseInt32(const Message& src_text, const char* str, Int32* value) { return false; } - // Is the parsed value in the range of an Int32? - const Int32 result = static_cast<Int32>(long_value); + // Is the parsed value in the range of an int32_t? + const auto result = static_cast<int32_t>(long_value); if (long_value == LONG_MAX || long_value == LONG_MIN || // The parsed value overflows as a long. (strtol() returns // LONG_MAX or LONG_MIN when the input overflows.) result != long_value - // The parsed value overflows as an Int32. + // The parsed value overflows as an int32_t. ) { Message msg; msg << "WARNING: " << src_text @@ -1342,7 +1343,7 @@ bool BoolFromGTestEnv(const char* flag, bool default_value) { // Reads and returns a 32-bit integer stored in the environment // variable corresponding to the given flag; if it isn't set or // doesn't represent a valid 32-bit integer, returns default_value. -Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) { +int32_t Int32FromGTestEnv(const char* flag, int32_t default_value) { #if defined(GTEST_GET_INT32_FROM_ENV_) return GTEST_GET_INT32_FROM_ENV_(flag, default_value); #else @@ -1353,7 +1354,7 @@ Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) { return default_value; } - Int32 result = default_value; + int32_t result = default_value; if (!ParseInt32(Message() << "Environment variable " << env_var, string_value, &result)) { printf("The default value %s is used.\n", |