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
d8db0ca9
Unverified
Commit
d8db0ca9
authored
Jul 20, 2018
by
duxiuxing
Committed by
GitHub
Jul 20, 2018
Browse files
Merge branch 'master' into googletest_for_asam
parents
2eb43960
6ce9b98f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
7 deletions
+29
-7
googlemock/include/gmock/gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+8
-4
googlemock/test/gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+21
-3
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
d8db0ca9
...
@@ -5165,13 +5165,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
...
@@ -5165,13 +5165,17 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
// Define variadic matcher versions. They are overloaded in
// Define variadic matcher versions. They are overloaded in
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.
template
<
typename
...
Args
>
template
<
typename
...
Args
>
internal
::
AllOfMatcher
<
Args
...
>
AllOf
(
const
Args
&
...
matchers
)
{
internal
::
AllOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
AllOf
(
return
internal
::
AllOfMatcher
<
Args
...
>
(
matchers
...);
const
Args
&
...
matchers
)
{
return
internal
::
AllOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
(
matchers
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
internal
::
AnyOfMatcher
<
Args
...
>
AnyOf
(
const
Args
&
...
matchers
)
{
internal
::
AnyOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
AnyOf
(
return
internal
::
AnyOfMatcher
<
Args
...
>
(
matchers
...);
const
Args
&
...
matchers
)
{
return
internal
::
AnyOfMatcher
<
typename
std
::
decay
<
const
Args
&>::
type
...
>
(
matchers
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
...
...
googlemock/test/gmock-matchers_test.cc
View file @
d8db0ca9
...
@@ -2680,7 +2680,7 @@ TEST(AllOfTest, ExplainsResult) {
...
@@ -2680,7 +2680,7 @@ TEST(AllOfTest, ExplainsResult) {
}
}
// Helper to allow easy testing of AnyOf matchers with num parameters.
// Helper to allow easy testing of AnyOf matchers with num parameters.
void
AnyOfMatches
(
int
num
,
const
Matcher
<
int
>&
m
)
{
static
void
AnyOfMatches
(
int
num
,
const
Matcher
<
int
>&
m
)
{
SCOPED_TRACE
(
Describe
(
m
));
SCOPED_TRACE
(
Describe
(
m
));
EXPECT_FALSE
(
m
.
Matches
(
0
));
EXPECT_FALSE
(
m
.
Matches
(
0
));
for
(
int
i
=
1
;
i
<=
num
;
++
i
)
{
for
(
int
i
=
1
;
i
<=
num
;
++
i
)
{
...
@@ -2689,6 +2689,18 @@ void AnyOfMatches(int num, const Matcher<int>& m) {
...
@@ -2689,6 +2689,18 @@ void AnyOfMatches(int num, const Matcher<int>& m) {
EXPECT_FALSE
(
m
.
Matches
(
num
+
1
));
EXPECT_FALSE
(
m
.
Matches
(
num
+
1
));
}
}
#if GTEST_LANG_CXX11
static
void
AnyOfStringMatches
(
int
num
,
const
Matcher
<
std
::
string
>&
m
)
{
SCOPED_TRACE
(
Describe
(
m
));
EXPECT_FALSE
(
m
.
Matches
(
std
::
to_string
(
0
)));
for
(
int
i
=
1
;
i
<=
num
;
++
i
)
{
EXPECT_TRUE
(
m
.
Matches
(
std
::
to_string
(
i
)));
}
EXPECT_FALSE
(
m
.
Matches
(
std
::
to_string
(
num
+
1
)));
}
#endif
// Tests that AnyOf(m1, ..., mn) matches any value that matches at
// Tests that AnyOf(m1, ..., mn) matches any value that matches at
// least one of the given matchers.
// least one of the given matchers.
TEST
(
AnyOfTest
,
MatchesWhenAnyMatches
)
{
TEST
(
AnyOfTest
,
MatchesWhenAnyMatches
)
{
...
@@ -2746,6 +2758,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
...
@@ -2746,6 +2758,12 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
21
,
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
31
,
32
,
33
,
34
,
35
,
36
,
37
,
38
,
39
,
40
,
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
));
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
));
AnyOfStringMatches
(
50
,
AnyOf
(
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
,
"7"
,
"8"
,
"9"
,
"10"
,
"11"
,
"12"
,
"13"
,
"14"
,
"15"
,
"16"
,
"17"
,
"18"
,
"19"
,
"20"
,
"21"
,
"22"
,
"23"
,
"24"
,
"25"
,
"26"
,
"27"
,
"28"
,
"29"
,
"30"
,
"31"
,
"32"
,
"33"
,
"34"
,
"35"
,
"36"
,
"37"
,
"38"
,
"39"
,
"40"
,
"41"
,
"42"
,
"43"
,
"44"
,
"45"
,
"46"
,
"47"
,
"48"
,
"49"
,
"50"
));
}
}
// Tests the variadic version of the ElementsAreMatcher
// Tests the variadic version of the ElementsAreMatcher
...
@@ -2777,6 +2795,7 @@ TEST(ElementsAreTest, HugeMatcherUnordered) {
...
@@ -2777,6 +2795,7 @@ TEST(ElementsAreTest, HugeMatcherUnordered) {
#endif // GTEST_LANG_CXX11
#endif // GTEST_LANG_CXX11
// Tests that AnyOf(m1, ..., mn) describes itself properly.
// Tests that AnyOf(m1, ..., mn) describes itself properly.
TEST
(
AnyOfTest
,
CanDescribeSelf
)
{
TEST
(
AnyOfTest
,
CanDescribeSelf
)
{
Matcher
<
int
>
m
;
Matcher
<
int
>
m
;
...
@@ -4570,7 +4589,7 @@ TEST(ResultOfTest, WorksForFunctors) {
...
@@ -4570,7 +4589,7 @@ TEST(ResultOfTest, WorksForFunctors) {
}
}
// Tests that ResultOf(f, ...) compiles and works as expected when f is a
// Tests that ResultOf(f, ...) compiles and works as expected when f is a
// functor with more th
e
n one operator() defined. ResultOf() must work
// functor with more th
a
n one operator() defined. ResultOf() must work
// for each defined operator().
// for each defined operator().
struct
PolymorphicFunctor
{
struct
PolymorphicFunctor
{
typedef
int
result_type
;
typedef
int
result_type
;
...
@@ -6764,4 +6783,3 @@ TEST(NotTest, WorksOnMoveOnlyType) {
...
@@ -6764,4 +6783,3 @@ TEST(NotTest, WorksOnMoveOnlyType) {
}
// namespace gmock_matchers_test
}
// namespace gmock_matchers_test
}
// namespace testing
}
// namespace testing
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