mirror of
https://github.com/google/googletest.git
synced 2025-12-08 08:37:20 +08:00
Merge 2ce0685f76 into 75e834700d
Closes #1544 With refinements and changes PiperOrigin-RevId: 215273083
This commit is contained in:
committed by
Gennadiy Civil
parent
2e91bbcf6f
commit
00938b2b22
@@ -53,7 +53,8 @@ class GTEST_API_ TestPartResult {
|
||||
enum Type {
|
||||
kSuccess, // Succeeded.
|
||||
kNonFatalFailure, // Failed but the test can continue.
|
||||
kFatalFailure // Failed and the test should be terminated.
|
||||
kFatalFailure, // Failed and the test should be terminated.
|
||||
kSkip // Skipped.
|
||||
};
|
||||
|
||||
// C'tor. TestPartResult does NOT have a default constructor.
|
||||
@@ -89,18 +90,21 @@ class GTEST_API_ TestPartResult {
|
||||
// Gets the message associated with the test part.
|
||||
const char* message() const { return message_.c_str(); }
|
||||
|
||||
// Returns true iff the test part was skipped.
|
||||
bool skipped() const { return type_ == kSkip; }
|
||||
|
||||
// Returns true iff the test part passed.
|
||||
bool passed() const { return type_ == kSuccess; }
|
||||
|
||||
// Returns true iff the test part failed.
|
||||
bool failed() const { return type_ != kSuccess; }
|
||||
|
||||
// Returns true iff the test part non-fatally failed.
|
||||
bool nonfatally_failed() const { return type_ == kNonFatalFailure; }
|
||||
|
||||
// Returns true iff the test part fatally failed.
|
||||
bool fatally_failed() const { return type_ == kFatalFailure; }
|
||||
|
||||
// Returns true iff the test part failed.
|
||||
bool failed() const { return fatally_failed() || nonfatally_failed(); }
|
||||
|
||||
private:
|
||||
Type type_;
|
||||
|
||||
|
||||
@@ -440,6 +440,9 @@ class GTEST_API_ Test {
|
||||
// Returns true iff the current test has a non-fatal failure.
|
||||
static bool HasNonfatalFailure();
|
||||
|
||||
// Returns true iff the current test was skipped.
|
||||
static bool IsSkipped();
|
||||
|
||||
// Returns true iff the current test has a (either fatal or
|
||||
// non-fatal) failure.
|
||||
static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }
|
||||
@@ -574,7 +577,10 @@ class GTEST_API_ TestResult {
|
||||
int test_property_count() const;
|
||||
|
||||
// Returns true iff the test passed (i.e. no test part failed).
|
||||
bool Passed() const { return !Failed(); }
|
||||
bool Passed() const { return !Skipped() && !Failed(); }
|
||||
|
||||
// Returns true iff the test was skipped.
|
||||
bool Skipped() const;
|
||||
|
||||
// Returns true iff the test failed.
|
||||
bool Failed() const;
|
||||
@@ -854,6 +860,9 @@ class GTEST_API_ TestCase {
|
||||
// Gets the number of successful tests in this test case.
|
||||
int successful_test_count() const;
|
||||
|
||||
// Gets the number of skipped tests in this test case.
|
||||
int skipped_test_count() const;
|
||||
|
||||
// Gets the number of failed tests in this test case.
|
||||
int failed_test_count() const;
|
||||
|
||||
@@ -936,6 +945,11 @@ class GTEST_API_ TestCase {
|
||||
return test_info->should_run() && test_info->result()->Passed();
|
||||
}
|
||||
|
||||
// Returns true iff test skipped.
|
||||
static bool TestSkipped(const TestInfo* test_info) {
|
||||
return test_info->should_run() && test_info->result()->Skipped();
|
||||
}
|
||||
|
||||
// Returns true iff test failed.
|
||||
static bool TestFailed(const TestInfo* test_info) {
|
||||
return test_info->should_run() && test_info->result()->Failed();
|
||||
@@ -1258,6 +1272,9 @@ class GTEST_API_ UnitTest {
|
||||
// Gets the number of successful tests.
|
||||
int successful_test_count() const;
|
||||
|
||||
// Gets the number of skipped tests.
|
||||
int skipped_test_count() const;
|
||||
|
||||
// Gets the number of failed tests.
|
||||
int failed_test_count() const;
|
||||
|
||||
@@ -1835,6 +1852,11 @@ class TestWithParam : public Test, public WithParamInterface<T> {
|
||||
|
||||
// Macros for indicating success/failure in test code.
|
||||
|
||||
// Skips test in runtime.
|
||||
// Skipping test aborts current function.
|
||||
// Skipped tests are neither successful nor failed.
|
||||
#define GTEST_SKIP() GTEST_SKIP_("Skipped")
|
||||
|
||||
// ADD_FAILURE unconditionally adds a failure to the current test.
|
||||
// SUCCEED generates a success - it doesn't automatically make the
|
||||
// current test successful, as a test is only successful when it has
|
||||
|
||||
@@ -1208,7 +1208,10 @@ class NativeArray {
|
||||
#define GTEST_SUCCESS_(message) \
|
||||
GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)
|
||||
|
||||
// Suppress MSVC warning 4702 (unreachable code) for the code following
|
||||
#define GTEST_SKIP_(message) \
|
||||
return GTEST_MESSAGE_(message, ::testing::TestPartResult::kSkip)
|
||||
|
||||
// Suppress MSVC warning 4072 (unreachable code) for the code following
|
||||
// statement if it returns or throws (or doesn't return or throw in some
|
||||
// situations).
|
||||
#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \
|
||||
|
||||
Reference in New Issue
Block a user