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
This commit is contained in:
parent
200ff59949
commit
717ce7feb8
@ -162,8 +162,8 @@ GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0);
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0);
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long long, 0); // NOLINT
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long long, 0); // NOLINT
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);
|
||||
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
|
||||
|
||||
|
@ -136,15 +136,13 @@ GMOCK_DECLARE_KIND_(int, kInteger);
|
||||
GMOCK_DECLARE_KIND_(unsigned int, kInteger);
|
||||
GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
|
||||
GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
|
||||
GMOCK_DECLARE_KIND_(long long, kInteger); // NOLINT
|
||||
GMOCK_DECLARE_KIND_(unsigned long long, kInteger); // NOLINT
|
||||
|
||||
#if GMOCK_WCHAR_T_IS_NATIVE_
|
||||
GMOCK_DECLARE_KIND_(wchar_t, kInteger);
|
||||
#endif
|
||||
|
||||
// Non-standard integer types.
|
||||
GMOCK_DECLARE_KIND_(Int64, kInteger);
|
||||
GMOCK_DECLARE_KIND_(UInt64, kInteger);
|
||||
|
||||
// All standard floating-point types.
|
||||
GMOCK_DECLARE_KIND_(float, kFloatingPoint);
|
||||
GMOCK_DECLARE_KIND_(double, kFloatingPoint);
|
||||
|
@ -42,6 +42,7 @@
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
|
||||
// Most of the utilities needed for porting Google Mock are also
|
||||
@ -69,8 +70,7 @@
|
||||
|
||||
// Macros for declaring flags.
|
||||
# define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)
|
||||
# define GMOCK_DECLARE_int32_(name) \
|
||||
extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name)
|
||||
# define GMOCK_DECLARE_int32_(name) extern GTEST_API_ int32_t GMOCK_FLAG(name)
|
||||
# define GMOCK_DECLARE_string_(name) \
|
||||
extern GTEST_API_ ::std::string GMOCK_FLAG(name)
|
||||
|
||||
@ -78,7 +78,7 @@
|
||||
# define GMOCK_DEFINE_bool_(name, default_val, doc) \
|
||||
GTEST_API_ bool GMOCK_FLAG(name) = (default_val)
|
||||
# define GMOCK_DEFINE_int32_(name, default_val, doc) \
|
||||
GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)
|
||||
GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val)
|
||||
# define GMOCK_DEFINE_string_(name, default_val, doc) \
|
||||
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)
|
||||
|
||||
|
@ -80,8 +80,6 @@ using testing::SetArgumentPointee;
|
||||
using testing::Unused;
|
||||
using testing::WithArgs;
|
||||
using testing::internal::BuiltInDefaultValue;
|
||||
using testing::internal::Int64;
|
||||
using testing::internal::UInt64;
|
||||
|
||||
#if !GTEST_OS_WINDOWS_MOBILE
|
||||
using testing::SetErrnoAndReturn;
|
||||
@ -123,8 +121,9 @@ TEST(BuiltInDefaultValueTest, IsZeroForNumericTypes) {
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<signed long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<UInt64>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<Int64>::Get());
|
||||
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned long long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<signed long long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<long long>::Get()); // NOLINT
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<float>::Get());
|
||||
EXPECT_EQ(0, BuiltInDefaultValue<double>::Get());
|
||||
}
|
||||
@ -147,8 +146,9 @@ TEST(BuiltInDefaultValueTest, ExistsForNumericTypes) {
|
||||
EXPECT_TRUE(BuiltInDefaultValue<unsigned long>::Exists()); // NOLINT
|
||||
EXPECT_TRUE(BuiltInDefaultValue<signed long>::Exists()); // NOLINT
|
||||
EXPECT_TRUE(BuiltInDefaultValue<long>::Exists()); // NOLINT
|
||||
EXPECT_TRUE(BuiltInDefaultValue<UInt64>::Exists());
|
||||
EXPECT_TRUE(BuiltInDefaultValue<Int64>::Exists());
|
||||
EXPECT_TRUE(BuiltInDefaultValue<unsigned long long>::Exists()); // NOLINT
|
||||
EXPECT_TRUE(BuiltInDefaultValue<signed long long>::Exists()); // NOLINT
|
||||
EXPECT_TRUE(BuiltInDefaultValue<long long>::Exists()); // NOLINT
|
||||
EXPECT_TRUE(BuiltInDefaultValue<float>::Exists());
|
||||
EXPECT_TRUE(BuiltInDefaultValue<double>::Exists());
|
||||
}
|
||||
|
@ -36,6 +36,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
@ -172,9 +173,9 @@ TEST(KindOfTest, Integer) {
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned int)); // NOLINT
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(long)); // NOLINT
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long)); // NOLINT
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(long long)); // NOLINT
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long long)); // NOLINT
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(wchar_t)); // NOLINT
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(Int64)); // NOLINT
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(UInt64)); // NOLINT
|
||||
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(size_t)); // NOLINT
|
||||
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN
|
||||
// ssize_t is not defined on Windows and possibly some other OSes.
|
||||
@ -222,11 +223,12 @@ TEST(LosslessArithmeticConvertibleTest, IntegerToInteger) {
|
||||
EXPECT_TRUE((LosslessArithmeticConvertible<unsigned char, int>::value));
|
||||
|
||||
// Unsigned => larger unsigned is fine.
|
||||
EXPECT_TRUE(
|
||||
(LosslessArithmeticConvertible<unsigned short, UInt64>::value)); // NOLINT
|
||||
EXPECT_TRUE((LosslessArithmeticConvertible<
|
||||
unsigned short, uint64_t>::value)); // NOLINT
|
||||
|
||||
// Signed => unsigned is not fine.
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<short, UInt64>::value)); // NOLINT
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<
|
||||
short, uint64_t>::value)); // NOLINT
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<
|
||||
signed char, unsigned int>::value)); // NOLINT
|
||||
|
||||
@ -242,12 +244,12 @@ TEST(LosslessArithmeticConvertibleTest, IntegerToInteger) {
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<
|
||||
unsigned char, signed char>::value));
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<int, unsigned int>::value));
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<UInt64, Int64>::value));
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<uint64_t, int64_t>::value));
|
||||
|
||||
// Larger size => smaller size is not fine.
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<long, char>::value)); // NOLINT
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<int, signed char>::value));
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<Int64, unsigned int>::value));
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<int64_t, unsigned int>::value));
|
||||
}
|
||||
|
||||
TEST(LosslessArithmeticConvertibleTest, IntegerToFloatingPoint) {
|
||||
@ -266,7 +268,7 @@ TEST(LosslessArithmeticConvertibleTest, FloatingPointToBool) {
|
||||
|
||||
TEST(LosslessArithmeticConvertibleTest, FloatingPointToInteger) {
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<float, long>::value)); // NOLINT
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<double, Int64>::value));
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<double, int64_t>::value));
|
||||
EXPECT_FALSE((LosslessArithmeticConvertible<long double, int>::value));
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <functional>
|
||||
@ -6028,9 +6029,9 @@ TEST_P(BipartiteRandomTest, LargerNets) {
|
||||
int iters = GetParam().second;
|
||||
MatchMatrix graph(static_cast<size_t>(nodes), static_cast<size_t>(nodes));
|
||||
|
||||
auto seed = static_cast<testing::internal::UInt32>(GTEST_FLAG(random_seed));
|
||||
auto seed = static_cast<uint32_t>(GTEST_FLAG(random_seed));
|
||||
if (seed == 0) {
|
||||
seed = static_cast<testing::internal::UInt32>(time(nullptr));
|
||||
seed = static_cast<uint32_t>(time(nullptr));
|
||||
}
|
||||
|
||||
for (; iters > 0; --iters, ++seed) {
|
||||
|
@ -53,6 +53,7 @@
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
#include <cstdint>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <map>
|
||||
@ -842,18 +843,18 @@ struct GTEST_API_ TrueWithString {
|
||||
// but it's good enough for our purposes.
|
||||
class GTEST_API_ Random {
|
||||
public:
|
||||
static const UInt32 kMaxRange = 1u << 31;
|
||||
static const uint32_t kMaxRange = 1u << 31;
|
||||
|
||||
explicit Random(UInt32 seed) : state_(seed) {}
|
||||
explicit Random(uint32_t seed) : state_(seed) {}
|
||||
|
||||
void Reseed(UInt32 seed) { state_ = seed; }
|
||||
void Reseed(uint32_t seed) { state_ = seed; }
|
||||
|
||||
// Generates a random number from [0, range). Crashes if 'range' is
|
||||
// 0 or greater than kMaxRange.
|
||||
UInt32 Generate(UInt32 range);
|
||||
uint32_t Generate(uint32_t range);
|
||||
|
||||
private:
|
||||
UInt32 state_;
|
||||
uint32_t state_;
|
||||
GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);
|
||||
};
|
||||
|
||||
|
@ -223,8 +223,7 @@
|
||||
//
|
||||
// Integer types:
|
||||
// TypeWithSize - maps an integer to a int type.
|
||||
// Int32, UInt32, Int64, UInt64, TimeInMillis
|
||||
// - integers of known sizes.
|
||||
// TimeInMillis - integers of known sizes.
|
||||
// BiggestInt - the biggest signed integer type.
|
||||
//
|
||||
// Command-line utilities:
|
||||
@ -235,7 +234,7 @@
|
||||
// Environment variable utilities:
|
||||
// GetEnv() - gets the value of an environment variable.
|
||||
// BoolFromGTestEnv() - parses a bool environment variable.
|
||||
// Int32FromGTestEnv() - parses an Int32 environment variable.
|
||||
// Int32FromGTestEnv() - parses an int32_t environment variable.
|
||||
// StringFromGTestEnv() - parses a string environment variable.
|
||||
//
|
||||
// Deprecation warnings:
|
||||
@ -248,6 +247,8 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
@ -1876,12 +1877,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,15 +2082,13 @@ 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.
|
||||
// The biggest signed integer type the compiler supports.
|
||||
//
|
||||
// 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));
|
||||
// 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<BiggestInt>::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
|
||||
@ -2117,40 +2113,27 @@ class TypeWithSize {
|
||||
public:
|
||||
// This prevents the user from using TypeWithSize<N> with incorrect
|
||||
// values of N.
|
||||
typedef void UInt;
|
||||
using UInt = void;
|
||||
};
|
||||
|
||||
// The specialization for size 4.
|
||||
template <>
|
||||
class TypeWithSize<4> {
|
||||
public:
|
||||
// unsigned int has size 4 in both gcc and MSVC.
|
||||
//
|
||||
// As base/basictypes.h doesn't compile on Windows, we cannot use
|
||||
// uint32, uint64, and etc here.
|
||||
typedef int Int;
|
||||
typedef unsigned int UInt;
|
||||
using Int = std::int32_t;
|
||||
using UInt = std::uint32_t;
|
||||
};
|
||||
|
||||
// The specialization for size 8.
|
||||
template <>
|
||||
class TypeWithSize<8> {
|
||||
public:
|
||||
#if GTEST_OS_WINDOWS
|
||||
typedef __int64 Int;
|
||||
typedef unsigned __int64 UInt;
|
||||
#else
|
||||
typedef long long Int; // NOLINT
|
||||
typedef unsigned long long UInt; // NOLINT
|
||||
#endif // GTEST_OS_WINDOWS
|
||||
using Int = std::int64_t;
|
||||
using UInt = std::uint64_t;
|
||||
};
|
||||
|
||||
// Integer types of known sizes.
|
||||
typedef TypeWithSize<4>::Int Int32;
|
||||
typedef TypeWithSize<4>::UInt UInt32;
|
||||
typedef TypeWithSize<8>::Int Int64;
|
||||
typedef TypeWithSize<8>::UInt UInt64;
|
||||
typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
using TimeInMillis = int64_t; // Represents time in milliseconds.
|
||||
|
||||
// Utilities for command line flags and environment variables.
|
||||
|
||||
@ -2169,7 +2152,7 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
// Macros for declaring flags.
|
||||
# define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)
|
||||
# define GTEST_DECLARE_int32_(name) \
|
||||
GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)
|
||||
GTEST_API_ extern std::int32_t GTEST_FLAG(name)
|
||||
# define GTEST_DECLARE_string_(name) \
|
||||
GTEST_API_ extern ::std::string GTEST_FLAG(name)
|
||||
|
||||
@ -2177,7 +2160,7 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
# define GTEST_DEFINE_bool_(name, default_val, doc) \
|
||||
GTEST_API_ bool GTEST_FLAG(name) = (default_val)
|
||||
# define GTEST_DEFINE_int32_(name, default_val, doc) \
|
||||
GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)
|
||||
GTEST_API_ std::int32_t GTEST_FLAG(name) = (default_val)
|
||||
# define GTEST_DEFINE_string_(name, default_val, doc) \
|
||||
GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)
|
||||
|
||||
@ -2192,12 +2175,12 @@ typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds.
|
||||
// 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 a bool/Int32/string from the environment variable
|
||||
// Parses a bool/int32_t/string from the environment variable
|
||||
// corresponding to the given Google Test flag.
|
||||
bool BoolFromGTestEnv(const char* flag, bool default_val);
|
||||
GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);
|
||||
GTEST_API_ int32_t Int32FromGTestEnv(const char* flag, int32_t default_val);
|
||||
std::string OutputFlagAlsoCheckEnvVar();
|
||||
const char* StringFromGTestEnv(const char* flag, const char* default_val);
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "gtest/internal/gtest-port.h"
|
||||
@ -152,7 +153,7 @@ class GTEST_API_ String {
|
||||
static std::string FormatHexInt(int value);
|
||||
|
||||
// Formats an int value as "%X".
|
||||
static std::string FormatHexUInt32(UInt32 value);
|
||||
static std::string FormatHexUInt32(uint32_t value);
|
||||
|
||||
// Formats a byte as "%02X".
|
||||
static std::string FormatByte(unsigned char value);
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <string.h> // For memmove.
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -123,11 +124,11 @@ GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms);
|
||||
// On success, stores the value of the flag in *value, and returns
|
||||
// true. On failure, returns false without changing *value.
|
||||
GTEST_API_ bool ParseInt32Flag(
|
||||
const char* str, const char* flag, Int32* value);
|
||||
const char* str, const char* flag, int32_t* value);
|
||||
|
||||
// Returns a random seed in range [1, kMaxRandomSeed] based on the
|
||||
// given --gtest_random_seed flag value.
|
||||
inline int GetRandomSeedFromFlag(Int32 random_seed_flag) {
|
||||
inline int GetRandomSeedFromFlag(int32_t random_seed_flag) {
|
||||
const unsigned int raw_seed = (random_seed_flag == 0) ?
|
||||
static_cast<unsigned int>(GetTimeInMillis()) :
|
||||
static_cast<unsigned int>(random_seed_flag);
|
||||
@ -213,10 +214,10 @@ class GTestFlagSaver {
|
||||
std::string output_;
|
||||
bool print_time_;
|
||||
bool print_utf8_;
|
||||
internal::Int32 random_seed_;
|
||||
internal::Int32 repeat_;
|
||||
int32_t random_seed_;
|
||||
int32_t repeat_;
|
||||
bool shuffle_;
|
||||
internal::Int32 stack_trace_depth_;
|
||||
int32_t stack_trace_depth_;
|
||||
std::string stream_result_to_;
|
||||
bool throw_on_failure_;
|
||||
} GTEST_ATTRIBUTE_UNUSED_;
|
||||
@ -227,7 +228,7 @@ class GTestFlagSaver {
|
||||
// If the code_point is not a valid Unicode code point
|
||||
// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted
|
||||
// to "(Invalid Unicode 0xXXXXXXXX)".
|
||||
GTEST_API_ std::string CodePointToUtf8(UInt32 code_point);
|
||||
GTEST_API_ std::string CodePointToUtf8(uint32_t code_point);
|
||||
|
||||
// Converts a wide string to a narrow string in UTF-8 encoding.
|
||||
// The wide string is assumed to have the following encoding:
|
||||
@ -260,10 +261,10 @@ GTEST_API_ bool ShouldShard(const char* total_shards_str,
|
||||
const char* shard_index_str,
|
||||
bool in_subprocess_for_death_test);
|
||||
|
||||
// Parses the environment variable var as an Int32. If it is unset,
|
||||
// returns default_val. If it is not an Int32, prints an error and
|
||||
// Parses the environment variable var as a 32-bit integer. If it is unset,
|
||||
// returns default_val. If it is not a 32-bit integer, prints an error and
|
||||
// and aborts.
|
||||
GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);
|
||||
GTEST_API_ int32_t Int32FromEnvOrDie(const char* env_var, int32_t default_val);
|
||||
|
||||
// Given the total number of shards, the shard index, and the test id,
|
||||
// returns true if and only if the test should be run on this shard. The test id
|
||||
@ -323,7 +324,7 @@ void ShuffleRange(internal::Random* random, int begin, int end,
|
||||
const int last_in_range = begin + range_width - 1;
|
||||
const int selected =
|
||||
begin +
|
||||
static_cast<int>(random->Generate(static_cast<UInt32>(range_width)));
|
||||
static_cast<int>(random->Generate(static_cast<uint32_t>(range_width)));
|
||||
std::swap((*v)[static_cast<size_t>(selected)],
|
||||
(*v)[static_cast<size_t>(last_in_range)]);
|
||||
}
|
||||
@ -999,20 +1000,9 @@ bool ParseNaturalNumber(const ::std::string& str, Integer* number) {
|
||||
char* end;
|
||||
// BiggestConvertible is the largest integer type that system-provided
|
||||
// string-to-number conversion routines can return.
|
||||
using BiggestConvertible = unsigned long long; // NOLINT
|
||||
|
||||
# if GTEST_OS_WINDOWS && !defined(__GNUC__)
|
||||
|
||||
// MSVC and C++ Builder define __int64 instead of the standard long long.
|
||||
typedef unsigned __int64 BiggestConvertible;
|
||||
const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);
|
||||
|
||||
# else
|
||||
|
||||
typedef unsigned long long BiggestConvertible; // NOLINT
|
||||
const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);
|
||||
|
||||
# endif // GTEST_OS_WINDOWS && !defined(__GNUC__)
|
||||
|
||||
const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10); // NOLINT
|
||||
const bool parse_success = *end == '\0' && errno == 0;
|
||||
|
||||
GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));
|
||||
|
@ -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",
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <wctype.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <iomanip>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
@ -333,10 +334,10 @@ namespace internal {
|
||||
// Generates a random number from [0, range), using a Linear
|
||||
// Congruential Generator (LCG). Crashes if 'range' is 0 or greater
|
||||
// than kMaxRange.
|
||||
UInt32 Random::Generate(UInt32 range) {
|
||||
uint32_t Random::Generate(uint32_t range) {
|
||||
// These constants are the same as are used in glibc's rand(3).
|
||||
// Use wider types than necessary to prevent unsigned overflow diagnostics.
|
||||
state_ = static_cast<UInt32>(1103515245ULL*state_ + 12345U) % kMaxRange;
|
||||
state_ = static_cast<uint32_t>(1103515245ULL*state_ + 12345U) % kMaxRange;
|
||||
|
||||
GTEST_CHECK_(range > 0)
|
||||
<< "Cannot generate a number in the range [0, 0).";
|
||||
@ -1738,33 +1739,33 @@ AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT
|
||||
// 17 - 21 bits 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
|
||||
// The maximum code-point a one-byte UTF-8 sequence can represent.
|
||||
const UInt32 kMaxCodePoint1 = (static_cast<UInt32>(1) << 7) - 1;
|
||||
constexpr uint32_t kMaxCodePoint1 = (static_cast<uint32_t>(1) << 7) - 1;
|
||||
|
||||
// The maximum code-point a two-byte UTF-8 sequence can represent.
|
||||
const UInt32 kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1;
|
||||
constexpr uint32_t kMaxCodePoint2 = (static_cast<uint32_t>(1) << (5 + 6)) - 1;
|
||||
|
||||
// The maximum code-point a three-byte UTF-8 sequence can represent.
|
||||
const UInt32 kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1;
|
||||
constexpr uint32_t kMaxCodePoint3 = (static_cast<uint32_t>(1) << (4 + 2*6)) - 1;
|
||||
|
||||
// The maximum code-point a four-byte UTF-8 sequence can represent.
|
||||
const UInt32 kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1;
|
||||
constexpr uint32_t kMaxCodePoint4 = (static_cast<uint32_t>(1) << (3 + 3*6)) - 1;
|
||||
|
||||
// Chops off the n lowest bits from a bit pattern. Returns the n
|
||||
// lowest bits. As a side effect, the original bit pattern will be
|
||||
// shifted to the right by n bits.
|
||||
inline UInt32 ChopLowBits(UInt32* bits, int n) {
|
||||
const UInt32 low_bits = *bits & ((static_cast<UInt32>(1) << n) - 1);
|
||||
inline uint32_t ChopLowBits(uint32_t* bits, int n) {
|
||||
const uint32_t low_bits = *bits & ((static_cast<uint32_t>(1) << n) - 1);
|
||||
*bits >>= n;
|
||||
return low_bits;
|
||||
}
|
||||
|
||||
// Converts a Unicode code point to a narrow string in UTF-8 encoding.
|
||||
// code_point parameter is of type UInt32 because wchar_t may not be
|
||||
// code_point parameter is of type uint32_t because wchar_t may not be
|
||||
// wide enough to contain a code point.
|
||||
// If the code_point is not a valid Unicode code point
|
||||
// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted
|
||||
// to "(Invalid Unicode 0xXXXXXXXX)".
|
||||
std::string CodePointToUtf8(UInt32 code_point) {
|
||||
std::string CodePointToUtf8(uint32_t code_point) {
|
||||
if (code_point > kMaxCodePoint4) {
|
||||
return "(Invalid Unicode 0x" + String::FormatHexUInt32(code_point) + ")";
|
||||
}
|
||||
@ -1805,11 +1806,11 @@ inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {
|
||||
}
|
||||
|
||||
// Creates a Unicode code point from UTF16 surrogate pair.
|
||||
inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first,
|
||||
wchar_t second) {
|
||||
const auto first_u = static_cast<UInt32>(first);
|
||||
const auto second_u = static_cast<UInt32>(second);
|
||||
const UInt32 mask = (1 << 10) - 1;
|
||||
inline uint32_t CreateCodePointFromUtf16SurrogatePair(wchar_t first,
|
||||
wchar_t second) {
|
||||
const auto first_u = static_cast<uint32_t>(first);
|
||||
const auto second_u = static_cast<uint32_t>(second);
|
||||
const uint32_t mask = (1 << 10) - 1;
|
||||
return (sizeof(wchar_t) == 2)
|
||||
? (((first_u & mask) << 10) | (second_u & mask)) + 0x10000
|
||||
:
|
||||
@ -1837,7 +1838,7 @@ std::string WideStringToUtf8(const wchar_t* str, int num_chars) {
|
||||
|
||||
::std::stringstream stream;
|
||||
for (int i = 0; i < num_chars; ++i) {
|
||||
UInt32 unicode_code_point;
|
||||
uint32_t unicode_code_point;
|
||||
|
||||
if (str[i] == L'\0') {
|
||||
break;
|
||||
@ -1846,7 +1847,7 @@ std::string WideStringToUtf8(const wchar_t* str, int num_chars) {
|
||||
str[i + 1]);
|
||||
i++;
|
||||
} else {
|
||||
unicode_code_point = static_cast<UInt32>(str[i]);
|
||||
unicode_code_point = static_cast<uint32_t>(str[i]);
|
||||
}
|
||||
|
||||
stream << CodePointToUtf8(unicode_code_point);
|
||||
@ -1972,7 +1973,7 @@ std::string String::FormatIntWidth2(int value) {
|
||||
}
|
||||
|
||||
// Formats an int value as "%X".
|
||||
std::string String::FormatHexUInt32(UInt32 value) {
|
||||
std::string String::FormatHexUInt32(uint32_t value) {
|
||||
std::stringstream ss;
|
||||
ss << std::hex << std::uppercase << value;
|
||||
return ss.str();
|
||||
@ -1980,7 +1981,7 @@ std::string String::FormatHexUInt32(UInt32 value) {
|
||||
|
||||
// Formats an int value as "%X".
|
||||
std::string String::FormatHexInt(int value) {
|
||||
return FormatHexUInt32(static_cast<UInt32>(value));
|
||||
return FormatHexUInt32(static_cast<uint32_t>(value));
|
||||
}
|
||||
|
||||
// Formats a byte as "%02X".
|
||||
@ -3156,7 +3157,7 @@ void PrettyUnitTestResultPrinter::OnTestIterationStart(
|
||||
}
|
||||
|
||||
if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {
|
||||
const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
|
||||
const int32_t shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);
|
||||
ColoredPrintf(COLOR_YELLOW,
|
||||
"Note: This is test shard %d of %s.\n",
|
||||
static_cast<int>(shard_index) + 1,
|
||||
@ -5302,7 +5303,7 @@ bool UnitTestImpl::RunAllTests() {
|
||||
|
||||
// Shuffles test suites and tests if requested.
|
||||
if (has_tests_to_run && GTEST_FLAG(shuffle)) {
|
||||
random()->Reseed(static_cast<UInt32>(random_seed_));
|
||||
random()->Reseed(static_cast<uint32_t>(random_seed_));
|
||||
// This should be done before calling OnTestIterationStart(),
|
||||
// such that a test event listener can see the actual test order
|
||||
// in the event.
|
||||
@ -5425,8 +5426,8 @@ bool ShouldShard(const char* total_shards_env,
|
||||
return false;
|
||||
}
|
||||
|
||||
const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1);
|
||||
const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1);
|
||||
const int32_t total_shards = Int32FromEnvOrDie(total_shards_env, -1);
|
||||
const int32_t shard_index = Int32FromEnvOrDie(shard_index_env, -1);
|
||||
|
||||
if (total_shards == -1 && shard_index == -1) {
|
||||
return false;
|
||||
@ -5463,13 +5464,13 @@ bool ShouldShard(const char* total_shards_env,
|
||||
// Parses the environment variable var as an Int32. If it is unset,
|
||||
// returns default_val. If it is not an Int32, prints an error
|
||||
// and aborts.
|
||||
Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
|
||||
int32_t Int32FromEnvOrDie(const char* var, int32_t default_val) {
|
||||
const char* str_val = posix::GetEnv(var);
|
||||
if (str_val == nullptr) {
|
||||
return default_val;
|
||||
}
|
||||
|
||||
Int32 result;
|
||||
int32_t result;
|
||||
if (!ParseInt32(Message() << "The value of environment variable " << var,
|
||||
str_val, &result)) {
|
||||
exit(EXIT_FAILURE);
|
||||
@ -5493,9 +5494,9 @@ bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {
|
||||
// https://github.com/google/googletest/blob/master/googletest/docs/advanced.md
|
||||
// . Returns the number of tests that should run.
|
||||
int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {
|
||||
const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
|
||||
const int32_t total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
|
||||
Int32FromEnvOrDie(kTestTotalShards, -1) : -1;
|
||||
const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
|
||||
const int32_t shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
|
||||
Int32FromEnvOrDie(kTestShardIndex, -1) : -1;
|
||||
|
||||
// num_runnable_tests are the number of tests that will
|
||||
@ -5784,12 +5785,11 @@ static bool ParseBoolFlag(const char* str, const char* flag, bool* value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parses a string for an Int32 flag, in the form of
|
||||
// "--flag=value".
|
||||
// Parses a string for an int32_t flag, in the form of "--flag=value".
|
||||
//
|
||||
// On success, stores the value of the flag in *value, and returns
|
||||
// true. On failure, returns false without changing *value.
|
||||
bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
|
||||
bool ParseInt32Flag(const char* str, const char* flag, int32_t* value) {
|
||||
// Gets the value of the flag as a string.
|
||||
const char* const value_str = ParseFlagValue(str, flag, false);
|
||||
|
||||
@ -5801,8 +5801,7 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) {
|
||||
value_str, value);
|
||||
}
|
||||
|
||||
// Parses a string for a string flag, in the form of
|
||||
// "--flag=value".
|
||||
// Parses a string for a string flag, in the form of "--flag=value".
|
||||
//
|
||||
// On success, stores the value of the flag in *value, and returns
|
||||
// true. On failure, returns false without changing *value.
|
||||
|
@ -33,11 +33,12 @@
|
||||
// This file tests the universal value printer.
|
||||
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
#include <forward_list>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <set>
|
||||
@ -339,23 +340,25 @@ TEST(PrintBuiltInTypeTest, Wchar_t) {
|
||||
EXPECT_EQ("L'\\xC74D' (51021)", Print(static_cast<wchar_t>(0xC74D)));
|
||||
}
|
||||
|
||||
// Test that Int64 provides more storage than wchar_t.
|
||||
// Test that int64_t provides more storage than wchar_t.
|
||||
TEST(PrintTypeSizeTest, Wchar_t) {
|
||||
EXPECT_LT(sizeof(wchar_t), sizeof(testing::internal::Int64));
|
||||
EXPECT_LT(sizeof(wchar_t), sizeof(int64_t));
|
||||
}
|
||||
|
||||
// Various integer types.
|
||||
TEST(PrintBuiltInTypeTest, Integer) {
|
||||
EXPECT_EQ("'\\xFF' (255)", Print(static_cast<unsigned char>(255))); // uint8
|
||||
EXPECT_EQ("'\\x80' (-128)", Print(static_cast<signed char>(-128))); // int8
|
||||
EXPECT_EQ("65535", Print(USHRT_MAX)); // uint16
|
||||
EXPECT_EQ("-32768", Print(SHRT_MIN)); // int16
|
||||
EXPECT_EQ("4294967295", Print(UINT_MAX)); // uint32
|
||||
EXPECT_EQ("-2147483648", Print(INT_MIN)); // int32
|
||||
EXPECT_EQ("65535", Print(std::numeric_limits<uint16_t>::max())); // uint16
|
||||
EXPECT_EQ("-32768", Print(std::numeric_limits<int16_t>::min())); // int16
|
||||
EXPECT_EQ("4294967295",
|
||||
Print(std::numeric_limits<uint32_t>::max())); // uint32
|
||||
EXPECT_EQ("-2147483648",
|
||||
Print(std::numeric_limits<int32_t>::min())); // int32
|
||||
EXPECT_EQ("18446744073709551615",
|
||||
Print(static_cast<testing::internal::UInt64>(-1))); // uint64
|
||||
Print(std::numeric_limits<uint64_t>::max())); // uint64
|
||||
EXPECT_EQ("-9223372036854775808",
|
||||
Print(static_cast<testing::internal::Int64>(1) << 63)); // int64
|
||||
Print(std::numeric_limits<int64_t>::min())); // int64
|
||||
}
|
||||
|
||||
// Size types.
|
||||
@ -977,9 +980,8 @@ TEST(PrintStdTupleTest, VariousSizes) {
|
||||
EXPECT_EQ("(false, 2, 3, 4)", Print(t4));
|
||||
|
||||
const char* const str = "8";
|
||||
::std::tuple<bool, char, short, testing::internal::Int32, // NOLINT
|
||||
testing::internal::Int64, float, double, const char*, void*,
|
||||
std::string>
|
||||
::std::tuple<bool, char, short, int32_t, int64_t, float, double, // NOLINT
|
||||
const char*, void*, std::string>
|
||||
t10(false, 'a', static_cast<short>(3), 4, 5, 1.5F, -2.5, str, // NOLINT
|
||||
nullptr, "10");
|
||||
EXPECT_EQ("(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, " + PrintPointer(str) +
|
||||
|
@ -60,6 +60,7 @@ TEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <type_traits>
|
||||
@ -249,7 +250,6 @@ using testing::internal::GetTestTypeId;
|
||||
using testing::internal::GetTimeInMillis;
|
||||
using testing::internal::GetTypeId;
|
||||
using testing::internal::GetUnitTestImpl;
|
||||
using testing::internal::Int32;
|
||||
using testing::internal::Int32FromEnvOrDie;
|
||||
using testing::internal::IsAProtocolMessage;
|
||||
using testing::internal::IsContainer;
|
||||
@ -271,7 +271,6 @@ using testing::internal::StreamableToString;
|
||||
using testing::internal::String;
|
||||
using testing::internal::TestEventListenersAccessor;
|
||||
using testing::internal::TestResultAccessor;
|
||||
using testing::internal::UInt32;
|
||||
using testing::internal::UnitTestImpl;
|
||||
using testing::internal::WideStringToUtf8;
|
||||
using testing::internal::edit_distance::CalculateOptimalEdits;
|
||||
@ -788,7 +787,7 @@ TEST(RandomDeathTest, GeneratesCrashesOnInvalidRange) {
|
||||
}
|
||||
|
||||
TEST(RandomTest, GeneratesNumbersWithinRange) {
|
||||
const UInt32 kRange = 10000;
|
||||
constexpr uint32_t kRange = 10000;
|
||||
testing::internal::Random random(12345);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
EXPECT_LT(random.Generate(kRange), kRange) << " for iteration " << i;
|
||||
@ -801,10 +800,10 @@ TEST(RandomTest, GeneratesNumbersWithinRange) {
|
||||
}
|
||||
|
||||
TEST(RandomTest, RepeatsWhenReseeded) {
|
||||
const int kSeed = 123;
|
||||
const int kArraySize = 10;
|
||||
const UInt32 kRange = 10000;
|
||||
UInt32 values[kArraySize];
|
||||
constexpr int kSeed = 123;
|
||||
constexpr int kArraySize = 10;
|
||||
constexpr uint32_t kRange = 10000;
|
||||
uint32_t values[kArraySize];
|
||||
|
||||
testing::internal::Random random(kSeed);
|
||||
for (int i = 0; i < kArraySize; i++) {
|
||||
@ -1772,7 +1771,7 @@ TEST(Int32FromGTestEnvTest, ParsesAndReturnsValidValue) {
|
||||
// Tests that ParseInt32Flag() returns false and doesn't change the
|
||||
// output value when the flag has wrong format
|
||||
TEST(ParseInt32FlagTest, ReturnsFalseForInvalidFlag) {
|
||||
Int32 value = 123;
|
||||
int32_t value = 123;
|
||||
EXPECT_FALSE(ParseInt32Flag("--a=100", "b", &value));
|
||||
EXPECT_EQ(123, value);
|
||||
|
||||
@ -1785,7 +1784,7 @@ TEST(ParseInt32FlagTest, ReturnsFalseForInvalidFlag) {
|
||||
TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueOverflows) {
|
||||
printf("(expecting 2 warnings)\n");
|
||||
|
||||
Int32 value = 123;
|
||||
int32_t value = 123;
|
||||
EXPECT_FALSE(ParseInt32Flag("--abc=12345678987654321", "abc", &value));
|
||||
EXPECT_EQ(123, value);
|
||||
|
||||
@ -1799,7 +1798,7 @@ TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueOverflows) {
|
||||
TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueIsInvalid) {
|
||||
printf("(expecting 2 warnings)\n");
|
||||
|
||||
Int32 value = 123;
|
||||
int32_t value = 123;
|
||||
EXPECT_FALSE(ParseInt32Flag("--abc=A1", "abc", &value));
|
||||
EXPECT_EQ(123, value);
|
||||
|
||||
@ -1811,7 +1810,7 @@ TEST(ParseInt32FlagTest, ReturnsDefaultWhenValueIsInvalid) {
|
||||
// returns true when the flag represents a valid decimal integer in
|
||||
// the range of an Int32.
|
||||
TEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) {
|
||||
Int32 value = 123;
|
||||
int32_t value = 123;
|
||||
EXPECT_TRUE(ParseInt32Flag("--" GTEST_FLAG_PREFIX_ "abc=456", "abc", &value));
|
||||
EXPECT_EQ(456, value);
|
||||
|
||||
@ -1834,7 +1833,7 @@ TEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) {
|
||||
#endif // !GTEST_OS_WINDOWS_MOBILE
|
||||
|
||||
// Tests that Int32FromEnvOrDie() aborts with an error message
|
||||
// if the variable is not an Int32.
|
||||
// if the variable is not an int32_t.
|
||||
TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {
|
||||
SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "xxx");
|
||||
EXPECT_DEATH_IF_SUPPORTED(
|
||||
@ -1843,7 +1842,7 @@ TEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {
|
||||
}
|
||||
|
||||
// Tests that Int32FromEnvOrDie() aborts with an error message
|
||||
// if the variable cannot be represented by an Int32.
|
||||
// if the variable cannot be represented by an int32_t.
|
||||
TEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) {
|
||||
SetEnv(GTEST_FLAG_PREFIX_UPPER_ "VAR", "1234567891234567891234");
|
||||
EXPECT_DEATH_IF_SUPPORTED(
|
||||
@ -5597,7 +5596,7 @@ struct Flags {
|
||||
|
||||
// Creates a Flags struct where the gtest_random_seed flag has the given
|
||||
// value.
|
||||
static Flags RandomSeed(Int32 random_seed) {
|
||||
static Flags RandomSeed(int32_t random_seed) {
|
||||
Flags flags;
|
||||
flags.random_seed = random_seed;
|
||||
return flags;
|
||||
@ -5605,7 +5604,7 @@ struct Flags {
|
||||
|
||||
// Creates a Flags struct where the gtest_repeat flag has the given
|
||||
// value.
|
||||
static Flags Repeat(Int32 repeat) {
|
||||
static Flags Repeat(int32_t repeat) {
|
||||
Flags flags;
|
||||
flags.repeat = repeat;
|
||||
return flags;
|
||||
@ -5621,7 +5620,7 @@ struct Flags {
|
||||
|
||||
// Creates a Flags struct where the GTEST_FLAG(stack_trace_depth) flag has
|
||||
// the given value.
|
||||
static Flags StackTraceDepth(Int32 stack_trace_depth) {
|
||||
static Flags StackTraceDepth(int32_t stack_trace_depth) {
|
||||
Flags flags;
|
||||
flags.stack_trace_depth = stack_trace_depth;
|
||||
return flags;
|
||||
@ -5652,10 +5651,10 @@ struct Flags {
|
||||
bool list_tests;
|
||||
const char* output;
|
||||
bool print_time;
|
||||
Int32 random_seed;
|
||||
Int32 repeat;
|
||||
int32_t random_seed;
|
||||
int32_t repeat;
|
||||
bool shuffle;
|
||||
Int32 stack_trace_depth;
|
||||
int32_t stack_trace_depth;
|
||||
const char* stream_result_to;
|
||||
bool throw_on_failure;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user