Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
a3b85916
Commit
a3b85916
authored
May 31, 2012
by
zhanyong.wan
Browse files
Fixes threading annotations and compatibility with C++11, which doesn't
allow exepctions to be thrown in a destructor.
parent
cdb24f86
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
10 deletions
+16
-10
src/gtest.cc
src/gtest.cc
+2
-2
test/gtest_catch_exceptions_test.py
test/gtest_catch_exceptions_test.py
+11
-8
test/gtest_catch_exceptions_test_.cc
test/gtest_catch_exceptions_test_.cc
+3
-0
No files found.
src/gtest.cc
View file @
a3b85916
...
@@ -3530,7 +3530,7 @@ void StreamingListener::MakeConnection() {
...
@@ -3530,7 +3530,7 @@ void StreamingListener::MakeConnection() {
// Pushes the given source file location and message onto a per-thread
// Pushes the given source file location and message onto a per-thread
// trace stack maintained by Google Test.
// trace stack maintained by Google Test.
ScopedTrace
::
ScopedTrace
(
const
char
*
file
,
int
line
,
const
Message
&
message
)
ScopedTrace
::
ScopedTrace
(
const
char
*
file
,
int
line
,
const
Message
&
message
)
GTEST_LOCK_EXCLUDED_
(
UnitTest
::
mutex_
)
{
GTEST_LOCK_EXCLUDED_
(
&
UnitTest
::
mutex_
)
{
TraceInfo
trace
;
TraceInfo
trace
;
trace
.
file
=
file
;
trace
.
file
=
file
;
trace
.
line
=
line
;
trace
.
line
=
line
;
...
@@ -3541,7 +3541,7 @@ ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
...
@@ -3541,7 +3541,7 @@ ScopedTrace::ScopedTrace(const char* file, int line, const Message& message)
// Pops the info pushed by the c'tor.
// Pops the info pushed by the c'tor.
ScopedTrace
::~
ScopedTrace
()
ScopedTrace
::~
ScopedTrace
()
GTEST_LOCK_EXCLUDED_
(
UnitTest
::
mutex_
)
{
GTEST_LOCK_EXCLUDED_
(
&
UnitTest
::
mutex_
)
{
UnitTest
::
GetInstance
()
->
PopGTestTrace
();
UnitTest
::
GetInstance
()
->
PopGTestTrace
();
}
}
...
...
test/gtest_catch_exceptions_test.py
View file @
a3b85916
...
@@ -117,6 +117,9 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
...
@@ -117,6 +117,9 @@ class CatchCxxExceptionsTest(gtest_test_utils.TestCase):
'"CxxExceptionInConstructorTest" (no quotes) '
'"CxxExceptionInConstructorTest" (no quotes) '
'appears on the same line as words "called unexpectedly"'
)
'appears on the same line as words "called unexpectedly"'
)
if
(
'CxxExceptionInDestructorTest.ThrowsExceptionInDestructor'
in
EX_BINARY_OUTPUT
):
def
testCatchesCxxExceptionsInFixtureDestructor
(
self
):
def
testCatchesCxxExceptionsInFixtureDestructor
(
self
):
self
.
assert_
(
'C++ exception with description '
self
.
assert_
(
'C++ exception with description '
'"Standard C++ exception" thrown '
'"Standard C++ exception" thrown '
...
...
test/gtest_catch_exceptions_test_.cc
View file @
a3b85916
...
@@ -137,6 +137,8 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
...
@@ -137,6 +137,8 @@ TEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {
<<
"called unexpectedly."
;
<<
"called unexpectedly."
;
}
}
// Exceptions in destructors are not supported in C++11.
#if !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
class
CxxExceptionInDestructorTest
:
public
Test
{
class
CxxExceptionInDestructorTest
:
public
Test
{
public:
public:
static
void
TearDownTestCase
()
{
static
void
TearDownTestCase
()
{
...
@@ -153,6 +155,7 @@ class CxxExceptionInDestructorTest : public Test {
...
@@ -153,6 +155,7 @@ class CxxExceptionInDestructorTest : public Test {
};
};
TEST_F
(
CxxExceptionInDestructorTest
,
ThrowsExceptionInDestructor
)
{}
TEST_F
(
CxxExceptionInDestructorTest
,
ThrowsExceptionInDestructor
)
{}
#endif // C++11 mode
class
CxxExceptionInSetUpTestCaseTest
:
public
Test
{
class
CxxExceptionInSetUpTestCaseTest
:
public
Test
{
public:
public:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment