summaryrefslogtreecommitdiffstats
path: root/googletest/include
diff options
context:
space:
mode:
authorArseny Aprelev <arseny.aprelev@gmail.com>2018-10-01 20:47:09 (GMT)
committerGennadiy Civil <misterg@google.com>2018-10-02 17:03:28 (GMT)
commit00938b2b228f3b70d3d9e51f29a1505bdad43f1e (patch)
tree2bebc032627672911353925d14d1fce101a36029 /googletest/include
parent2e91bbcf6f33eb85451001be2d4c95cca86ea9fc (diff)
downloadgoogletest-00938b2b228f3b70d3d9e51f29a1505bdad43f1e.zip
googletest-00938b2b228f3b70d3d9e51f29a1505bdad43f1e.tar.gz
googletest-00938b2b228f3b70d3d9e51f29a1505bdad43f1e.tar.bz2
Merge 2ce0685f76a4db403b7b2650433a584c150f2108 into 75e834700d19aa373b428c7c746f951737354c28
Closes #1544 With refinements and changes PiperOrigin-RevId: 215273083
Diffstat (limited to 'googletest/include')
-rw-r--r--googletest/include/gtest/gtest-test-part.h12
-rw-r--r--googletest/include/gtest/gtest.h24
-rw-r--r--googletest/include/gtest/internal/gtest-internal.h5
3 files changed, 35 insertions, 6 deletions
diff --git a/googletest/include/gtest/gtest-test-part.h b/googletest/include/gtest/gtest-test-part.h
index 1c7b89e..7b30aff 100644
--- a/googletest/include/gtest/gtest-test-part.h
+++ b/googletest/include/gtest/gtest-test-part.h
@@ -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_;
diff --git a/googletest/include/gtest/gtest.h b/googletest/include/gtest/gtest.h
index 5df4b0a..8921418 100644
--- a/googletest/include/gtest/gtest.h
+++ b/googletest/include/gtest/gtest.h
@@ -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
diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h
index b762f61..380a11c 100644
--- a/googletest/include/gtest/internal/gtest-internal.h
+++ b/googletest/include/gtest/internal/gtest-internal.h
@@ -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) \