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
6414d806
Commit
6414d806
authored
Dec 03, 2013
by
kosak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix warnings encountered with clang -Wall, and pull in gtest 670.
parent
b72d18ca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
37 deletions
+33
-37
gmock-generated-matchers_test.cc
test/gmock-generated-matchers_test.cc
+19
-22
gmock-matchers_test.cc
test/gmock-matchers_test.cc
+14
-15
No files found.
test/gmock-generated-matchers_test.cc
View file @
6414d806
...
...
@@ -81,9 +81,6 @@ using testing::Value;
using
testing
::
internal
::
ElementsAreArrayMatcher
;
using
testing
::
internal
::
string
;
// Evaluates to the number of elements in 'array'.
#define GMOCK_ARRAY_SIZE_(a) (sizeof(a) / sizeof(a[0]))
// Returns the description of the given matcher.
template
<
typename
T
>
string
Describe
(
const
Matcher
<
T
>&
m
)
{
...
...
@@ -337,7 +334,7 @@ TEST(ElementsAreTest, ExplainsNonTrivialMatch) {
ElementsAre
(
GreaterThan
(
1
),
0
,
GreaterThan
(
2
));
const
int
a
[]
=
{
10
,
0
,
100
};
vector
<
int
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_EQ
(
"whose element #0 matches, which is 9 more than 1,
\n
"
"and whose element #2 matches, which is 98 more than 2"
,
Explain
(
m
,
test_vector
));
...
...
@@ -422,7 +419,7 @@ TEST(ElementsAreTest, MatchesThreeElementsMixedMatchers) {
TEST
(
ElementsAreTest
,
MatchesTenElementVector
)
{
const
int
a
[]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
};
vector
<
int
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
test_vector
,
// The element list can contain values and/or matchers
...
...
@@ -465,7 +462,7 @@ TEST(ElementsAreTest, WorksForNestedContainer) {
};
vector
<
list
<
char
>
>
nested
;
for
(
size_t
i
=
0
;
i
<
G
MOCK
_ARRAY_SIZE_
(
strings
);
i
++
)
{
for
(
size_t
i
=
0
;
i
<
G
TEST
_ARRAY_SIZE_
(
strings
);
i
++
)
{
nested
.
push_back
(
list
<
char
>
(
strings
[
i
],
strings
[
i
]
+
strlen
(
strings
[
i
])));
}
...
...
@@ -477,7 +474,7 @@ TEST(ElementsAreTest, WorksForNestedContainer) {
TEST
(
ElementsAreTest
,
WorksWithByRefElementMatchers
)
{
int
a
[]
=
{
0
,
1
,
2
};
vector
<
int
>
v
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
v
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
v
,
ElementsAre
(
Ref
(
v
[
0
]),
Ref
(
v
[
1
]),
Ref
(
v
[
2
])));
EXPECT_THAT
(
v
,
Not
(
ElementsAre
(
Ref
(
v
[
0
]),
Ref
(
v
[
1
]),
Ref
(
a
[
2
]))));
...
...
@@ -485,7 +482,7 @@ TEST(ElementsAreTest, WorksWithByRefElementMatchers) {
TEST
(
ElementsAreTest
,
WorksWithContainerPointerUsingPointee
)
{
int
a
[]
=
{
0
,
1
,
2
};
vector
<
int
>
v
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
v
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
&
v
,
Pointee
(
ElementsAre
(
0
,
1
,
_
)));
EXPECT_THAT
(
&
v
,
Not
(
Pointee
(
ElementsAre
(
0
,
_
,
3
))));
...
...
@@ -582,7 +579,7 @@ TEST(ElementsAreTest, MakesCopyOfArguments) {
TEST
(
ElementsAreArrayTest
,
CanBeCreatedWithValueArray
)
{
const
int
a
[]
=
{
1
,
2
,
3
};
vector
<
int
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
a
));
test_vector
[
2
]
=
0
;
...
...
@@ -592,18 +589,18 @@ TEST(ElementsAreArrayTest, CanBeCreatedWithValueArray) {
TEST
(
ElementsAreArrayTest
,
CanBeCreatedWithArraySize
)
{
const
char
*
a
[]
=
{
"one"
,
"two"
,
"three"
};
vector
<
string
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
a
,
G
MOCK
_ARRAY_SIZE_
(
a
)));
vector
<
string
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
a
,
G
TEST
_ARRAY_SIZE_
(
a
)));
const
char
**
p
=
a
;
test_vector
[
0
]
=
"1"
;
EXPECT_THAT
(
test_vector
,
Not
(
ElementsAreArray
(
p
,
G
MOCK
_ARRAY_SIZE_
(
a
))));
EXPECT_THAT
(
test_vector
,
Not
(
ElementsAreArray
(
p
,
G
TEST
_ARRAY_SIZE_
(
a
))));
}
TEST
(
ElementsAreArrayTest
,
CanBeCreatedWithoutArraySize
)
{
const
char
*
a
[]
=
{
"one"
,
"two"
,
"three"
};
vector
<
string
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
string
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
a
));
test_vector
[
0
]
=
"1"
;
...
...
@@ -626,8 +623,8 @@ TEST(ElementsAreArrayTest, CanBeCreatedWithMatcherArray) {
TEST
(
ElementsAreArrayTest
,
CanBeCreatedWithVector
)
{
const
int
a
[]
=
{
1
,
2
,
3
};
vector
<
int
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
const
vector
<
int
>
expected
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
const
vector
<
int
>
expected
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
expected
));
test_vector
.
push_back
(
4
);
EXPECT_THAT
(
test_vector
,
Not
(
ElementsAreArray
(
expected
)));
...
...
@@ -674,9 +671,9 @@ TEST(ElementsAreArrayTest,
TEST
(
ElementsAreArrayTest
,
CanBeCreatedWithMatcherVector
)
{
const
int
a
[]
=
{
1
,
2
,
3
};
const
Matcher
<
int
>
kMatchers
[]
=
{
Eq
(
1
),
Eq
(
2
),
Eq
(
3
)
};
vector
<
int
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
const
vector
<
Matcher
<
int
>
>
expected
(
kMatchers
,
kMatchers
+
G
MOCK
_ARRAY_SIZE_
(
kMatchers
));
kMatchers
,
kMatchers
+
G
TEST
_ARRAY_SIZE_
(
kMatchers
));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
expected
));
test_vector
.
push_back
(
4
);
EXPECT_THAT
(
test_vector
,
Not
(
ElementsAreArray
(
expected
)));
...
...
@@ -684,11 +681,11 @@ TEST(ElementsAreArrayTest, CanBeCreatedWithMatcherVector) {
TEST
(
ElementsAreArrayTest
,
CanBeCreatedWithIteratorRange
)
{
const
int
a
[]
=
{
1
,
2
,
3
};
const
vector
<
int
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
const
vector
<
int
>
expected
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
const
vector
<
int
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
const
vector
<
int
>
expected
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
expected
.
begin
(),
expected
.
end
()));
// Pointers are iterators, too.
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
)));
EXPECT_THAT
(
test_vector
,
ElementsAreArray
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
)));
// The empty range of NULL pointers should also be okay.
int
*
const
null_int
=
NULL
;
EXPECT_THAT
(
test_vector
,
Not
(
ElementsAreArray
(
null_int
,
null_int
)));
...
...
@@ -708,8 +705,8 @@ TEST(ElementsAreArrayTest, WorksWithNativeArray) {
TEST
(
ElementsAreArrayTest
,
SourceLifeSpan
)
{
const
int
a
[]
=
{
1
,
2
,
3
};
vector
<
int
>
test_vector
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
expect
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
vector
<
int
>
test_vector
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
vector
<
int
>
expect
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
ElementsAreArrayMatcher
<
int
>
matcher_maker
=
ElementsAreArray
(
expect
.
begin
(),
expect
.
end
());
EXPECT_THAT
(
test_vector
,
matcher_maker
);
...
...
test/gmock-matchers_test.cc
View file @
6414d806
...
...
@@ -151,9 +151,6 @@ using testing::internal::linked_ptr;
using
testing
::
internal
::
scoped_ptr
;
using
testing
::
internal
::
string
;
// Evaluates to the number of elements in 'array'.
#define GMOCK_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))
// For testing ExplainMatchResultTo().
class
GreaterThanMatcher
:
public
MatcherInterface
<
int
>
{
public
:
...
...
@@ -3444,6 +3441,8 @@ double AClass::x_ = 0.0;
// A derived class for testing Property().
class
DerivedClass
:
public
AClass
{
public
:
int
k
()
const
{
return
k_
;
}
private
:
int
k_
;
};
...
...
@@ -4424,14 +4423,14 @@ TEST(WhenSortedTest, WorksForStreamlike) {
// Streamlike 'container' provides only minimal iterator support.
// Its iterators are tagged with input_iterator_tag.
const
int
a
[
5
]
=
{
2
,
1
,
4
,
5
,
3
};
Streamlike
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
Streamlike
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
s
,
WhenSorted
(
ElementsAre
(
1
,
2
,
3
,
4
,
5
)));
EXPECT_THAT
(
s
,
Not
(
WhenSorted
(
ElementsAre
(
2
,
1
,
4
,
5
,
3
))));
}
TEST
(
WhenSortedTest
,
WorksForVectorConstRefMatcherOnStreamlike
)
{
const
int
a
[]
=
{
2
,
1
,
4
,
5
,
3
};
Streamlike
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
Streamlike
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
Matcher
<
const
std
::
vector
<
int
>&>
vector_match
=
ElementsAre
(
1
,
2
,
3
,
4
,
5
);
EXPECT_THAT
(
s
,
WhenSorted
(
vector_match
));
EXPECT_THAT
(
s
,
Not
(
WhenSorted
(
ElementsAre
(
2
,
1
,
4
,
5
,
3
))));
...
...
@@ -4442,14 +4441,14 @@ TEST(WhenSortedTest, WorksForVectorConstRefMatcherOnStreamlike) {
TEST
(
ElemensAreStreamTest
,
WorksForStreamlike
)
{
const
int
a
[
5
]
=
{
1
,
2
,
3
,
4
,
5
};
Streamlike
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
Streamlike
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
s
,
ElementsAre
(
1
,
2
,
3
,
4
,
5
));
EXPECT_THAT
(
s
,
Not
(
ElementsAre
(
2
,
1
,
4
,
5
,
3
)));
}
TEST
(
ElemensAreArrayStreamTest
,
WorksForStreamlike
)
{
const
int
a
[
5
]
=
{
1
,
2
,
3
,
4
,
5
};
Streamlike
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
Streamlike
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
vector
<
int
>
expected
;
expected
.
push_back
(
1
);
...
...
@@ -4467,7 +4466,7 @@ TEST(ElemensAreArrayStreamTest, WorksForStreamlike) {
TEST
(
UnorderedElementsAreArrayTest
,
SucceedsWhenExpected
)
{
const
int
a
[]
=
{
0
,
1
,
2
,
3
,
4
};
std
::
vector
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
std
::
vector
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
do
{
StringMatchResultListener
listener
;
EXPECT_TRUE
(
ExplainMatchResult
(
UnorderedElementsAreArray
(
a
),
...
...
@@ -4478,8 +4477,8 @@ TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) {
TEST
(
UnorderedElementsAreArrayTest
,
VectorBool
)
{
const
bool
a
[]
=
{
0
,
1
,
0
,
1
,
1
};
const
bool
b
[]
=
{
1
,
0
,
1
,
1
,
0
};
std
::
vector
<
bool
>
expected
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
std
::
vector
<
bool
>
actual
(
b
,
b
+
G
MOCK
_ARRAY_SIZE_
(
b
));
std
::
vector
<
bool
>
expected
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
std
::
vector
<
bool
>
actual
(
b
,
b
+
G
TEST
_ARRAY_SIZE_
(
b
));
StringMatchResultListener
listener
;
EXPECT_TRUE
(
ExplainMatchResult
(
UnorderedElementsAreArray
(
expected
),
actual
,
&
listener
))
<<
listener
.
str
();
...
...
@@ -4490,7 +4489,7 @@ TEST(UnorderedElementsAreArrayTest, WorksForStreamlike) {
// Its iterators are tagged with input_iterator_tag, and it has no
// size() or empty() methods.
const
int
a
[
5
]
=
{
2
,
1
,
4
,
5
,
3
};
Streamlike
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
Streamlike
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
::
std
::
vector
<
int
>
expected
;
expected
.
push_back
(
1
);
...
...
@@ -4547,7 +4546,7 @@ class UnorderedElementsAreTest : public testing::Test {
TEST_F
(
UnorderedElementsAreTest
,
SucceedsWhenExpected
)
{
const
int
a
[]
=
{
1
,
2
,
3
};
std
::
vector
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
std
::
vector
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
do
{
StringMatchResultListener
listener
;
EXPECT_TRUE
(
ExplainMatchResult
(
UnorderedElementsAre
(
1
,
2
,
3
),
...
...
@@ -4557,7 +4556,7 @@ TEST_F(UnorderedElementsAreTest, SucceedsWhenExpected) {
TEST_F
(
UnorderedElementsAreTest
,
FailsWhenAnElementMatchesNoMatcher
)
{
const
int
a
[]
=
{
1
,
2
,
3
};
std
::
vector
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
std
::
vector
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
std
::
vector
<
Matcher
<
int
>
>
mv
;
mv
.
push_back
(
1
);
mv
.
push_back
(
2
);
...
...
@@ -4573,7 +4572,7 @@ TEST_F(UnorderedElementsAreTest, WorksForStreamlike) {
// Its iterators are tagged with input_iterator_tag, and it has no
// size() or empty() methods.
const
int
a
[
5
]
=
{
2
,
1
,
4
,
5
,
3
};
Streamlike
<
int
>
s
(
a
,
a
+
G
MOCK
_ARRAY_SIZE_
(
a
));
Streamlike
<
int
>
s
(
a
,
a
+
G
TEST
_ARRAY_SIZE_
(
a
));
EXPECT_THAT
(
s
,
UnorderedElementsAre
(
1
,
2
,
3
,
4
,
5
));
EXPECT_THAT
(
s
,
Not
(
UnorderedElementsAre
(
2
,
2
,
3
,
4
,
5
)));
...
...
@@ -4884,7 +4883,7 @@ TEST_F(BipartiteNonSquareTest, SimpleBacktracking) {
// 0 1 2
MatchMatrix
g
(
4
,
3
);
static
const
int
kEdges
[][
2
]
=
{
{
0
,
2
},
{
1
,
1
},
{
2
,
1
},
{
3
,
0
}
};
for
(
size_t
i
=
0
;
i
<
G
MOCK
_ARRAY_SIZE_
(
kEdges
);
++
i
)
{
for
(
size_t
i
=
0
;
i
<
G
TEST
_ARRAY_SIZE_
(
kEdges
);
++
i
)
{
g
.
SetEdge
(
kEdges
[
i
][
0
],
kEdges
[
i
][
1
],
true
);
}
EXPECT_THAT
(
FindBacktrackingMaxBPM
(
g
),
...
...
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