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
23187058
Commit
23187058
authored
Mar 26, 2018
by
Gennadiy Civil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merging gmock-matchers.h 2
parent
8ea10d38
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
7 deletions
+44
-7
gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+44
-7
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
23187058
...
@@ -2862,6 +2862,10 @@ class WhenSortedByMatcher {
...
@@ -2862,6 +2862,10 @@ class WhenSortedByMatcher {
// container and the RHS container respectively.
// container and the RHS container respectively.
template
<
typename
TupleMatcher
,
typename
RhsContainer
>
template
<
typename
TupleMatcher
,
typename
RhsContainer
>
class
PointwiseMatcher
{
class
PointwiseMatcher
{
GTEST_COMPILE_ASSERT_
(
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
RhsContainer
)
>::
value
,
use_UnorderedPointwise_with_hash_tables
);
public
:
public
:
typedef
internal
::
StlContainerView
<
RhsContainer
>
RhsView
;
typedef
internal
::
StlContainerView
<
RhsContainer
>
RhsView
;
typedef
typename
RhsView
::
type
RhsStlContainer
;
typedef
typename
RhsView
::
type
RhsStlContainer
;
...
@@ -2879,6 +2883,10 @@ class PointwiseMatcher {
...
@@ -2879,6 +2883,10 @@ class PointwiseMatcher {
template
<
typename
LhsContainer
>
template
<
typename
LhsContainer
>
operator
Matcher
<
LhsContainer
>
()
const
{
operator
Matcher
<
LhsContainer
>
()
const
{
GTEST_COMPILE_ASSERT_
(
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
LhsContainer
)
>::
value
,
use_UnorderedPointwise_with_hash_tables
);
return
MakeMatcher
(
new
Impl
<
LhsContainer
>
(
tuple_matcher_
,
rhs_
));
return
MakeMatcher
(
new
Impl
<
LhsContainer
>
(
tuple_matcher_
,
rhs_
));
}
}
...
@@ -2929,12 +2937,15 @@ class PointwiseMatcher {
...
@@ -2929,12 +2937,15 @@ class PointwiseMatcher {
typename
LhsStlContainer
::
const_iterator
left
=
lhs_stl_container
.
begin
();
typename
LhsStlContainer
::
const_iterator
left
=
lhs_stl_container
.
begin
();
typename
RhsStlContainer
::
const_iterator
right
=
rhs_
.
begin
();
typename
RhsStlContainer
::
const_iterator
right
=
rhs_
.
begin
();
for
(
size_t
i
=
0
;
i
!=
actual_size
;
++
i
,
++
left
,
++
right
)
{
for
(
size_t
i
=
0
;
i
!=
actual_size
;
++
i
,
++
left
,
++
right
)
{
const
InnerMatcherArg
value_pair
(
*
left
,
*
right
);
if
(
listener
->
IsInterested
())
{
if
(
listener
->
IsInterested
())
{
StringMatchResultListener
inner_listener
;
StringMatchResultListener
inner_listener
;
// Create InnerMatcherArg as a temporarily object to avoid it outlives
// *left and *right. Dereference or the conversion to `const T&` may
// return temp objects, e.g for vector<bool>.
if
(
!
mono_tuple_matcher_
.
MatchAndExplain
(
if
(
!
mono_tuple_matcher_
.
MatchAndExplain
(
value_pair
,
&
inner_listener
))
{
InnerMatcherArg
(
ImplicitCast_
<
const
LhsValue
&>
(
*
left
),
ImplicitCast_
<
const
RhsValue
&>
(
*
right
)),
&
inner_listener
))
{
*
listener
<<
"where the value pair ("
;
*
listener
<<
"where the value pair ("
;
UniversalPrint
(
*
left
,
listener
->
stream
());
UniversalPrint
(
*
left
,
listener
->
stream
());
*
listener
<<
", "
;
*
listener
<<
", "
;
...
@@ -2944,7 +2955,9 @@ class PointwiseMatcher {
...
@@ -2944,7 +2955,9 @@ class PointwiseMatcher {
return
false
;
return
false
;
}
}
}
else
{
}
else
{
if
(
!
mono_tuple_matcher_
.
Matches
(
value_pair
))
if
(
!
mono_tuple_matcher_
.
Matches
(
InnerMatcherArg
(
ImplicitCast_
<
const
LhsValue
&>
(
*
left
),
ImplicitCast_
<
const
RhsValue
&>
(
*
right
))))
return
false
;
return
false
;
}
}
}
}
...
@@ -3166,8 +3179,8 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
...
@@ -3166,8 +3179,8 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
virtual
bool
MatchAndExplain
(
PairType
key_value
,
virtual
bool
MatchAndExplain
(
PairType
key_value
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
StringMatchResultListener
inner_listener
;
StringMatchResultListener
inner_listener
;
const
bool
match
=
inner_matcher_
.
MatchAndExplain
(
key_value
.
first
,
const
bool
match
=
inner_matcher_
.
MatchAndExplain
(
&
inner_listener
);
pair_getters
::
First
(
key_value
,
Rank0
()),
&
inner_listener
);
const
std
::
string
explanation
=
inner_listener
.
str
();
const
std
::
string
explanation
=
inner_listener
.
str
();
if
(
explanation
!=
""
)
{
if
(
explanation
!=
""
)
{
*
listener
<<
"whose first field is a value "
<<
explanation
;
*
listener
<<
"whose first field is a value "
<<
explanation
;
...
@@ -3708,6 +3721,11 @@ class ElementsAreMatcher {
...
@@ -3708,6 +3721,11 @@ class ElementsAreMatcher {
template
<
typename
Container
>
template
<
typename
Container
>
operator
Matcher
<
Container
>
()
const
{
operator
Matcher
<
Container
>
()
const
{
GTEST_COMPILE_ASSERT_
(
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
>::
value
||
::
testing
::
tuple_size
<
MatcherTuple
>::
value
<
2
,
use_UnorderedElementsAre_with_hash_tables
);
typedef
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
RawContainer
;
typedef
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
RawContainer
;
typedef
typename
internal
::
StlContainerView
<
RawContainer
>::
type
View
;
typedef
typename
internal
::
StlContainerView
<
RawContainer
>::
type
View
;
typedef
typename
View
::
value_type
Element
;
typedef
typename
View
::
value_type
Element
;
...
@@ -3756,6 +3774,10 @@ class ElementsAreArrayMatcher {
...
@@ -3756,6 +3774,10 @@ class ElementsAreArrayMatcher {
template
<
typename
Container
>
template
<
typename
Container
>
operator
Matcher
<
Container
>
()
const
{
operator
Matcher
<
Container
>
()
const
{
GTEST_COMPILE_ASSERT_
(
!
IsHashTable
<
GTEST_REMOVE_REFERENCE_AND_CONST_
(
Container
)
>::
value
,
use_UnorderedElementsAreArray_with_hash_tables
);
return
MakeMatcher
(
new
ElementsAreMatcherImpl
<
Container
>
(
return
MakeMatcher
(
new
ElementsAreMatcherImpl
<
Container
>
(
matchers_
.
begin
(),
matchers_
.
end
()));
matchers_
.
begin
(),
matchers_
.
end
()));
}
}
...
@@ -3953,7 +3975,7 @@ class VariantMatcher {
...
@@ -3953,7 +3975,7 @@ class VariantMatcher {
}
}
private
:
private
:
static
string
GetTypeName
()
{
static
st
d
::
st
ring
GetTypeName
()
{
#if GTEST_HAS_RTTI
#if GTEST_HAS_RTTI
return
internal
::
GetTypeName
<
T
>
();
return
internal
::
GetTypeName
<
T
>
();
#endif
#endif
...
@@ -4351,6 +4373,21 @@ Property(PropertyType (Class::*property)() const,
...
@@ -4351,6 +4373,21 @@ Property(PropertyType (Class::*property)() const,
// to compile where bar() returns an int32 and m is a matcher for int64.
// to compile where bar() returns an int32 and m is a matcher for int64.
}
}
// Same as Property() above, but also takes the name of the property to provide
// better error messages.
template
<
typename
Class
,
typename
PropertyType
,
typename
PropertyMatcher
>
inline
PolymorphicMatcher
<
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
>
>
Property
(
const
std
::
string
&
property_name
,
PropertyType
(
Class
::*
property
)()
const
,
const
PropertyMatcher
&
matcher
)
{
return
MakePolymorphicMatcher
(
internal
::
PropertyMatcher
<
Class
,
PropertyType
,
PropertyType
(
Class
::*
)()
const
>
(
property_name
,
property
,
MatcherCast
<
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
>
(
matcher
)));
}
#if GTEST_LANG_CXX11
#if GTEST_LANG_CXX11
// The same as above but for reference-qualified member functions.
// The same as above but for reference-qualified member functions.
template
<
typename
Class
,
typename
PropertyType
,
typename
PropertyMatcher
>
template
<
typename
Class
,
typename
PropertyType
,
typename
PropertyMatcher
>
...
...
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