|
|
|
@ -622,12 +622,12 @@ extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId(); |
|
|
|
|
// This predicate-formatter checks that 'results' contains a test part
|
|
|
|
|
// failure of the given type and that the failure message contains the
|
|
|
|
|
// given substring.
|
|
|
|
|
AssertionResult HasOneFailure(const char* /* results_expr */, |
|
|
|
|
const char* /* type_expr */, |
|
|
|
|
const char* /* substr_expr */, |
|
|
|
|
const TestPartResultArray& results, |
|
|
|
|
TestPartResult::Type type, |
|
|
|
|
const std::string& substr) { |
|
|
|
|
static AssertionResult HasOneFailure(const char* /* results_expr */, |
|
|
|
|
const char* /* type_expr */, |
|
|
|
|
const char* /* substr_expr */, |
|
|
|
|
const TestPartResultArray& results, |
|
|
|
|
TestPartResult::Type type, |
|
|
|
|
const std::string& substr) { |
|
|
|
|
const std::string expected(type == TestPartResult::kFatalFailure ? |
|
|
|
|
"1 fatal failure" : |
|
|
|
|
"1 non-fatal failure"); |
|
|
|
@ -2130,8 +2130,9 @@ static std::string FormatWordList(const std::vector<std::string>& words) { |
|
|
|
|
return word_list.GetString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool ValidateTestPropertyName(const std::string& property_name, |
|
|
|
|
const std::vector<std::string>& reserved_names) { |
|
|
|
|
static bool ValidateTestPropertyName( |
|
|
|
|
const std::string& property_name, |
|
|
|
|
const std::vector<std::string>& reserved_names) { |
|
|
|
|
if (std::find(reserved_names.begin(), reserved_names.end(), property_name) != |
|
|
|
|
reserved_names.end()) { |
|
|
|
|
ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name |
|
|
|
@ -2876,7 +2877,7 @@ enum GTestColor { |
|
|
|
|
!GTEST_OS_WINDOWS_PHONE && !GTEST_OS_WINDOWS_RT && !GTEST_OS_WINDOWS_MINGW |
|
|
|
|
|
|
|
|
|
// Returns the character attribute for the given color.
|
|
|
|
|
WORD GetColorAttribute(GTestColor color) { |
|
|
|
|
static WORD GetColorAttribute(GTestColor color) { |
|
|
|
|
switch (color) { |
|
|
|
|
case COLOR_RED: return FOREGROUND_RED; |
|
|
|
|
case COLOR_GREEN: return FOREGROUND_GREEN; |
|
|
|
@ -2885,7 +2886,7 @@ WORD GetColorAttribute(GTestColor color) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int GetBitOffset(WORD color_mask) { |
|
|
|
|
static int GetBitOffset(WORD color_mask) { |
|
|
|
|
if (color_mask == 0) return 0; |
|
|
|
|
|
|
|
|
|
int bitOffset = 0; |
|
|
|
@ -2896,7 +2897,7 @@ int GetBitOffset(WORD color_mask) { |
|
|
|
|
return bitOffset; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
WORD GetNewColor(GTestColor color, WORD old_color_attrs) { |
|
|
|
|
static WORD GetNewColor(GTestColor color, WORD old_color_attrs) { |
|
|
|
|
// Let's reuse the BG
|
|
|
|
|
static const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY; |
|
|
|
|
static const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY; |
|
|
|
@ -2916,7 +2917,7 @@ WORD GetNewColor(GTestColor color, WORD old_color_attrs) { |
|
|
|
|
|
|
|
|
|
// Returns the ANSI color code for the given color. COLOR_DEFAULT is
|
|
|
|
|
// an invalid input.
|
|
|
|
|
const char* GetAnsiColorCode(GTestColor color) { |
|
|
|
|
static const char* GetAnsiColorCode(GTestColor color) { |
|
|
|
|
switch (color) { |
|
|
|
|
case COLOR_RED: return "1"; |
|
|
|
|
case COLOR_GREEN: return "2"; |
|
|
|
@ -2969,7 +2970,7 @@ bool ShouldUseColor(bool stdout_is_tty) { |
|
|
|
|
// This routine must actually emit the characters rather than return a string
|
|
|
|
|
// that would be colored when printed, as can be done on Linux.
|
|
|
|
|
GTEST_ATTRIBUTE_PRINTF_(2, 3) |
|
|
|
|
void ColoredPrintf(GTestColor color, const char* fmt, ...) { |
|
|
|
|
static void ColoredPrintf(GTestColor color, const char* fmt, ...) { |
|
|
|
|
va_list args; |
|
|
|
|
va_start(args, fmt); |
|
|
|
|
|
|
|
|
@ -3023,7 +3024,7 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) { |
|
|
|
|
static const char kTypeParamLabel[] = "TypeParam"; |
|
|
|
|
static const char kValueParamLabel[] = "GetParam()"; |
|
|
|
|
|
|
|
|
|
void PrintFullTestCommentIfPresent(const TestInfo& test_info) { |
|
|
|
|
static void PrintFullTestCommentIfPresent(const TestInfo& test_info) { |
|
|
|
|
const char* const type_param = test_info.type_param(); |
|
|
|
|
const char* const value_param = test_info.value_param(); |
|
|
|
|
|
|
|
|
@ -5021,9 +5022,9 @@ bool SkipPrefix(const char* prefix, const char** pstr) { |
|
|
|
|
// part can be omitted.
|
|
|
|
|
//
|
|
|
|
|
// Returns the value of the flag, or NULL if the parsing failed.
|
|
|
|
|
const char* ParseFlagValue(const char* str, |
|
|
|
|
const char* flag, |
|
|
|
|
bool def_optional) { |
|
|
|
|
static const char* ParseFlagValue(const char* str, |
|
|
|
|
const char* flag, |
|
|
|
|
bool def_optional) { |
|
|
|
|
// str and flag must not be NULL.
|
|
|
|
|
if (str == NULL || flag == NULL) return NULL; |
|
|
|
|
|
|
|
|
@ -5059,7 +5060,7 @@ const char* ParseFlagValue(const char* str, |
|
|
|
|
//
|
|
|
|
|
// On success, stores the value of the flag in *value, and returns
|
|
|
|
|
// true. On failure, returns false without changing *value.
|
|
|
|
|
bool ParseBoolFlag(const char* str, const char* flag, bool* value) { |
|
|
|
|
static bool ParseBoolFlag(const char* str, const char* flag, bool* value) { |
|
|
|
|
// Gets the value of the flag as a string.
|
|
|
|
|
const char* const value_str = ParseFlagValue(str, flag, true); |
|
|
|
|
|
|
|
|
@ -5093,7 +5094,9 @@ bool ParseInt32Flag(const char* str, const char* flag, Int32* value) { |
|
|
|
|
//
|
|
|
|
|
// On success, stores the value of the flag in *value, and returns
|
|
|
|
|
// true. On failure, returns false without changing *value.
|
|
|
|
|
bool ParseStringFlag(const char* str, const char* flag, std::string* value) { |
|
|
|
|
static bool ParseStringFlag(const char* str, |
|
|
|
|
const char* flag, |
|
|
|
|
std::string* value) { |
|
|
|
|
// Gets the value of the flag as a string.
|
|
|
|
|
const char* const value_str = ParseFlagValue(str, flag, false); |
|
|
|
|
|
|
|
|
@ -5229,7 +5232,7 @@ static const char kColorEncodedHelpMessage[] = |
|
|
|
|
"(not one in your own code or tests), please report it to\n" |
|
|
|
|
"@G<" GTEST_DEV_EMAIL_ ">@D.\n"; |
|
|
|
|
|
|
|
|
|
bool ParseGoogleTestFlag(const char* const arg) { |
|
|
|
|
static bool ParseGoogleTestFlag(const char* const arg) { |
|
|
|
|
return ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag, |
|
|
|
|
>EST_FLAG(also_run_disabled_tests)) || |
|
|
|
|
ParseBoolFlag(arg, kBreakOnFailureFlag, |
|
|
|
@ -5259,7 +5262,7 @@ bool ParseGoogleTestFlag(const char* const arg) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if GTEST_USE_OWN_FLAGFILE_FLAG_ |
|
|
|
|
void LoadFlagsFromFile(const std::string& path) { |
|
|
|
|
static void LoadFlagsFromFile(const std::string& path) { |
|
|
|
|
FILE* flagfile = posix::FOpen(path.c_str(), "r"); |
|
|
|
|
if (!flagfile) { |
|
|
|
|
GTEST_LOG_(FATAL) << "Unable to open file \"" |
|
|
|
|