aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-02-06 00:47:20 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-02-06 00:47:20 +0000
commit37504994338c114247519331237831f88a9a7c40 (patch)
treea7c84a0c95dd0bb3af5e23cd4cce7dba4c4bc8f2 /include
parentad99ca14461f0e929d835d29518e11c05e8d41f0 (diff)
downloadgoogletest-37504994338c114247519331237831f88a9a7c40.tar.gz
googletest-37504994338c114247519331237831f88a9a7c40.tar.bz2
googletest-37504994338c114247519331237831f88a9a7c40.zip
Adds tests for EXPECT_FATAL_FAILURE and reduces the golden file bloat (by Zhanyong Wan). Fixes more warnings on Windows (by Vlad Losev).
Diffstat (limited to 'include')
-rw-r--r--include/gtest/internal/gtest-internal.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/gtest/internal/gtest-internal.h b/include/gtest/internal/gtest-internal.h
index 541c89b8..b28da96e 100644
--- a/include/gtest/internal/gtest-internal.h
+++ b/include/gtest/internal/gtest-internal.h
@@ -749,7 +749,7 @@ String GetCurrentOsStackTraceExceptTop(UnitTest* unit_test, int skip_count);
int GetFailedPartCount(const TestResult* result);
// A helper for suppressing warnings on unreachable code in some macros.
-inline bool True() { return true; }
+bool AlwaysTrue();
} // namespace internal
} // namespace testing
@@ -767,12 +767,18 @@ inline bool True() { return true; }
#define GTEST_SUCCESS_(message) \
GTEST_MESSAGE_(message, ::testing::TPRT_SUCCESS)
+// Suppresses MSVC warnings 4072 (unreachable code) for the code following
+// statement if it returns or throws (or doesn't return or throw in some
+// situations).
+#define GTEST_HIDE_UNREACHABLE_CODE_(statement) \
+ if (::testing::internal::AlwaysTrue()) { statement; }
+
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \
bool gtest_caught_expected = false; \
try { \
- statement; \
+ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
} \
catch (expected_exception const&) { \
gtest_caught_expected = true; \
@@ -796,7 +802,7 @@ inline bool True() { return true; }
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \
try { \
- statement; \
+ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
} \
catch (...) { \
gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \
@@ -812,7 +818,7 @@ inline bool True() { return true; }
if (const char* gtest_msg = "") { \
bool gtest_caught_any = false; \
try { \
- statement; \
+ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
} \
catch (...) { \
gtest_caught_any = true; \
@@ -838,7 +844,7 @@ inline bool True() { return true; }
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (const char* gtest_msg = "") { \
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
- if (::testing::internal::True()) { statement; } \
+ GTEST_HIDE_UNREACHABLE_CODE_(statement); \
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
gtest_msg = "Expected: " #statement " doesn't generate new fatal " \
"failures in the current thread.\n" \