From ed8500b341c473ecf46acd13951ae5b4e3acc780 Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Fri, 7 Aug 2009 06:47:47 +0000 Subject: Implements EXPECT_DEATH_IF_SUPPORTED (by Vlad Losev); Fixes compatibility with Symbian (by Araceli Checa); Removes GetCapturedStderr()'s dependency on std::string (by Vlad Losev). --- include/gtest/gtest-death-test.h | 22 ++++++++++++++++++++++ include/gtest/internal/gtest-port.h | 4 +--- include/gtest/internal/gtest-tuple.h | 10 +++++----- 3 files changed, 28 insertions(+), 8 deletions(-) (limited to 'include/gtest') diff --git a/include/gtest/gtest-death-test.h b/include/gtest/gtest-death-test.h index dcb2b66e..410654b9 100644 --- a/include/gtest/gtest-death-test.h +++ b/include/gtest/gtest-death-test.h @@ -257,6 +257,28 @@ class KilledBySignal { #endif // NDEBUG for EXPECT_DEBUG_DEATH #endif // GTEST_HAS_DEATH_TEST + +// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and +// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if +// death tests are supported; otherwise they expand to empty. This is +// useful when you are combining death test assertions with normal test +// assertions in one test. +#if GTEST_HAS_DEATH_TEST +#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + EXPECT_DEATH(statement, regex) +#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ + ASSERT_DEATH(statement, regex) +#else +#define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + GTEST_LOG_(WARNING, \ + "Death tests are not supported on this platform. The statement" \ + " '" #statement "' can not be verified") +#define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ + GTEST_LOG_(WARNING, \ + "Death tests are not supported on this platform. The statement" \ + " '" #statement "' can not be verified") +#endif + } // namespace testing #endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h index e67a498d..58b2eaf8 100644 --- a/include/gtest/internal/gtest-port.h +++ b/include/gtest/internal/gtest-port.h @@ -696,10 +696,8 @@ inline void FlushInfoLog() { fflush(NULL); } // CaptureStderr - starts capturing stderr. // GetCapturedStderr - stops capturing stderr and returns the captured string. -#if GTEST_HAS_STD_STRING void CaptureStderr(); -::std::string GetCapturedStderr(); -#endif // GTEST_HAS_STD_STRING +String GetCapturedStderr(); #if GTEST_HAS_DEATH_TEST diff --git a/include/gtest/internal/gtest-tuple.h b/include/gtest/internal/gtest-tuple.h index 5ef49203..86b200be 100644 --- a/include/gtest/internal/gtest-tuple.h +++ b/include/gtest/internal/gtest-tuple.h @@ -38,11 +38,11 @@ #include // For ::std::pair. -// The compiler used in Symbian 5th Edition (__S60_50__) has a bug -// that prevents us from declaring the tuple template as a friend (it -// complains that tuple is redefined). This hack bypasses the bug by -// declaring the members that should otherwise be private as public. -#if defined(__SYMBIAN32__) && __S60_50__ +// The compiler used in Symbian has a bug that prevents us from declaring the +// tuple template as a friend (it complains that tuple is redefined). This +// hack bypasses the bug by declaring the members that should otherwise be +// private as public. +#if defined(__SYMBIAN32__) #define GTEST_DECLARE_TUPLE_AS_FRIEND_ public: #else #define GTEST_DECLARE_TUPLE_AS_FRIEND_ \ -- cgit v1.2.3