summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2012-05-31 20:37:13 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2012-05-31 20:37:13 +0000
commitaa3c420019cb0215b00013cb94658a917ec4f712 (patch)
treeed3a1185c93839b0026103187b5fad7dd349f359
parent69c199d08a8731a9d5e66004d1b434a21016c3c8 (diff)
downloadgtest-aa3c420019cb0215b00013cb94658a917ec4f712.tar.gz
gtest-aa3c420019cb0215b00013cb94658a917ec4f712.tar.bz2
gtest-aa3c420019cb0215b00013cb94658a917ec4f712.tar.xz
Fixes threading annotations and compatibility with C++11, which doesn't
allow exepctions to be thrown in a destructor. git-svn-id: http://googletest.googlecode.com/svn/trunk@615 861a406c-534a-0410-8894-cb66d6ee9925
-rw-r--r--src/gtest.cc4
-rwxr-xr-xtest/gtest_catch_exceptions_test.py19
-rw-r--r--test/gtest_catch_exceptions_test_.cc3
3 files changed, 16 insertions, 10 deletions
diff --git a/src/gtest.cc b/src/gtest.cc
index 56af646..78f113e 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -3530,7 +3530,7 @@ void StreamingListener::MakeConnection() {
// Pushes the given source file location and message onto a per-thread
// trace stack maintained by Google Test.
ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
- GTEST_LOCK_EXCLUDED_(UnitTest::mutex_) {
+ GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
TraceInfo trace;
trace.file = file;
trace.line = line;
@@ -3541,7 +3541,7 @@ ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
// Pops the info pushed by the c'tor.
ScopedTrace::~ScopedTrace()
- GTEST_LOCK_EXCLUDED_(UnitTest::mutex_) {
+ GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
UnitTest::GetInstance()->PopGTestTrace();
}
diff --git a/test/gtest_catch_exceptions_test.py b/test/gtest_catch_exceptions_test.py
index 7fd7dba..d7ef10e 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 a35103f..d0fc82c 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: