|
|
|
@ -177,7 +177,7 @@ namespace internal { |
|
|
|
|
// stack trace.
|
|
|
|
|
const char kStackTraceMarker[] = "\nStack trace:\n"; |
|
|
|
|
|
|
|
|
|
// g_help_flag is true iff the --help flag or an equivalent form is
|
|
|
|
|
// g_help_flag is true if the --help flag or an equivalent form is
|
|
|
|
|
// specified on the command line.
|
|
|
|
|
bool g_help_flag = false; |
|
|
|
|
|
|
|
|
@ -217,12 +217,12 @@ GTEST_DEFINE_bool_( |
|
|
|
|
GTEST_DEFINE_bool_( |
|
|
|
|
break_on_failure, |
|
|
|
|
internal::BoolFromGTestEnv("break_on_failure", false), |
|
|
|
|
"True iff a failed assertion should be a debugger break-point."); |
|
|
|
|
"True if a failed assertion should be a debugger break-point."); |
|
|
|
|
|
|
|
|
|
GTEST_DEFINE_bool_( |
|
|
|
|
catch_exceptions, |
|
|
|
|
internal::BoolFromGTestEnv("catch_exceptions", true), |
|
|
|
|
"True iff " GTEST_NAME_ |
|
|
|
|
"True if " GTEST_NAME_ |
|
|
|
|
" should catch exceptions and treat them as test failures."); |
|
|
|
|
|
|
|
|
|
GTEST_DEFINE_string_( |
|
|
|
@ -273,13 +273,13 @@ GTEST_DEFINE_string_( |
|
|
|
|
GTEST_DEFINE_bool_( |
|
|
|
|
print_time, |
|
|
|
|
internal::BoolFromGTestEnv("print_time", true), |
|
|
|
|
"True iff " GTEST_NAME_ |
|
|
|
|
"True if " GTEST_NAME_ |
|
|
|
|
" should display elapsed time in text output."); |
|
|
|
|
|
|
|
|
|
GTEST_DEFINE_bool_( |
|
|
|
|
print_utf8, |
|
|
|
|
internal::BoolFromGTestEnv("print_utf8", true), |
|
|
|
|
"True iff " GTEST_NAME_ |
|
|
|
|
"True if " GTEST_NAME_ |
|
|
|
|
" prints UTF8 characters as text."); |
|
|
|
|
|
|
|
|
|
GTEST_DEFINE_int32_( |
|
|
|
@ -296,13 +296,13 @@ GTEST_DEFINE_int32_( |
|
|
|
|
|
|
|
|
|
GTEST_DEFINE_bool_( |
|
|
|
|
show_internal_stack_frames, false, |
|
|
|
|
"True iff " GTEST_NAME_ " should include internal stack frames when " |
|
|
|
|
"True if " GTEST_NAME_ " should include internal stack frames when " |
|
|
|
|
"printing test failure stack traces."); |
|
|
|
|
|
|
|
|
|
GTEST_DEFINE_bool_( |
|
|
|
|
shuffle, |
|
|
|
|
internal::BoolFromGTestEnv("shuffle", false), |
|
|
|
|
"True iff " GTEST_NAME_ |
|
|
|
|
"True if " GTEST_NAME_ |
|
|
|
|
" should randomize tests' order on every run."); |
|
|
|
|
|
|
|
|
|
GTEST_DEFINE_int32_( |
|
|
|
@ -354,7 +354,7 @@ UInt32 Random::Generate(UInt32 range) { |
|
|
|
|
return state_ % range; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// GTestIsInitialized() returns true iff the user has initialized
|
|
|
|
|
// GTestIsInitialized() returns true if the user has initialized
|
|
|
|
|
// Google Test. Useful for catching the user mistake of not initializing
|
|
|
|
|
// Google Test before calling RUN_ALL_TESTS().
|
|
|
|
|
static bool GTestIsInitialized() { return GetArgvs().size() > 0; } |
|
|
|
@ -371,17 +371,17 @@ static int SumOverTestSuiteList(const std::vector<TestSuite*>& case_list, |
|
|
|
|
return sum; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test suite passed.
|
|
|
|
|
// Returns true if the test suite passed.
|
|
|
|
|
static bool TestSuitePassed(const TestSuite* test_suite) { |
|
|
|
|
return test_suite->should_run() && test_suite->Passed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test suite failed.
|
|
|
|
|
// Returns true if the test suite failed.
|
|
|
|
|
static bool TestSuiteFailed(const TestSuite* test_suite) { |
|
|
|
|
return test_suite->should_run() && test_suite->Failed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff test_suite contains at least one test that should
|
|
|
|
|
// Returns true if test_suite contains at least one test that should
|
|
|
|
|
// run.
|
|
|
|
|
static bool ShouldRunTestSuite(const TestSuite* test_suite) { |
|
|
|
|
return test_suite->should_run(); |
|
|
|
@ -482,7 +482,7 @@ std::string UnitTestOptions::GetAbsolutePathToOutputFile() { |
|
|
|
|
return result.string(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the wildcard pattern matches the string. The
|
|
|
|
|
// Returns true if the wildcard pattern matches the string. The
|
|
|
|
|
// first ':' or '\0' character in pattern marks the end of it.
|
|
|
|
|
//
|
|
|
|
|
// This recursive algorithm isn't very efficient, but is clear and
|
|
|
|
@ -525,7 +525,7 @@ bool UnitTestOptions::MatchesFilter( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the user-specified filter matches the test suite
|
|
|
|
|
// Returns true if the user-specified filter matches the test suite
|
|
|
|
|
// name and the test name.
|
|
|
|
|
bool UnitTestOptions::FilterMatchesTest(const std::string& test_suite_name, |
|
|
|
|
const std::string& test_name) { |
|
|
|
@ -910,7 +910,7 @@ const char* String::Utf16ToAnsi(LPCWSTR utf16_str) { |
|
|
|
|
|
|
|
|
|
#endif // GTEST_OS_WINDOWS_MOBILE
|
|
|
|
|
|
|
|
|
|
// Compares two C strings. Returns true iff they have the same content.
|
|
|
|
|
// Compares two C strings. Returns true if they have the same content.
|
|
|
|
|
//
|
|
|
|
|
// Unlike strcmp(), this function can handle NULL argument(s). A NULL
|
|
|
|
|
// C string is considered different to any non-NULL C string,
|
|
|
|
@ -1320,7 +1320,7 @@ std::vector<std::string> SplitEscapedString(const std::string& str) { |
|
|
|
|
// lhs_value: "5"
|
|
|
|
|
// rhs_value: "6"
|
|
|
|
|
//
|
|
|
|
|
// The ignoring_case parameter is true iff the assertion is a
|
|
|
|
|
// The ignoring_case parameter is true if the assertion is a
|
|
|
|
|
// *_STRCASEEQ*. When it's true, the string "Ignoring case" will
|
|
|
|
|
// be inserted into the message.
|
|
|
|
|
AssertionResult EqFailure(const char* lhs_expression, |
|
|
|
@ -1563,7 +1563,7 @@ namespace { |
|
|
|
|
|
|
|
|
|
// Helper functions for implementing IsSubString() and IsNotSubstring().
|
|
|
|
|
|
|
|
|
|
// This group of overloaded functions return true iff needle is a
|
|
|
|
|
// This group of overloaded functions return true if needle is a
|
|
|
|
|
// substring of haystack. NULL is considered a substring of itself
|
|
|
|
|
// only.
|
|
|
|
|
|
|
|
|
@ -1865,7 +1865,7 @@ std::string String::ShowWideCString(const wchar_t * wide_c_str) { |
|
|
|
|
return internal::WideStringToUtf8(wide_c_str, -1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Compares two wide C strings. Returns true iff they have the same
|
|
|
|
|
// Compares two wide C strings. Returns true if they have the same
|
|
|
|
|
// content.
|
|
|
|
|
//
|
|
|
|
|
// Unlike wcscmp(), this function can handle NULL argument(s). A NULL
|
|
|
|
@ -1910,7 +1910,7 @@ AssertionResult CmpHelperSTRNE(const char* s1_expression, |
|
|
|
|
<< " vs " << PrintToString(s2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Compares two C strings, ignoring case. Returns true iff they have
|
|
|
|
|
// Compares two C strings, ignoring case. Returns true if they have
|
|
|
|
|
// the same content.
|
|
|
|
|
//
|
|
|
|
|
// Unlike strcasecmp(), this function can handle NULL argument(s). A
|
|
|
|
@ -1922,7 +1922,7 @@ bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) { |
|
|
|
|
return posix::StrCaseCmp(lhs, rhs) == 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Compares two wide C strings, ignoring case. Returns true iff they
|
|
|
|
|
// Compares two wide C strings, ignoring case. Returns true if they
|
|
|
|
|
// have the same content.
|
|
|
|
|
//
|
|
|
|
|
// Unlike wcscasecmp(), this function can handle NULL argument(s).
|
|
|
|
@ -1956,7 +1956,7 @@ bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, |
|
|
|
|
#endif // OS selector
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff str ends with the given suffix, ignoring case.
|
|
|
|
|
// Returns true if str ends with the given suffix, ignoring case.
|
|
|
|
|
// Any string is considered to end with an empty suffix.
|
|
|
|
|
bool String::EndsWithCaseInsensitive( |
|
|
|
|
const std::string& str, const std::string& suffix) { |
|
|
|
@ -2198,12 +2198,12 @@ static bool TestPartSkipped(const TestPartResult& result) { |
|
|
|
|
return result.skipped(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test was skipped.
|
|
|
|
|
// Returns true if the test was skipped.
|
|
|
|
|
bool TestResult::Skipped() const { |
|
|
|
|
return !Failed() && CountIf(test_part_results_, TestPartSkipped) > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test failed.
|
|
|
|
|
// Returns true if the test failed.
|
|
|
|
|
bool TestResult::Failed() const { |
|
|
|
|
for (int i = 0; i < total_part_count(); ++i) { |
|
|
|
|
if (GetTestPartResult(i).failed()) |
|
|
|
@ -2212,22 +2212,22 @@ bool TestResult::Failed() const { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test part fatally failed.
|
|
|
|
|
// Returns true if the test part fatally failed.
|
|
|
|
|
static bool TestPartFatallyFailed(const TestPartResult& result) { |
|
|
|
|
return result.fatally_failed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test fatally failed.
|
|
|
|
|
// Returns true if the test fatally failed.
|
|
|
|
|
bool TestResult::HasFatalFailure() const { |
|
|
|
|
return CountIf(test_part_results_, TestPartFatallyFailed) > 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test part non-fatally failed.
|
|
|
|
|
// Returns true if the test part non-fatally failed.
|
|
|
|
|
static bool TestPartNonfatallyFailed(const TestPartResult& result) { |
|
|
|
|
return result.nonfatally_failed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test has a non-fatal failure.
|
|
|
|
|
// Returns true if the test has a non-fatal failure.
|
|
|
|
|
bool TestResult::HasNonfatalFailure() const { |
|
|
|
|
return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0; |
|
|
|
|
} |
|
|
|
@ -2523,18 +2523,18 @@ void Test::Run() { |
|
|
|
|
this, &Test::TearDown, "TearDown()"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the current test has a fatal failure.
|
|
|
|
|
// Returns true if the current test has a fatal failure.
|
|
|
|
|
bool Test::HasFatalFailure() { |
|
|
|
|
return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the current test has a non-fatal failure.
|
|
|
|
|
// Returns true if the current test has a non-fatal failure.
|
|
|
|
|
bool Test::HasNonfatalFailure() { |
|
|
|
|
return internal::GetUnitTestImpl()->current_test_result()-> |
|
|
|
|
HasNonfatalFailure(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the current test was skipped.
|
|
|
|
|
// Returns true if the current test was skipped.
|
|
|
|
|
bool Test::IsSkipped() { |
|
|
|
|
return internal::GetUnitTestImpl()->current_test_result()->Skipped(); |
|
|
|
|
} |
|
|
|
@ -2633,7 +2633,7 @@ class TestNameIs { |
|
|
|
|
explicit TestNameIs(const char* name) |
|
|
|
|
: name_(name) {} |
|
|
|
|
|
|
|
|
|
// Returns true iff the test name of test_info matches name_.
|
|
|
|
|
// Returns true if the test name of test_info matches name_.
|
|
|
|
|
bool operator()(const TestInfo * test_info) const { |
|
|
|
|
return test_info && test_info->name() == name_; |
|
|
|
|
} |
|
|
|
@ -2992,7 +2992,7 @@ static const char* GetAnsiColorCode(GTestColor color) { |
|
|
|
|
|
|
|
|
|
#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE
|
|
|
|
|
|
|
|
|
|
// Returns true iff Google Test should use colors in the output.
|
|
|
|
|
// Returns true if Google Test should use colors in the output.
|
|
|
|
|
bool ShouldUseColor(bool stdout_is_tty) { |
|
|
|
|
const char* const gtest_color = GTEST_FLAG(color).c_str(); |
|
|
|
|
|
|
|
|
@ -4669,10 +4669,10 @@ internal::TimeInMillis UnitTest::elapsed_time() const { |
|
|
|
|
return impl()->elapsed_time(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Returns true iff the unit test passed (i.e. all test suites passed).
|
|
|
|
|
// Returns true if the unit test passed (i.e. all test suites passed).
|
|
|
|
|
bool UnitTest::Passed() const { return impl()->Passed(); } |
|
|
|
|
|
|
|
|
|
// Returns true iff the unit test failed (i.e. some test suite failed
|
|
|
|
|
// Returns true if the unit test failed (i.e. some test suite failed
|
|
|
|
|
// or something outside of all tests failed).
|
|
|
|
|
bool UnitTest::Failed() const { return impl()->Failed(); } |
|
|
|
|
|
|
|
|
@ -5111,7 +5111,7 @@ class TestSuiteNameIs { |
|
|
|
|
// Constructor.
|
|
|
|
|
explicit TestSuiteNameIs(const std::string& name) : name_(name) {} |
|
|
|
|
|
|
|
|
|
// Returns true iff the name of test_suite matches name_.
|
|
|
|
|
// Returns true if the name of test_suite matches name_.
|
|
|
|
|
bool operator()(const TestSuite* test_suite) const { |
|
|
|
|
return test_suite != nullptr && |
|
|
|
|
strcmp(test_suite->name(), name_.c_str()) == 0; |
|
|
|
@ -5182,7 +5182,7 @@ static void TearDownEnvironment(Environment* env) { env->TearDown(); } |
|
|
|
|
// All other functions called from RunAllTests() may safely assume that
|
|
|
|
|
// parameterized tests are ready to be counted and run.
|
|
|
|
|
bool UnitTestImpl::RunAllTests() { |
|
|
|
|
// True iff Google Test is initialized before RUN_ALL_TESTS() is called.
|
|
|
|
|
// True if Google Test is initialized before RUN_ALL_TESTS() is called.
|
|
|
|
|
const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized(); |
|
|
|
|
|
|
|
|
|
// Do not run any test if the --help flag was specified.
|
|
|
|
@ -5198,7 +5198,7 @@ bool UnitTestImpl::RunAllTests() { |
|
|
|
|
// protocol.
|
|
|
|
|
internal::WriteToShardStatusFileIfNeeded(); |
|
|
|
|
|
|
|
|
|
// True iff we are in a subprocess for running a thread-safe-style
|
|
|
|
|
// True if we are in a subprocess for running a thread-safe-style
|
|
|
|
|
// death test.
|
|
|
|
|
bool in_subprocess_for_death_test = false; |
|
|
|
|
|
|
|
|
@ -5231,7 +5231,7 @@ bool UnitTestImpl::RunAllTests() { |
|
|
|
|
random_seed_ = GTEST_FLAG(shuffle) ? |
|
|
|
|
GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0; |
|
|
|
|
|
|
|
|
|
// True iff at least one test has failed.
|
|
|
|
|
// True if at least one test has failed.
|
|
|
|
|
bool failed = false; |
|
|
|
|
|
|
|
|
|
TestEventListener* repeater = listeners()->repeater(); |
|
|
|
@ -5429,7 +5429,7 @@ Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Given the total number of shards, the shard index, and the test id,
|
|
|
|
|
// returns true iff the test should be run on this shard. The test id is
|
|
|
|
|
// returns true if the test should be run on this shard. The test id is
|
|
|
|
|
// some arbitrary but unique non-negative integer assigned to each test
|
|
|
|
|
// method. Assumes that 0 <= shard_index < total_shards.
|
|
|
|
|
bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) { |
|
|
|
@ -6003,7 +6003,7 @@ void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { |
|
|
|
|
void ParseGoogleTestFlagsOnly(int* argc, char** argv) { |
|
|
|
|
ParseGoogleTestFlagsOnlyImpl(argc, argv); |
|
|
|
|
|
|
|
|
|
// Fix the value of *_NSGetArgc() on macOS, but iff
|
|
|
|
|
// Fix the value of *_NSGetArgc() on macOS, but if
|
|
|
|
|
// *_NSGetArgv() == argv
|
|
|
|
|
// Only applicable to char** version of argv
|
|
|
|
|
#if GTEST_OS_MAC |
|
|
|
|