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
f3dbe3ec
Commit
f3dbe3ec
authored
Oct 14, 2020
by
dmauro
Committed by
Derek Mauro
Oct 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
Disable warnings on code that intentionally tests a suboptimal syntax PiperOrigin-RevId: 337138442
parent
7e7e9442
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
4 deletions
+60
-4
googletest-death-test-test.cc
googletest/test/googletest-death-test-test.cc
+20
-0
googletest-port-test.cc
googletest/test/googletest-port-test.cc
+10
-0
gtest_unittest.cc
googletest/test/gtest_unittest.cc
+30
-4
No files found.
googletest/test/googletest-death-test-test.cc
View file @
f3dbe3ec
...
...
@@ -298,6 +298,13 @@ TEST(ExitStatusPredicateTest, KilledBySignal) {
# endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
// The following code intentionally tests a suboptimal syntax.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-else"
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
// Tests that the death test macros expand to code which may or may not
// be followed by operator<<, and that in either case the complete text
// comprises only a single C++ statement.
...
...
@@ -321,6 +328,9 @@ TEST_F(TestForDeathTest, SingleStatement) {
else
EXPECT_DEATH
(
_exit
(
1
),
""
)
<<
1
<<
2
<<
3
;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
# if GTEST_USES_PCRE
...
...
@@ -1468,6 +1478,13 @@ TEST(ConditionalDeathMacrosTest, AssertDeatDoesNotReturnhIfUnsupported) {
namespace
{
// The following code intentionally tests a suboptimal syntax.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-else"
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
// Tests that the death test macros expand to code which may or may not
// be followed by operator<<, and that in either case the complete text
// comprises only a single C++ statement.
...
...
@@ -1493,6 +1510,9 @@ TEST(ConditionalDeathMacrosSyntaxDeathTest, SingleStatement) {
else
EXPECT_DEATH_IF_SUPPORTED
(
_exit
(
1
),
""
)
<<
1
<<
2
<<
3
;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
// Tests that conditional death test macros expand to code which interacts
// well with switch statements.
...
...
googletest/test/googletest-port-test.cc
View file @
f3dbe3ec
...
...
@@ -201,6 +201,13 @@ TEST(ImplicitCastTest, CanUseImplicitConstructor) {
EXPECT_TRUE
(
converted
);
}
// The following code intentionally tests a suboptimal syntax.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-else"
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
TEST
(
GtestCheckSyntaxTest
,
BehavesLikeASingleStatement
)
{
if
(
AlwaysFalse
())
GTEST_CHECK_
(
false
)
<<
"This should never be executed; "
...
...
@@ -216,6 +223,9 @@ TEST(GtestCheckSyntaxTest, BehavesLikeASingleStatement) {
else
GTEST_CHECK_
(
true
)
<<
""
;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
TEST
(
GtestCheckSyntaxTest
,
WorksWithSwitch
)
{
switch
(
0
)
{
...
...
googletest/test/gtest_unittest.cc
View file @
f3dbe3ec
...
...
@@ -4131,11 +4131,13 @@ TEST(HRESULTAssertionTest, Streaming) {
#endif // GTEST_OS_WINDOWS
#ifdef __BORLANDC__
// Silences warnings: "Condition is always true", "Unreachable code"
# pragma option push -w-ccc -w-rch
// The following code intentionally tests a suboptimal syntax.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-else"
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
// Tests that the assertion macros behave like single statements.
TEST
(
AssertionSyntaxTest
,
BasicAssertionsBehavesLikeSingleStatement
)
{
if
(
AlwaysFalse
())
...
...
@@ -4155,6 +4157,9 @@ TEST(AssertionSyntaxTest, BasicAssertionsBehavesLikeSingleStatement) {
else
EXPECT_GT
(
3
,
2
)
<<
""
;
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#if GTEST_HAS_EXCEPTIONS
// Tests that the compiler will not complain about unreachable code in the
...
...
@@ -4175,6 +4180,13 @@ TEST(ExpectThrowTest, DoesNotGenerateDuplicateCatchClauseWarning) {
EXPECT_THROW
(
throw
std
::
exception
(),
std
::
exception
);
}
// The following code intentionally tests a suboptimal syntax.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-else"
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
TEST
(
AssertionSyntaxTest
,
ExceptionAssertionsBehavesLikeSingleStatement
)
{
if
(
AlwaysFalse
())
EXPECT_THROW
(
ThrowNothing
(),
bool
);
...
...
@@ -4200,8 +4212,19 @@ TEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {
else
;
// NOLINT
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
#endif // GTEST_HAS_EXCEPTIONS
// The following code intentionally tests a suboptimal syntax.
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-else"
#pragma GCC diagnostic ignored "-Wempty-body"
#pragma GCC diagnostic ignored "-Wpragmas"
#endif
TEST
(
AssertionSyntaxTest
,
NoFatalFailureAssertionsBehavesLikeSingleStatement
)
{
if
(
AlwaysFalse
())
EXPECT_NO_FATAL_FAILURE
(
FAIL
())
<<
"This should never be executed. "
...
...
@@ -4224,6 +4247,9 @@ TEST(AssertionSyntaxTest, NoFatalFailureAssertionsBehavesLikeSingleStatement) {
else
ASSERT_NO_FATAL_FAILURE
(
SUCCEED
());
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
// Tests that the assertion macros work well with switch statements.
TEST
(
AssertionSyntaxTest
,
WorksWithSwitch
)
{
...
...
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