summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorjgm@google.com <jgm@google.com@861a406c-534a-0410-8894-cb66d6ee9925>2012-03-09 17:12:39 +0000
committerjgm@google.com <jgm@google.com@861a406c-534a-0410-8894-cb66d6ee9925>2012-03-09 17:12:39 +0000
commit7a574c99ea1d474f8ec5f040deba54169120f063 (patch)
treedea331f222e639cfc37f481766bbc88ce20dc7cb /include
parent62576d5b3fb1173e4ad1b7fbc98f9d58323dfc64 (diff)
downloadgtest-7a574c99ea1d474f8ec5f040deba54169120f063.tar.gz
gtest-7a574c99ea1d474f8ec5f040deba54169120f063.tar.bz2
gtest-7a574c99ea1d474f8ec5f040deba54169120f063.tar.xz
Misc small updates to some debug death code, and to messages streaming to macros
git-svn-id: http://googletest.googlecode.com/svn/trunk@612 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'include')
-rw-r--r--include/gtest/gtest-death-test.h6
-rw-r--r--include/gtest/gtest-param-test.h2
-rw-r--r--include/gtest/gtest-param-test.h.pump2
-rw-r--r--include/gtest/gtest.h6
-rw-r--r--include/gtest/internal/gtest-death-test-internal.h11
5 files changed, 16 insertions, 11 deletions
diff --git a/include/gtest/gtest-death-test.h b/include/gtest/gtest-death-test.h
index 16f08b8..957a69c 100644
--- a/include/gtest/gtest-death-test.h
+++ b/include/gtest/gtest-death-test.h
@@ -86,7 +86,7 @@ GTEST_API_ bool InDeathTestChild();
// for (int i = 0; i < 5; i++) {
// EXPECT_DEATH(server.ProcessRequest(i),
// "Invalid request .* in ProcessRequest()")
-// << "Failed to die on request " << i);
+// << "Failed to die on request " << i;
// }
//
// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
@@ -256,10 +256,10 @@ class GTEST_API_ KilledBySignal {
# ifdef NDEBUG
# define EXPECT_DEBUG_DEATH(statement, regex) \
- do { statement; } while (::testing::internal::AlwaysFalse())
+ GTEST_EXECUTE_STATEMENT_(statement, regex)
# define ASSERT_DEBUG_DEATH(statement, regex) \
- do { statement; } while (::testing::internal::AlwaysFalse())
+ GTEST_EXECUTE_STATEMENT_(statement, regex)
# else
diff --git a/include/gtest/gtest-param-test.h b/include/gtest/gtest-param-test.h
index 6407cfd..d6702c8 100644
--- a/include/gtest/gtest-param-test.h
+++ b/include/gtest/gtest-param-test.h
@@ -1257,7 +1257,7 @@ inline internal::ParamGenerator<bool> Bool() {
// Boolean flags:
//
// class FlagDependentTest
-// : public testing::TestWithParam<tuple(bool, bool)> > {
+// : public testing::TestWithParam<tuple<bool, bool> > {
// virtual void SetUp() {
// // Assigns external_flag_1 and external_flag_2 values from the tuple.
// tie(external_flag_1, external_flag_2) = GetParam();
diff --git a/include/gtest/gtest-param-test.h.pump b/include/gtest/gtest-param-test.h.pump
index 401cb51..2dc9303 100644
--- a/include/gtest/gtest-param-test.h.pump
+++ b/include/gtest/gtest-param-test.h.pump
@@ -414,7 +414,7 @@ inline internal::ParamGenerator<bool> Bool() {
// Boolean flags:
//
// class FlagDependentTest
-// : public testing::TestWithParam<tuple(bool, bool)> > {
+// : public testing::TestWithParam<tuple<bool, bool> > {
// virtual void SetUp() {
// // Assigns external_flag_1 and external_flag_2 values from the tuple.
// tie(external_flag_1, external_flag_2) = GetParam();
diff --git a/include/gtest/gtest.h b/include/gtest/gtest.h
index 2d570a2..226307e 100644
--- a/include/gtest/gtest.h
+++ b/include/gtest/gtest.h
@@ -1731,12 +1731,6 @@ class TestWithParam : public Test, public WithParamInterface<T> {
// usually want the fail-fast behavior of FAIL and ASSERT_*, but those
// writing data-driven tests often find themselves using ADD_FAILURE
// and EXPECT_* more.
-//
-// Examples:
-//
-// EXPECT_TRUE(server.StatusIsOK());
-// ASSERT_FALSE(server.HasPendingRequest(port))
-// << "There are still pending requests " << "on port " << port;
// Generates a nonfatal failure with a generic message.
#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed")
diff --git a/include/gtest/internal/gtest-death-test-internal.h b/include/gtest/internal/gtest-death-test-internal.h
index 1d9f83b..22bb97f 100644
--- a/include/gtest/internal/gtest-death-test-internal.h
+++ b/include/gtest/internal/gtest-death-test-internal.h
@@ -217,6 +217,17 @@ GTEST_API_ bool ExitedUnsuccessfully(int exit_status);
// The symbol "fail" here expands to something into which a message
// can be streamed.
+// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in
+// NDEBUG mode. In this case we need the statements to be executed, the regex is
+// ignored, and the macro must accept a streamed message even though the message
+// is never printed.
+# define GTEST_EXECUTE_STATEMENT_(statement, regex) \
+ GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
+ if (::testing::internal::AlwaysTrue()) { \
+ GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
+ } else \
+ ::testing::Message()
+
// A class representing the parsed contents of the
// --gtest_internal_run_death_test flag, as it existed when
// RUN_ALL_TESTS was called.