Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
61baf319
Commit
61baf319
authored
May 10, 2010
by
zhanyong.wan
Browse files
Suppresses some Clang warnings (by Chandler Carruth, Jeffrey Yasskin, and Zhanyong Wan).
parent
2ccea88c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
21 deletions
+28
-21
include/gtest/gtest.h
include/gtest/gtest.h
+1
-1
include/gtest/internal/gtest-internal.h
include/gtest/internal/gtest-internal.h
+27
-20
No files found.
include/gtest/gtest.h
View file @
61baf319
...
@@ -1959,7 +1959,7 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
...
@@ -1959,7 +1959,7 @@ GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,
// to cause a compiler error.
// to cause a compiler error.
template
<
typename
T1
,
typename
T2
>
template
<
typename
T1
,
typename
T2
>
bool
StaticAssertTypeEq
()
{
bool
StaticAssertTypeEq
()
{
internal
::
StaticAssertTypeEqHelper
<
T1
,
T2
>
();
(
void
)
internal
::
StaticAssertTypeEqHelper
<
T1
,
T2
>
();
return
true
;
return
true
;
}
}
...
...
include/gtest/internal/gtest-internal.h
View file @
61baf319
...
@@ -765,6 +765,15 @@ GTEST_API_ bool AlwaysTrue();
...
@@ -765,6 +765,15 @@ GTEST_API_ bool AlwaysTrue();
// Always returns false.
// Always returns false.
inline
bool
AlwaysFalse
()
{
return
!
AlwaysTrue
();
}
inline
bool
AlwaysFalse
()
{
return
!
AlwaysTrue
();
}
// Helper for suppressing false warning from Clang on a const char*
// variable declared in a conditional expression always being NULL in
// the else branch.
struct
GTEST_API_
ConstCharPtr
{
ConstCharPtr
(
const
char
*
str
)
:
value
(
str
)
{}
operator
bool
()
const
{
return
true
;
}
const
char
*
value
;
};
// A simple Linear Congruential Generator for generating random
// A simple Linear Congruential Generator for generating random
// numbers with a uniform distribution. Unlike rand() and srand(), it
// numbers with a uniform distribution. Unlike rand() and srand(), it
// doesn't use global state (and therefore can't interfere with user
// doesn't use global state (and therefore can't interfere with user
...
@@ -1097,7 +1106,7 @@ class NativeArray {
...
@@ -1097,7 +1106,7 @@ class NativeArray {
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
#define GTEST_TEST_THROW_(statement, expected_exception, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (
c
onst
c
har
*
gtest_msg = "") { \
if (
::testing::internal::C
onst
C
har
Ptr
gtest_msg = "") { \
bool gtest_caught_expected = false; \
bool gtest_caught_expected = false; \
try { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
...
@@ -1106,38 +1115,38 @@ class NativeArray {
...
@@ -1106,38 +1115,38 @@ class NativeArray {
gtest_caught_expected = true; \
gtest_caught_expected = true; \
} \
} \
catch (...) { \
catch (...) { \
gtest_msg
= "Expected: " #statement " throws an exception of typ
e
"
\
gtest_msg
.valu
e
=
\
#expected_exception ".\n Actual: it throws a different
" \
"Expected: " #statement " throws an exception of type
" \
"
type."; \
#expected_exception ".\n Actual: it throws a different
type."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} \
if (!gtest_caught_expected) { \
if (!gtest_caught_expected) { \
gtest_msg = "Expected: " #statement " throws an exception of type " \
gtest_msg.value = \
#expected_exception ".\n Actual: it throws nothing."; \
"Expected: " #statement " throws an exception of type " \
#expected_exception ".\n Actual: it throws nothing."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \
} \
} \
} else \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \
fail(gtest_msg)
fail(gtest_msg
.value
)
#define GTEST_TEST_NO_THROW_(statement, fail) \
#define GTEST_TEST_NO_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (
const char* gtest_msg = ""
) { \
if (
::testing::internal::AlwaysTrue()
) { \
try { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
} \
} \
catch (...) { \
catch (...) { \
gtest_msg = "Expected: " #statement " doesn't throw an exception.\n" \
" Actual: it throws."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \
} \
} \
} else \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \
fail(gtest_msg)
fail("Expected: " #statement " doesn't throw an exception.\n" \
" Actual: it throws.")
#define GTEST_TEST_ANY_THROW_(statement, fail) \
#define GTEST_TEST_ANY_THROW_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (
const char* gtest_msg = ""
) { \
if (
::testing::internal::AlwaysTrue()
) { \
bool gtest_caught_any = false; \
bool gtest_caught_any = false; \
try { \
try { \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
...
@@ -1146,13 +1155,12 @@ class NativeArray {
...
@@ -1146,13 +1155,12 @@ class NativeArray {
gtest_caught_any = true; \
gtest_caught_any = true; \
} \
} \
if (!gtest_caught_any) { \
if (!gtest_caught_any) { \
gtest_msg = "Expected: " #statement " throws an exception.\n" \
" Actual: it doesn't."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \
} \
} \
} else \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \
fail(gtest_msg)
fail("Expected: " #statement " throws an exception.\n" \
" Actual: it doesn't.")
// Implements Boolean test assertions such as EXPECT_TRUE. expression can be
// Implements Boolean test assertions such as EXPECT_TRUE. expression can be
...
@@ -1169,18 +1177,17 @@ class NativeArray {
...
@@ -1169,18 +1177,17 @@ class NativeArray {
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
GTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if (
const char* gtest_msg = ""
) { \
if (
::testing::internal::AlwaysTrue()
) { \
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \
gtest_msg = "Expected: " #statement " doesn't generate new fatal " \
"failures in the current thread.\n" \
" Actual: it does."; \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \
} \
} \
} else \
} else \
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \
fail(gtest_msg)
fail("Expected: " #statement " doesn't generate new fatal " \
"failures in the current thread.\n" \
" Actual: it does.")
// Expands to the name of the class that implements the given test.
// Expands to the name of the class that implements the given test.
#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \
...
...
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