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
dff32aff
Commit
dff32aff
authored
Apr 17, 2018
by
Gennadiy Civil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http://cl/193060888
parent
3f88bb18
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
5 deletions
+55
-5
gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+13
-5
gmock-matchers_test.cc
googlemock/test/gmock-matchers_test.cc
+42
-0
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
dff32aff
...
@@ -5202,19 +5202,27 @@ std::string DescribeMatcher(const M& matcher, bool negation = false) {
...
@@ -5202,19 +5202,27 @@ 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
>
in
line
in
ternal
::
AllOfMatcher
<
Args
...
>
AllOf
(
const
Args
&
...
matchers
)
{
internal
::
AllOfMatcher
<
Args
...
>
AllOf
(
const
Args
&
...
matchers
)
{
return
internal
::
AllOfMatcher
<
Args
...
>
(
matchers
...);
return
internal
::
AllOfMatcher
<
Args
...
>
(
matchers
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
in
line
in
ternal
::
AnyOfMatcher
<
Args
...
>
AnyOf
(
const
Args
&
...
matchers
)
{
internal
::
AnyOfMatcher
<
Args
...
>
AnyOf
(
const
Args
&
...
matchers
)
{
return
internal
::
AnyOfMatcher
<
Args
...
>
(
matchers
...);
return
internal
::
AnyOfMatcher
<
Args
...
>
(
matchers
...);
}
}
template
<
typename
...
Args
>
template
<
typename
...
Args
>
inline
internal
::
UnorderedElementsAreMatcher
<
Args
...
>
internal
::
ElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
Args
>::
type
...
>>
UnorderedElementsAreMatcher
(
const
Args
&
...
matchers
)
{
ElementsAre
(
const
Args
&
...
matchers
)
{
return
internal
::
UnorderedElementsAreMatcher
<
Args
...
>
(
matchers
...);
return
internal
::
ElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
Args
>::
type
...
>>
(
make_tuple
(
matchers
...));
}
template
<
typename
...
Args
>
internal
::
UnorderedElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
Args
>::
type
...
>>
UnorderedElementsAre
(
const
Args
&
...
matchers
)
{
return
internal
::
UnorderedElementsAreMatcher
<
tuple
<
typename
std
::
decay
<
Args
>::
type
...
>>
(
make_tuple
(
matchers
...));
}
}
#endif // GTEST_LANG_CXX11
#endif // GTEST_LANG_CXX11
...
...
googlemock/test/gmock-matchers_test.cc
View file @
dff32aff
...
@@ -2742,6 +2742,48 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
...
@@ -2742,6 +2742,48 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
));
41
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
49
,
50
));
}
}
// Tests the variadic version of the ElementsAreMatcher
TEST
(
ElementsAreTest
,
HugeMatcher
)
{
vector
<
int
>
test_vector
;
test_vector
.
push_back
(
1
);
test_vector
.
push_back
(
2
);
test_vector
.
push_back
(
3
);
test_vector
.
push_back
(
4
);
test_vector
.
push_back
(
5
);
test_vector
.
push_back
(
6
);
test_vector
.
push_back
(
7
);
test_vector
.
push_back
(
8
);
test_vector
.
push_back
(
9
);
test_vector
.
push_back
(
10
);
test_vector
.
push_back
(
11
);
test_vector
.
push_back
(
12
);
EXPECT_THAT
(
test_vector
,
ElementsAre
(
Eq
(
1
),
Eq
(
2
),
Lt
(
13
),
Eq
(
4
),
Eq
(
5
),
Eq
(
6
),
Eq
(
7
),
Eq
(
8
),
Eq
(
9
),
Eq
(
10
),
Gt
(
1
),
Eq
(
12
)
));
}
// Tests the variadic version of the UnorderedElementsAreMatcher
TEST
(
ElementsAreTest
,
HugeMatcherUnordered
)
{
vector
<
int
>
test_vector
;
test_vector
.
push_back
(
1
);
test_vector
.
push_back
(
2
);
test_vector
.
push_back
(
3
);
test_vector
.
push_back
(
4
);
test_vector
.
push_back
(
5
);
test_vector
.
push_back
(
6
);
test_vector
.
push_back
(
7
);
test_vector
.
push_back
(
8
);
test_vector
.
push_back
(
9
);
test_vector
.
push_back
(
10
);
test_vector
.
push_back
(
11
);
test_vector
.
push_back
(
12
);
EXPECT_THAT
(
test_vector
,
UnorderedElementsAre
(
Eq
(
1
),
Eq
(
2
),
Eq
(
3
),
Eq
(
4
),
Eq
(
5
),
Eq
(
6
),
Eq
(
7
),
Eq
(
8
),
Eq
(
9
),
Eq
(
10
),
Eq
(
11
),
Ne
(
122
)
));
}
#endif // GTEST_LANG_CXX11
#endif // GTEST_LANG_CXX11
// Tests that AnyOf(m1, ..., mn) describes itself properly.
// Tests that AnyOf(m1, ..., mn) describes itself properly.
...
...
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