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
6aae206b
Commit
6aae206b
authored
Mar 26, 2018
by
Gennadiy Civil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merging gmock-matchers.h 3
parent
23187058
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
13 deletions
+36
-13
gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+36
-13
No files found.
googlemock/include/gmock/gmock-matchers.h
View file @
6aae206b
...
@@ -281,7 +281,8 @@ class MatcherBase {
...
@@ -281,7 +281,8 @@ class MatcherBase {
public
:
public
:
// Returns true iff the matcher matches x; also explains the match
// Returns true iff the matcher matches x; also explains the match
// result to 'listener'.
// result to 'listener'.
bool
MatchAndExplain
(
T
x
,
MatchResultListener
*
listener
)
const
{
bool
MatchAndExplain
(
GTEST_REFERENCE_TO_CONST_
(
T
)
x
,
MatchResultListener
*
listener
)
const
{
return
impl_
->
MatchAndExplain
(
x
,
listener
);
return
impl_
->
MatchAndExplain
(
x
,
listener
);
}
}
...
@@ -2351,15 +2352,21 @@ class FieldMatcher {
...
@@ -2351,15 +2352,21 @@ class FieldMatcher {
public
:
public
:
FieldMatcher
(
FieldType
Class
::*
field
,
FieldMatcher
(
FieldType
Class
::*
field
,
const
Matcher
<
const
FieldType
&>&
matcher
)
const
Matcher
<
const
FieldType
&>&
matcher
)
:
field_
(
field
),
matcher_
(
matcher
)
{}
:
field_
(
field
),
matcher_
(
matcher
),
whose_field_
(
"whose given field "
)
{}
FieldMatcher
(
const
std
::
string
&
field_name
,
FieldType
Class
::*
field
,
const
Matcher
<
const
FieldType
&>&
matcher
)
:
field_
(
field
),
matcher_
(
matcher
),
whose_field_
(
"whose field `"
+
field_name
+
"` "
)
{}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is an object
whose given field "
;
*
os
<<
"is an object
"
<<
whose_field_
;
matcher_
.
DescribeTo
(
os
);
matcher_
.
DescribeTo
(
os
);
}
}
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is an object
whose given field "
;
*
os
<<
"is an object
"
<<
whose_field_
;
matcher_
.
DescribeNegationTo
(
os
);
matcher_
.
DescribeNegationTo
(
os
);
}
}
...
@@ -2377,7 +2384,7 @@ class FieldMatcher {
...
@@ -2377,7 +2384,7 @@ class FieldMatcher {
// true_type iff the Field() matcher is used to match a pointer.
// true_type iff the Field() matcher is used to match a pointer.
bool
MatchAndExplainImpl
(
false_type
/* is_not_pointer */
,
const
Class
&
obj
,
bool
MatchAndExplainImpl
(
false_type
/* is_not_pointer */
,
const
Class
&
obj
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
*
listener
<<
"whose given field
is "
;
*
listener
<<
whose_field_
<<
"
is "
;
return
MatchPrintAndExplain
(
obj
.
*
field_
,
matcher_
,
listener
);
return
MatchPrintAndExplain
(
obj
.
*
field_
,
matcher_
,
listener
);
}
}
...
@@ -2396,6 +2403,10 @@ class FieldMatcher {
...
@@ -2396,6 +2403,10 @@ class FieldMatcher {
const
FieldType
Class
::*
field_
;
const
FieldType
Class
::*
field_
;
const
Matcher
<
const
FieldType
&>
matcher_
;
const
Matcher
<
const
FieldType
&>
matcher_
;
// Contains either "whose given field " if the name of the field is unknown
// or "whose field `name_of_field` " if the name is known.
const
std
::
string
whose_field_
;
GTEST_DISALLOW_ASSIGN_
(
FieldMatcher
);
GTEST_DISALLOW_ASSIGN_
(
FieldMatcher
);
};
};
...
@@ -2414,15 +2425,23 @@ class PropertyMatcher {
...
@@ -2414,15 +2425,23 @@ class PropertyMatcher {
typedef
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
RefToConstProperty
;
typedef
GTEST_REFERENCE_TO_CONST_
(
PropertyType
)
RefToConstProperty
;
PropertyMatcher
(
Property
property
,
const
Matcher
<
RefToConstProperty
>&
matcher
)
PropertyMatcher
(
Property
property
,
const
Matcher
<
RefToConstProperty
>&
matcher
)
:
property_
(
property
),
matcher_
(
matcher
)
{}
:
property_
(
property
),
matcher_
(
matcher
),
whose_property_
(
"whose given property "
)
{}
PropertyMatcher
(
const
std
::
string
&
property_name
,
Property
property
,
const
Matcher
<
RefToConstProperty
>&
matcher
)
:
property_
(
property
),
matcher_
(
matcher
),
whose_property_
(
"whose property `"
+
property_name
+
"` "
)
{}
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is an object
whose given property "
;
*
os
<<
"is an object
"
<<
whose_property_
;
matcher_
.
DescribeTo
(
os
);
matcher_
.
DescribeTo
(
os
);
}
}
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
*
os
<<
"is an object
whose given property "
;
*
os
<<
"is an object
"
<<
whose_property_
;
matcher_
.
DescribeNegationTo
(
os
);
matcher_
.
DescribeNegationTo
(
os
);
}
}
...
@@ -2440,7 +2459,7 @@ class PropertyMatcher {
...
@@ -2440,7 +2459,7 @@ class PropertyMatcher {
// true_type iff the Property() matcher is used to match a pointer.
// true_type iff the Property() matcher is used to match a pointer.
bool
MatchAndExplainImpl
(
false_type
/* is_not_pointer */
,
const
Class
&
obj
,
bool
MatchAndExplainImpl
(
false_type
/* is_not_pointer */
,
const
Class
&
obj
,
MatchResultListener
*
listener
)
const
{
MatchResultListener
*
listener
)
const
{
*
listener
<<
"whose given property
is "
;
*
listener
<<
whose_property_
<<
"
is "
;
// Cannot pass the return value (for example, int) to MatchPrintAndExplain,
// Cannot pass the return value (for example, int) to MatchPrintAndExplain,
// which takes a non-const reference as argument.
// which takes a non-const reference as argument.
#if defined(_PREFAST_ ) && _MSC_VER == 1800
#if defined(_PREFAST_ ) && _MSC_VER == 1800
...
@@ -2469,6 +2488,10 @@ class PropertyMatcher {
...
@@ -2469,6 +2488,10 @@ class PropertyMatcher {
Property
property_
;
Property
property_
;
const
Matcher
<
RefToConstProperty
>
matcher_
;
const
Matcher
<
RefToConstProperty
>
matcher_
;
// Contains either "whose given property " if the name of the property is
// unknown or "whose property `name_of_property` " if the name is known.
const
std
::
string
whose_property_
;
GTEST_DISALLOW_ASSIGN_
(
PropertyMatcher
);
GTEST_DISALLOW_ASSIGN_
(
PropertyMatcher
);
};
};
...
@@ -3263,18 +3286,18 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
...
@@ -3263,18 +3286,18 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
if
(
!
listener
->
IsInterested
())
{
if
(
!
listener
->
IsInterested
())
{
// If the listener is not interested, we don't need to construct the
// If the listener is not interested, we don't need to construct the
// explanation.
// explanation.
return
first_matcher_
.
Matches
(
a_pair
.
first
)
&&
return
first_matcher_
.
Matches
(
pair_getters
::
First
(
a_pair
,
Rank0
())
)
&&
second_matcher_
.
Matches
(
a_pair
.
second
);
second_matcher_
.
Matches
(
pair_getters
::
Second
(
a_pair
,
Rank0
())
);
}
}
StringMatchResultListener
first_inner_listener
;
StringMatchResultListener
first_inner_listener
;
if
(
!
first_matcher_
.
MatchAndExplain
(
a_pair
.
first
,
if
(
!
first_matcher_
.
MatchAndExplain
(
pair_getters
::
First
(
a_pair
,
Rank0
())
,
&
first_inner_listener
))
{
&
first_inner_listener
))
{
*
listener
<<
"whose first field does not match"
;
*
listener
<<
"whose first field does not match"
;
PrintIfNotEmpty
(
first_inner_listener
.
str
(),
listener
->
stream
());
PrintIfNotEmpty
(
first_inner_listener
.
str
(),
listener
->
stream
());
return
false
;
return
false
;
}
}
StringMatchResultListener
second_inner_listener
;
StringMatchResultListener
second_inner_listener
;
if
(
!
second_matcher_
.
MatchAndExplain
(
a_pair
.
second
,
if
(
!
second_matcher_
.
MatchAndExplain
(
pair_getters
::
Second
(
a_pair
,
Rank0
())
,
&
second_inner_listener
))
{
&
second_inner_listener
))
{
*
listener
<<
"whose second field does not match"
;
*
listener
<<
"whose second field does not match"
;
PrintIfNotEmpty
(
second_inner_listener
.
str
(),
listener
->
stream
());
PrintIfNotEmpty
(
second_inner_listener
.
str
(),
listener
->
stream
());
...
...
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