Skip to content

Commit aa3c420

Browse files
author
zhanyong.wan
committed
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
1 parent 69c199d commit aa3c420

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

src/gtest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3530,7 +3530,7 @@ void StreamingListener::MakeConnection() {
35303530
// Pushes the given source file location and message onto a per-thread
35313531
// trace stack maintained by Google Test.
35323532
ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
3533-
GTEST_LOCK_EXCLUDED_(UnitTest::mutex_) {
3533+
GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
35343534
TraceInfo trace;
35353535
trace.file = file;
35363536
trace.line = line;
@@ -3541,7 +3541,7 @@ ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
35413541

35423542
// Pops the info pushed by the c'tor.
35433543
ScopedTrace::~ScopedTrace()
3544-
GTEST_LOCK_EXCLUDED_(UnitTest::mutex_) {
3544+
GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {
35453545
UnitTest::GetInstance()->PopGTestTrace();
35463546
}
35473547

test/gtest_catch_exceptions_test.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,17 @@ def testCatchesCxxExceptionsInFixtureConstructor(self):
117117
'"CxxExceptionInConstructorTest" (no quotes) '
118118
'appears on the same line as words "called unexpectedly"')
119119

120-
def testCatchesCxxExceptionsInFixtureDestructor(self):
121-
self.assert_('C++ exception with description '
122-
'"Standard C++ exception" thrown '
123-
'in the test fixture\'s destructor'
124-
in EX_BINARY_OUTPUT)
125-
self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() '
126-
'called as expected.'
127-
in EX_BINARY_OUTPUT)
120+
if ('CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' in
121+
EX_BINARY_OUTPUT):
122+
123+
def testCatchesCxxExceptionsInFixtureDestructor(self):
124+
self.assert_('C++ exception with description '
125+
'"Standard C++ exception" thrown '
126+
'in the test fixture\'s destructor'
127+
in EX_BINARY_OUTPUT)
128+
self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() '
129+
'called as expected.'
130+
in EX_BINARY_OUTPUT)
128131

129132
def testCatchesCxxExceptionsInSetUpTestCase(self):
130133
self.assert_('C++ exception with description "Standard C++ exception"'

test/gtest_catch_exceptions_test_.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
137137
<< "called unexpectedly.";
138138
}
139139

140+
// Exceptions in destructors are not supported in C++11.
141+
#if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
140142
class CxxExceptionInDestructorTest : public Test {
141143
public:
142144
static void TearDownTestCase() {
@@ -153,6 +155,7 @@ class CxxExceptionInDestructorTest : public Test {
153155
};
154156

155157
TEST_F(CxxExceptionInDestructorTest, ThrowsExceptionInDestructor) {}
158+
#endif // C++11 mode
156159

157160
class CxxExceptionInSetUpTestCaseTest : public Test {
158161
public:

0 commit comments

Comments
 (0)