From a3b859162dd7a4a1798cf8753a03098f2cbdb62e Mon Sep 17 00:00:00 2001 From: "zhanyong.wan" Date: Thu, 31 May 2012 20:37:13 +0000 Subject: Fixes threading annotations and compatibility with C++11, which doesn't allow exepctions to be thrown in a destructor. --- test/gtest_catch_exceptions_test.py | 19 +++++++++++-------- test/gtest_catch_exceptions_test_.cc | 3 +++ 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/gtest_catch_exceptions_test.py b/test/gtest_catch_exceptions_test.py index 7fd7dbad..d7ef10eb 100755 --- a/test/gtest_catch_exceptions_test.py +++ b/test/gtest_catch_exceptions_test.py @@ -117,14 +117,17 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase): '"CxxExceptionInConstructorTest" (no quotes) ' 'appears on the same line as words "called unexpectedly"') - def testCatchesCxxExceptionsInFixtureDestructor(self): - self.assert_('C++ exception with description ' - '"Standard C++ exception" thrown ' - 'in the test fixture\'s destructor' - in EX_BINARY_OUTPUT) - self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() ' - 'called as expected.' - in EX_BINARY_OUTPUT) + if ('CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' in + EX_BINARY_OUTPUT): + + def testCatchesCxxExceptionsInFixtureDestructor(self): + self.assert_('C++ exception with description ' + '"Standard C++ exception" thrown ' + 'in the test fixture\'s destructor' + in EX_BINARY_OUTPUT) + self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() ' + 'called as expected.' + in EX_BINARY_OUTPUT) def testCatchesCxxExceptionsInSetUpTestCase(self): self.assert_('C++ exception with description "Standard C++ exception"' diff --git a/test/gtest_catch_exceptions_test_.cc b/test/gtest_catch_exceptions_test_.cc index a35103f0..d0fc82c9 100644 --- a/test/gtest_catch_exceptions_test_.cc +++ b/test/gtest_catch_exceptions_test_.cc @@ -137,6 +137,8 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) { << "called unexpectedly."; } +// Exceptions in destructors are not supported in C++11. +#if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L class CxxExceptionInDestructorTest : public Test { public: static void TearDownTestCase() { @@ -153,6 +155,7 @@ class CxxExceptionInDestructorTest : public Test { }; TEST_F(CxxExceptionInDestructorTest, ThrowsExceptionInDestructor) {} +#endif // C++11 mode class CxxExceptionInSetUpTestCaseTest : public Test { public: -- cgit v1.2.3