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
48b13151
Commit
48b13151
authored
Jan 10, 2011
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes GCC 4.6 warnings (patch by Jeffrey Yasskin).
parent
afaefb0e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
25 deletions
+49
-25
gtest-typed-test.h
include/gtest/gtest-typed-test.h
+3
-3
gtest.h
include/gtest/gtest.h
+27
-13
gtest-internal.h
include/gtest/internal/gtest-internal.h
+8
-1
gtest-port_test.cc
test/gtest-port_test.cc
+1
-0
gtest_unittest.cc
test/gtest_unittest.cc
+10
-8
No files found.
include/gtest/gtest-typed-test.h
View file @
48b13151
...
...
@@ -175,7 +175,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
typedef gtest_TypeParam_ TypeParam; \
virtual void TestBody(); \
}; \
bool gtest_##CaseName##_##TestName##_registered_ = \
bool gtest_##CaseName##_##TestName##_registered_
GTEST_ATTRIBUTE_UNUSED_
= \
::testing::internal::TypeParameterizedTest< \
CaseName, \
::testing::internal::TemplateSel< \
...
...
@@ -229,7 +229,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
typedef gtest_TypeParam_ TypeParam; \
virtual void TestBody(); \
}; \
static bool gtest_##TestName##_defined_ = \
static bool gtest_##TestName##_defined_
GTEST_ATTRIBUTE_UNUSED_
= \
GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\
__FILE__, __LINE__, #CaseName, #TestName); \
} \
...
...
@@ -248,7 +248,7 @@ INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);
// since some compilers may choke on '>>' when passing a template
// instance (e.g. Types<int>)
#define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \
bool gtest_##Prefix##_##CaseName = \
bool gtest_##Prefix##_##CaseName
GTEST_ATTRIBUTE_UNUSED_
= \
::testing::internal::TypeParameterizedTestCase<CaseName, \
GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \
::testing::internal::TypeList< Types >::type>::Register(\
...
...
include/gtest/gtest.h
View file @
48b13151
...
...
@@ -1342,7 +1342,7 @@ class EqHelper {
};
// This specialization is used when the first argument to ASSERT_EQ()
// is a null pointer literal.
// is a null pointer literal
, like NULL, false, or 0
.
template
<>
class
EqHelper
<
true
>
{
public
:
...
...
@@ -1351,24 +1351,38 @@ class EqHelper<true> {
// NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or
// EXPECT_EQ(false, a_bool).
template
<
typename
T1
,
typename
T2
>
static
AssertionResult
Compare
(
const
char
*
expected_expression
,
const
char
*
actual_expression
,
const
T1
&
expected
,
const
T2
&
actual
)
{
static
AssertionResult
Compare
(
const
char
*
expected_expression
,
const
char
*
actual_expression
,
const
T1
&
expected
,
const
T2
&
actual
,
// The following line prevents this overload from being considered if T2
// is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr)
// expands to Compare("", "", NULL, my_ptr), which requires a conversion
// to match the Secret* in the other overload, which would otherwise make
// this template match better.
typename
EnableIf
<!
is_pointer
<
T2
>::
value
>::
type
*
=
0
)
{
return
CmpHelperEQ
(
expected_expression
,
actual_expression
,
expected
,
actual
);
}
// This version will be picked when the second argument to
// ASSERT_EQ() is a pointer, e.g. ASSERT_EQ(NULL, a_pointer).
template
<
typename
T1
,
typename
T2
>
static
AssertionResult
Compare
(
const
char
*
expected_expression
,
const
char
*
actual_expression
,
const
T1
&
/* expected */
,
T2
*
actual
)
{
// This version will be picked when the second argument to ASSERT_EQ() is a
// pointer, e.g. ASSERT_EQ(NULL, a_pointer).
template
<
typename
T
>
static
AssertionResult
Compare
(
const
char
*
expected_expression
,
const
char
*
actual_expression
,
// We used to have a second template parameter instead of Secret*. That
// template parameter would deduce to 'long', making this a better match
// than the first overload even without the first overload's EnableIf.
// Unfortunately, gcc with -Wconversion-null warns when "passing NULL to
// non-pointer argument" (even a deduced integral argument), so the old
// implementation caused warnings in user code.
Secret
*
/* expected (NULL) */
,
T
*
actual
)
{
// We already know that 'expected' is a null pointer.
return
CmpHelperEQ
(
expected_expression
,
actual_expression
,
static_cast
<
T
2
*>
(
NULL
),
actual
);
static_cast
<
T
*>
(
NULL
),
actual
);
}
};
...
...
include/gtest/internal/gtest-internal.h
View file @
48b13151
...
...
@@ -919,6 +919,13 @@ typedef char IsNotContainer;
template
<
class
C
>
IsNotContainer
IsContainerTest
(...)
{
return
'\0'
;
}
// EnableIf<condition>::type is void when 'Cond' is true, and
// undefined when 'Cond' is false. To use SFINAE to make a function
// overload only apply when a particular expression is true, add
// "typename EnableIf<expression>::type* = 0" as the last parameter.
template
<
bool
>
struct
EnableIf
;
template
<>
struct
EnableIf
<
true
>
{
typedef
void
type
;
};
// NOLINT
// Utilities for native arrays.
// ArrayEq() compares two k-dimensional native arrays using the
...
...
@@ -1182,7 +1189,7 @@ class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\
private:\
virtual void TestBody();\
static ::testing::TestInfo* const test_info_;\
static ::testing::TestInfo* const test_info_
GTEST_ATTRIBUTE_UNUSED_
;\
GTEST_DISALLOW_COPY_AND_ASSIGN_(\
GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\
};\
...
...
test/gtest-port_test.cc
View file @
48b13151
...
...
@@ -168,6 +168,7 @@ class To {
TEST
(
ImplicitCastTest
,
CanUseImplicitConstructor
)
{
bool
converted
=
false
;
To
to
=
::
testing
::
internal
::
implicit_cast
<
To
>
(
&
converted
);
(
void
)
to
;
EXPECT_TRUE
(
converted
);
}
...
...
test/gtest_unittest.cc
View file @
48b13151
...
...
@@ -322,13 +322,11 @@ TEST(NullLiteralTest, IsTrueForNullLiterals) {
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
0
));
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
0U
));
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
0L
));
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
false
));
#ifndef __BORLANDC__
// Some compilers may fail to detect some null pointer literals;
// as long as users of the framework don't use such literals, this
// is harmless.
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
1
-
1
));
EXPECT_TRUE
(
GTEST_IS_NULL_LITERAL_
(
true
&&
false
));
#endif
}
...
...
@@ -3731,7 +3729,8 @@ TEST(AssertionTest, ASSERT_ANY_THROW) {
// compile.
TEST
(
AssertionTest
,
AssertPrecedence
)
{
ASSERT_EQ
(
1
<
2
,
true
);
ASSERT_EQ
(
true
&&
false
,
false
);
bool
false_value
=
false
;
ASSERT_EQ
(
true
&&
false_value
,
false
);
}
// A subroutine used by the following test.
...
...
@@ -4220,7 +4219,7 @@ TEST(ExpectTest, EXPECT_EQ_Double) {
TEST
(
ExpectTest
,
EXPECT_EQ_NULL
)
{
// A success.
const
char
*
p
=
NULL
;
// Some older GCC versions may issue a spurious waring in this or the next
// Some older GCC versions may issue a spurious war
n
ing in this or the next
// assertion statement. This warning should not be suppressed with
// static_cast since the test verifies the ability to use bare NULL as the
// expected parameter to the macro.
...
...
@@ -4490,8 +4489,10 @@ TEST(MacroTest, SUCCEED) {
// Tests using bool values in {EXPECT|ASSERT}_EQ.
TEST
(
EqAssertionTest
,
Bool
)
{
EXPECT_EQ
(
true
,
true
);
EXPECT_FATAL_FAILURE
(
ASSERT_EQ
(
false
,
true
),
"Value of: true"
);
EXPECT_FATAL_FAILURE
({
bool
false_value
=
false
;
ASSERT_EQ
(
false_value
,
true
);
},
"Value of: true"
);
}
// Tests using int values in {EXPECT|ASSERT}_EQ.
...
...
@@ -6470,8 +6471,9 @@ TEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {
// Verifies that StaticAssertTypeEq works in a namespace scope.
static
bool
dummy1
=
StaticAssertTypeEq
<
bool
,
bool
>
();
static
bool
dummy2
=
StaticAssertTypeEq
<
const
int
,
const
int
>
();
static
bool
dummy1
GTEST_ATTRIBUTE_UNUSED_
=
StaticAssertTypeEq
<
bool
,
bool
>
();
static
bool
dummy2
GTEST_ATTRIBUTE_UNUSED_
=
StaticAssertTypeEq
<
const
int
,
const
int
>
();
// Verifies that StaticAssertTypeEq works in a class.
...
...
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