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
9b1a944e
Commit
9b1a944e
authored
Apr 28, 2015
by
kosak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix EXPECT_THAT() to support literal strings as a second argument.
parent
6305ff5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
gmock-matchers.h
include/gmock/gmock-matchers.h
+4
-3
gmock-matchers_test.cc
test/gmock-matchers_test.cc
+15
-0
No files found.
include/gmock/gmock-matchers.h
View file @
9b1a944e
...
...
@@ -1833,7 +1833,7 @@ class MatcherAsPredicate {
template
<
typename
M
>
class
PredicateFormatterFromMatcher
{
public
:
explicit
PredicateFormatterFromMatcher
(
const
M
&
m
)
:
matcher_
(
m
)
{}
explicit
PredicateFormatterFromMatcher
(
M
m
)
:
matcher_
(
internal
::
move
(
m
)
)
{}
// This template () operator allows a PredicateFormatterFromMatcher
// object to act as a predicate-formatter suitable for using with
...
...
@@ -1873,10 +1873,11 @@ class PredicateFormatterFromMatcher {
// A helper function for converting a matcher to a predicate-formatter
// without the user needing to explicitly write the type. This is
// used for implementing ASSERT_THAT() and EXPECT_THAT().
// Implementation detail: 'matcher' is received by-value to force decaying.
template
<
typename
M
>
inline
PredicateFormatterFromMatcher
<
M
>
MakePredicateFormatterFromMatcher
(
const
M
&
matcher
)
{
return
PredicateFormatterFromMatcher
<
M
>
(
matcher
);
MakePredicateFormatterFromMatcher
(
M
matcher
)
{
return
PredicateFormatterFromMatcher
<
M
>
(
internal
::
move
(
matcher
)
);
}
// Implements the polymorphic floating point equality matcher, which matches
...
...
test/gmock-matchers_test.cc
View file @
9b1a944e
...
...
@@ -762,6 +762,21 @@ TEST(SafeMatcherCastTest, ValueIsNotCopied) {
EXPECT_TRUE
(
m
.
Matches
(
n
));
}
TEST
(
ExpectThat
,
TakesLiterals
)
{
EXPECT_THAT
(
1
,
1
);
EXPECT_THAT
(
1.0
,
1.0
);
EXPECT_THAT
(
string
(),
""
);
}
TEST
(
ExpectThat
,
TakesFunctions
)
{
struct
Helper
{
static
void
Func
()
{}
};
void
(
*
func
)()
=
Helper
::
Func
;
EXPECT_THAT
(
func
,
Helper
::
Func
);
EXPECT_THAT
(
func
,
&
Helper
::
Func
);
}
// Tests that A<T>() matches any value of type T.
TEST
(
ATest
,
MatchesAnyValue
)
{
// Tests a matcher for a value type.
...
...
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