aboutsummaryrefslogtreecommitdiffstats
path: root/include/gtest/gtest-spi.h
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-09-30 20:23:50 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2009-09-30 20:23:50 +0000
commitf8b268ee86ca74bba3276352f1e7de53d1336c3e (patch)
tree37e8c4680f5f6763c18aaa2739446c8ba08501f4 /include/gtest/gtest-spi.h
parentb50ef44a3527d958270ff1f08cb99e3ac633bd17 (diff)
downloadgoogletest-f8b268ee86ca74bba3276352f1e7de53d1336c3e.tar.gz
googletest-f8b268ee86ca74bba3276352f1e7de53d1336c3e.tar.bz2
googletest-f8b268ee86ca74bba3276352f1e7de53d1336c3e.zip
Makes gtest compile cleanly with MSVC's /W4 (by Zhanyong Wan).
Renames EventListenrs to TestEventListeners (by Zhanyong Wan). Fixes invalid characters in XML report (by Vlad Losev). Refacotrs SConscript (by Vlad Losev).
Diffstat (limited to 'include/gtest/gtest-spi.h')
-rw-r--r--include/gtest/gtest-spi.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/include/gtest/gtest-spi.h b/include/gtest/gtest-spi.h
index db0100ff..2953411b 100644
--- a/include/gtest/gtest-spi.h
+++ b/include/gtest/gtest-spi.h
@@ -150,7 +150,7 @@ class SingleFailureChecker {
INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
GTestExpectFatalFailureHelper::Execute();\
}\
- } while (false)
+ } while (::testing::internal::AlwaysFalse())
#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
do { \
@@ -167,7 +167,7 @@ class SingleFailureChecker {
INTERCEPT_ALL_THREADS, &gtest_failures);\
GTestExpectFatalFailureHelper::Execute();\
}\
- } while (false)
+ } while (::testing::internal::AlwaysFalse())
// A macro for testing Google Test assertions or code that's expected to
// generate Google Test non-fatal failures. It asserts that the given
@@ -190,8 +190,17 @@ class SingleFailureChecker {
// Note that even though the implementations of the following two
// macros are much alike, we cannot refactor them to use a common
// helper macro, due to some peculiarity in how the preprocessor
-// works. The AcceptsMacroThatExpandsToUnprotectedComma test in
-// gtest_unittest.cc will fail to compile if we do that.
+// works. If we do that, the code won't compile when the user gives
+// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that
+// expands to code containing an unprotected comma. The
+// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc
+// catches that.
+//
+// For the same reason, we have to write
+// if (::testing::internal::AlwaysTrue()) { statement; }
+// instead of
+// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)
+// to avoid an MSVC warning on unreachable code.
#define EXPECT_NONFATAL_FAILURE(statement, substr) \
do {\
::testing::TestPartResultArray gtest_failures;\
@@ -202,9 +211,9 @@ class SingleFailureChecker {
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter:: \
INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\
- statement;\
+ if (::testing::internal::AlwaysTrue()) { statement; }\
}\
- } while (false)
+ } while (::testing::internal::AlwaysFalse())
#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \
do {\
@@ -216,8 +225,8 @@ class SingleFailureChecker {
::testing::ScopedFakeTestPartResultReporter gtest_reporter(\
::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS,\
&gtest_failures);\
- statement;\
+ if (::testing::internal::AlwaysTrue()) { statement; }\
}\
- } while (false)
+ } while (::testing::internal::AlwaysFalse())
#endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_