Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
bcb12fa0
Commit
bcb12fa0
authored
Aug 01, 2008
by
shiqian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes the definition of GTEST_ATTRIBUTE_UNUSED and make the tests pass in opt mode.
parent
bf9b4b48
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
33 deletions
+8
-33
gtest-port.h
include/gtest/internal/gtest-port.h
+4
-4
gtest-death-test_test.cc
test/gtest-death-test_test.cc
+2
-27
gtest_repeat_test.cc
test/gtest_repeat_test.cc
+2
-2
No files found.
include/gtest/internal/gtest-port.h
View file @
bcb12fa0
...
@@ -249,11 +249,11 @@
...
@@ -249,11 +249,11 @@
// struct Foo {
// struct Foo {
// Foo() { ... }
// Foo() { ... }
// } GTEST_ATTRIBUTE_UNUSED;
// } GTEST_ATTRIBUTE_UNUSED;
#if defined(GTEST_OS_WINDOWS) || (defined(GTEST_OS_LINUX) && defined(SWIG))
#if defined(__GNUC__) && !defined(COMPILER_ICC)
#define GTEST_ATTRIBUTE_UNUSED
#else
#define GTEST_ATTRIBUTE_UNUSED __attribute__ ((unused))
#define GTEST_ATTRIBUTE_UNUSED __attribute__ ((unused))
#endif // GTEST_OS_WINDOWS || (GTEST_OS_LINUX && SWIG)
#else
#define GTEST_ATTRIBUTE_UNUSED
#endif
// A macro to disallow the evil copy constructor and operator= functions
// A macro to disallow the evil copy constructor and operator= functions
// This should be used in the private: declarations for a class.
// This should be used in the private: declarations for a class.
...
...
test/gtest-death-test_test.cc
View file @
bcb12fa0
...
@@ -467,31 +467,6 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
...
@@ -467,31 +467,6 @@ TEST_F(TestForDeathTest, TestExpectDebugDeath) {
#endif
#endif
}
}
// Tests that EXPECT_DEBUG_DEATH works as expected,
// that is, in debug mode, it:
// 1. Asserts on death.
// 2. Has no side effect.
//
// And in opt mode, it:
// 1. Has side effects and returns the expected value (12).
TEST_F
(
TestForDeathTest
,
TestExpectDebugDeathM
)
{
int
sideeffect
=
0
;
EXPECT_DEBUG_DEATH
({
// NOLINT
// Tests that the return value is 12 in opt mode.
EXPECT_EQ
(
12
,
DieInDebugElse12
(
&
sideeffect
));
// Tests that the side effect occurrs in opt mode.
EXPECT_EQ
(
12
,
sideeffect
);
},
"death.*DieInDebugElse12"
)
<<
"In ExpectDebugDeathM"
;
#ifdef NDEBUG
// Checks that the assignment occurs in opt mode (sideeffect).
EXPECT_EQ
(
12
,
sideeffect
);
#else
// Checks that the assignment does not occur in dbg mode (no sideeffect).
EXPECT_EQ
(
0
,
sideeffect
);
#endif
}
// Tests that ASSERT_DEBUG_DEATH works as expected
// Tests that ASSERT_DEBUG_DEATH works as expected
// In debug mode:
// In debug mode:
// 1. Asserts on debug death.
// 1. Asserts on debug death.
...
@@ -499,7 +474,7 @@ TEST_F(TestForDeathTest, TestExpectDebugDeathM) {
...
@@ -499,7 +474,7 @@ TEST_F(TestForDeathTest, TestExpectDebugDeathM) {
//
//
// In opt mode:
// In opt mode:
// 1. Has side effects and returns the expected value (12).
// 1. Has side effects and returns the expected value (12).
TEST_F
(
TestForDeathTest
,
TestAssertDebugDeath
M
)
{
TEST_F
(
TestForDeathTest
,
TestAssertDebugDeath
)
{
int
sideeffect
=
0
;
int
sideeffect
=
0
;
ASSERT_DEBUG_DEATH
({
// NOLINT
ASSERT_DEBUG_DEATH
({
// NOLINT
...
@@ -507,7 +482,7 @@ TEST_F(TestForDeathTest, TestAssertDebugDeathM) {
...
@@ -507,7 +482,7 @@ TEST_F(TestForDeathTest, TestAssertDebugDeathM) {
EXPECT_EQ
(
12
,
DieInDebugElse12
(
&
sideeffect
));
EXPECT_EQ
(
12
,
DieInDebugElse12
(
&
sideeffect
));
// Tests that the side effect occurred in opt mode.
// Tests that the side effect occurred in opt mode.
EXPECT_EQ
(
12
,
sideeffect
);
EXPECT_EQ
(
12
,
sideeffect
);
},
"death.*DieInDebugElse12"
)
<<
"In AssertDebugDeathM"
;
},
"death.*DieInDebugElse12"
);
#ifdef NDEBUG
#ifdef NDEBUG
// Checks that the assignment occurs in opt mode (sideeffect).
// Checks that the assignment occurs in opt mode (sideeffect).
...
...
test/gtest_repeat_test.cc
View file @
bcb12fa0
...
@@ -58,6 +58,8 @@ using testing::GTEST_FLAG(repeat);
...
@@ -58,6 +58,8 @@ using testing::GTEST_FLAG(repeat);
namespace
{
namespace
{
// We need this when we are testing Google Test itself and therefore
// cannot use Google Test assertions.
#define GTEST_CHECK_INT_EQ_(expected, actual) \
#define GTEST_CHECK_INT_EQ_(expected, actual) \
do {\
do {\
const int expected_val = (expected);\
const int expected_val = (expected);\
...
@@ -130,8 +132,6 @@ void ResetCounts() {
...
@@ -130,8 +132,6 @@ void ResetCounts() {
// Checks that the count for each test is expected.
// Checks that the count for each test is expected.
void
CheckCounts
(
int
expected
)
{
void
CheckCounts
(
int
expected
)
{
// We cannot use Google Test assertions here since we are testing Google Test
// itself.
GTEST_CHECK_INT_EQ_
(
expected
,
g_environment_set_up_count
);
GTEST_CHECK_INT_EQ_
(
expected
,
g_environment_set_up_count
);
GTEST_CHECK_INT_EQ_
(
expected
,
g_environment_tear_down_count
);
GTEST_CHECK_INT_EQ_
(
expected
,
g_environment_tear_down_count
);
GTEST_CHECK_INT_EQ_
(
expected
,
g_should_fail_count
);
GTEST_CHECK_INT_EQ_
(
expected
,
g_should_fail_count
);
...
...
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