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
6aae206b
Commit
6aae206b
authored
Mar 26, 2018
by
Gennadiy Civil
Browse files
merging gmock-matchers.h 3
parent
23187058
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
13 deletions
+36
-13
googlemock/include/gmock/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