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
2661c682
Commit
2661c682
authored
Jun 09, 2009
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implements the Args<k1, ..., kn>(m) matcher.
parent
240fe5a0
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
274 additions
and
29 deletions
+274
-29
gmock-generated-matchers.h
include/gmock/gmock-generated-matchers.h
+0
-0
gmock-generated-matchers.h.pump
include/gmock/gmock-generated-matchers.h.pump
+141
-0
gmock-matchers.h
include/gmock/gmock-matchers.h
+9
-9
gmock-spec-builders.h
include/gmock/gmock-spec-builders.h
+2
-2
gmock-generated-matchers_test.cc
test/gmock-generated-matchers_test.cc
+107
-2
gmock-internal-utils_test.cc
test/gmock-internal-utils_test.cc
+1
-1
gmock-matchers_test.cc
test/gmock-matchers_test.cc
+10
-11
gmock_output_test_golden.txt
test/gmock_output_test_golden.txt
+4
-4
No files found.
include/gmock/gmock-generated-matchers.h
View file @
2661c682
This diff is collapsed.
Click to expand it.
include/gmock/gmock-generated-matchers.h.pump
View file @
2661c682
...
@@ -3,6 +3,7 @@ $$ This is a Pump source file. Please use Pump to convert it to
...
@@ -3,6 +3,7 @@ $$ This is a Pump source file. Please use Pump to convert it to
$$
gmock
-
generated
-
variadic
-
actions
.
h
.
$$
gmock
-
generated
-
variadic
-
actions
.
h
.
$$
$$
$
var
n
=
10
$$
The
maximum
arity
we
support
.
$
var
n
=
10
$$
The
maximum
arity
we
support
.
$$
}}
This
line
fixes
auto
-
indentation
of
the
following
code
in
Emacs
.
// Copyright 2008, Google Inc.
// Copyright 2008, Google Inc.
// All rights reserved.
// All rights reserved.
//
//
...
@@ -48,6 +49,130 @@ $var n = 10 $$ The maximum arity we support.
...
@@ -48,6 +49,130 @@ $var n = 10 $$ The maximum arity we support.
namespace
testing
{
namespace
testing
{
namespace
internal
{
namespace
internal
{
$
range
i
0.
.
n
-
1
// The type of the i-th (0-based) field of Tuple.
#define GMOCK_FIELD_TYPE_(Tuple, i) \
typename ::std::tr1::tuple_element<i, Tuple>::type
// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a
// tuple of type Tuple. It has two members:
//
// type: a tuple type whose i-th field is the ki-th field of Tuple.
// GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.
//
// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:
//
// type is tuple<int, bool>, and
// GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).
template
<
class
Tuple
$
for
i
[[,
int
k
$
i
=
-
1
]]
>
class
TupleFields
;
// This generic version is used when there are $n selectors.
template
<
class
Tuple
$
for
i
[[,
int
k
$
i
]]
>
class
TupleFields
{
public
:
typedef
::
std
::
tr1
::
tuple
<
$
for
i
,
[[
GMOCK_FIELD_TYPE_
(
Tuple
,
k
$
i
)]]
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
using
::
std
::
tr1
::
get
;
return
type
(
$
for
i
,
[[
get
<
k
$
i
>
(
t
)]]);
}
};
// The following specialization is used for 0 ~ $(n-1) selectors.
$
for
i
[[
$$
}}}
$
range
j
0.
.
i
-
1
$
range
k
0.
.
n
-
1
template
<
class
Tuple
$
for
j
[[,
int
k
$
j
]]
>
class
TupleFields
<
Tuple
,
$
for
k
,
[[
$
if
k
<
i
[[
k
$
k
]]
$
else
[[
-
1
]]]]
>
{
public
:
typedef
::
std
::
tr1
::
tuple
<
$
for
j
,
[[
GMOCK_FIELD_TYPE_
(
Tuple
,
k
$
j
)]]
>
type
;
static
type
GetSelectedFields
(
const
Tuple
&
t
)
{
using
::
std
::
tr1
::
get
;
return
type
(
$
for
j
,
[[
get
<
k
$
j
>
(
t
)]]);
}
};
]]
#undef GMOCK_FIELD_TYPE_
// Implements the Args() matcher.
$
var
ks
=
[[
$
for
i
,
[[
k
$
i
]]]]
template
<
class
ArgsTuple
$
for
i
[[,
int
k
$
i
=
-
1
]]
>
class
ArgsMatcherImpl
:
public
MatcherInterface
<
ArgsTuple
>
{
public
:
// ArgsTuple may have top-level const or reference modifiers.
typedef
GMOCK_REMOVE_CONST_
(
GMOCK_REMOVE_REFERENCE_
(
ArgsTuple
))
RawArgsTuple
;
typedef
typename
internal
::
TupleFields
<
RawArgsTuple
,
$
ks
>::
type
SelectedArgs
;
typedef
Matcher
<
const
SelectedArgs
&>
MonomorphicInnerMatcher
;
template
<
typename
InnerMatcher
>
explicit
ArgsMatcherImpl
(
const
InnerMatcher
&
inner_matcher
)
:
inner_matcher_
(
SafeMatcherCast
<
const
SelectedArgs
&>
(
inner_matcher
))
{}
virtual
bool
Matches
(
ArgsTuple
args
)
const
{
return
inner_matcher_
.
Matches
(
GetSelectedArgs
(
args
));
}
virtual
void
DescribeTo
(
::
std
::
ostream
*
os
)
const
{
PrintIndices
(
os
);
inner_matcher_
.
DescribeTo
(
os
);
}
virtual
void
DescribeNegationTo
(
::
std
::
ostream
*
os
)
const
{
PrintIndices
(
os
);
inner_matcher_
.
DescribeNegationTo
(
os
);
}
virtual
void
ExplainMatchResultTo
(
ArgsTuple
args
,
::
std
::
ostream
*
os
)
const
{
inner_matcher_
.
ExplainMatchResultTo
(
GetSelectedArgs
(
args
),
os
);
}
private
:
static
SelectedArgs
GetSelectedArgs
(
ArgsTuple
args
)
{
return
TupleFields
<
RawArgsTuple
,
$
ks
>::
GetSelectedFields
(
args
);
}
// Prints the indices of the selected fields.
static
void
PrintIndices
(
::
std
::
ostream
*
os
)
{
*
os
<<
"are a tuple whose fields ("
;
const
int
indices
[
$
n
]
=
{
$
ks
};
for
(
int
i
=
0
;
i
<
$
n
;
i
++
)
{
if
(
indices
[
i
]
<
0
)
break
;
if
(
i
>=
1
)
*
os
<<
", "
;
*
os
<<
"#"
<<
indices
[
i
];
}
*
os
<<
") "
;
}
const
MonomorphicInnerMatcher
inner_matcher_
;
};
template
<
class
InnerMatcher
$
for
i
[[,
int
k
$
i
=
-
1
]]
>
class
ArgsMatcher
{
public
:
explicit
ArgsMatcher
(
const
InnerMatcher
&
inner_matcher
)
:
inner_matcher_
(
inner_matcher
)
{}
template
<
typename
ArgsTuple
>
operator
Matcher
<
ArgsTuple
>
()
const
{
return
MakeMatcher
(
new
ArgsMatcherImpl
<
ArgsTuple
,
$
ks
>
(
inner_matcher_
));
}
const
InnerMatcher
inner_matcher_
;
};
// Implements ElementsAre() and ElementsAreArray().
// Implements ElementsAre() and ElementsAreArray().
template
<
typename
Container
>
template
<
typename
Container
>
class
ElementsAreMatcherImpl
:
public
MatcherInterface
<
Container
>
{
class
ElementsAreMatcherImpl
:
public
MatcherInterface
<
Container
>
{
...
@@ -268,6 +393,21 @@ class ElementsAreArrayMatcher {
...
@@ -268,6 +393,21 @@ class ElementsAreArrayMatcher {
}
// namespace internal
}
// namespace internal
// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected
// fields of it matches a_matcher. C++ doesn't support default
// arguments for function templates, so we have to overload it.
$
range
i
0.
.
n
$
for
i
[[
$
range
j
1.
.
i
template
<
$
for
j
[[
int
k
$
j
,
]]
typename
InnerMatcher
>
inline
internal
::
ArgsMatcher
<
InnerMatcher
$
for
j
[[,
k
$
j
]]
>
Args
(
const
InnerMatcher
&
matcher
)
{
return
internal
::
ArgsMatcher
<
InnerMatcher
$
for
j
[[,
k
$
j
]]
>
(
matcher
);
}
]]
// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
// ElementsAre(e0, e1, ..., e_n) matches an STL-style container with
// (n + 1) elements, where the i-th element in the container must
// (n + 1) elements, where the i-th element in the container must
// match the i-th argument in the list. Each argument of
// match the i-th argument in the list. Each argument of
...
@@ -282,6 +422,7 @@ inline internal::ElementsAreMatcher0 ElementsAre() {
...
@@ -282,6 +422,7 @@ inline internal::ElementsAreMatcher0 ElementsAre() {
return
internal
::
ElementsAreMatcher0
();
return
internal
::
ElementsAreMatcher0
();
}
}
$
range
i
1.
.
n
$
for
i
[[
$
for
i
[[
$
range
j
1.
.
i
$
range
j
1.
.
i
...
...
include/gmock/gmock-matchers.h
View file @
2661c682
...
@@ -938,7 +938,7 @@ class MatchesRegexMatcher {
...
@@ -938,7 +938,7 @@ class MatchesRegexMatcher {
//
//
// We define this as a macro in order to eliminate duplicated source
// We define this as a macro in order to eliminate duplicated source
// code.
// code.
#define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op
, relation
) \
#define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op) \
class name##2Matcher { \
class name##2Matcher { \
public: \
public: \
template <typename T1, typename T2> \
template <typename T1, typename T2> \
...
@@ -953,21 +953,21 @@ class MatchesRegexMatcher {
...
@@ -953,21 +953,21 @@ class MatchesRegexMatcher {
return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \
return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \
} \
} \
virtual void DescribeTo(::std::ostream* os) const { \
virtual void DescribeTo(::std::ostream* os) const { \
*os << "ar
gument #0 is " relation " argument #1
"; \
*os << "ar
e a pair (x, y) where x " #op " y
"; \
} \
} \
virtual void DescribeNegationTo(::std::ostream* os) const { \
virtual void DescribeNegationTo(::std::ostream* os) const { \
*os << "ar
gument #0 is not " relation " argument #1
"; \
*os << "ar
e a pair (x, y) where x " #op " y is false
"; \
} \
} \
}; \
}; \
}
}
// Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively.
// Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively.
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Eq
,
==
,
"equal to"
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Eq
,
==
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Ge
,
>=
,
"greater than or equal to"
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Ge
,
>=
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Gt
,
>
,
"greater than"
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Gt
,
>
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Le
,
<=
,
"less than or equal to"
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Le
,
<=
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Lt
,
<
,
"less than"
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Lt
,
<
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Ne
,
!=
,
"not equal to"
);
GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
(
Ne
,
!=
);
#undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
#undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_
...
...
include/gmock/gmock-spec-builders.h
View file @
2661c682
...
@@ -795,9 +795,9 @@ class Expectation : public ExpectationBase {
...
@@ -795,9 +795,9 @@ class Expectation : public ExpectationBase {
DescribeMatchFailureTupleTo
(
matchers_
,
args
,
os
);
DescribeMatchFailureTupleTo
(
matchers_
,
args
,
os
);
}
}
if
(
!
extra_matcher_
.
Matches
(
args
))
{
if
(
!
extra_matcher_
.
Matches
(
args
))
{
*
os
<<
"
Expected
: "
;
*
os
<<
"
Expected args
: "
;
extra_matcher_
.
DescribeTo
(
os
);
extra_matcher_
.
DescribeTo
(
os
);
*
os
<<
"
\n
Actual:
false
"
;
*
os
<<
"
\n
Actual:
don't match
"
;
internal
::
ExplainMatchResultAsNeededTo
<
const
ArgumentTuple
&>
(
internal
::
ExplainMatchResultAsNeededTo
<
const
ArgumentTuple
&>
(
extra_matcher_
,
args
,
os
);
extra_matcher_
,
args
,
os
);
...
...
test/gmock-generated-matchers_test.cc
View file @
2661c682
...
@@ -53,8 +53,11 @@ using std::pair;
...
@@ -53,8 +53,11 @@ using std::pair;
using
std
::
set
;
using
std
::
set
;
using
std
::
stringstream
;
using
std
::
stringstream
;
using
std
::
vector
;
using
std
::
vector
;
using
std
::
tr1
::
get
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
make_tuple
;
using
std
::
tr1
::
tuple
;
using
testing
::
_
;
using
testing
::
_
;
using
testing
::
Args
;
using
testing
::
Contains
;
using
testing
::
Contains
;
using
testing
::
ElementsAre
;
using
testing
::
ElementsAre
;
using
testing
::
ElementsAreArray
;
using
testing
::
ElementsAreArray
;
...
@@ -98,6 +101,107 @@ string Explain(const MatcherType& m, const Value& x) {
...
@@ -98,6 +101,107 @@ string Explain(const MatcherType& m, const Value& x) {
return
ss
.
str
();
return
ss
.
str
();
}
}
// Tests Args<k0, ..., kn>(m).
TEST
(
ArgsTest
,
AcceptsZeroTemplateArg
)
{
const
tuple
<
int
,
bool
>
t
(
5
,
true
);
EXPECT_THAT
(
t
,
Args
<>
(
Eq
(
tuple
<>
())));
EXPECT_THAT
(
t
,
Not
(
Args
<>
(
Ne
(
tuple
<>
()))));
}
TEST
(
ArgsTest
,
AcceptsOneTemplateArg
)
{
const
tuple
<
int
,
bool
>
t
(
5
,
true
);
EXPECT_THAT
(
t
,
Args
<
0
>
(
Eq
(
make_tuple
(
5
))));
EXPECT_THAT
(
t
,
Args
<
1
>
(
Eq
(
make_tuple
(
true
))));
EXPECT_THAT
(
t
,
Not
(
Args
<
1
>
(
Eq
(
make_tuple
(
false
)))));
}
TEST
(
ArgsTest
,
AcceptsTwoTemplateArgs
)
{
const
tuple
<
short
,
int
,
long
>
t
(
4
,
5
,
6L
);
// NOLINT
EXPECT_THAT
(
t
,
(
Args
<
0
,
1
>
(
Lt
())));
EXPECT_THAT
(
t
,
(
Args
<
1
,
2
>
(
Lt
())));
EXPECT_THAT
(
t
,
Not
(
Args
<
0
,
2
>
(
Gt
())));
}
TEST
(
ArgsTest
,
AcceptsRepeatedTemplateArgs
)
{
const
tuple
<
short
,
int
,
long
>
t
(
4
,
5
,
6L
);
// NOLINT
EXPECT_THAT
(
t
,
(
Args
<
0
,
0
>
(
Eq
())));
EXPECT_THAT
(
t
,
Not
(
Args
<
1
,
1
>
(
Ne
())));
}
TEST
(
ArgsTest
,
AcceptsDecreasingTemplateArgs
)
{
const
tuple
<
short
,
int
,
long
>
t
(
4
,
5
,
6L
);
// NOLINT
EXPECT_THAT
(
t
,
(
Args
<
2
,
0
>
(
Gt
())));
EXPECT_THAT
(
t
,
Not
(
Args
<
2
,
1
>
(
Lt
())));
}
MATCHER
(
SumIsZero
,
""
)
{
return
get
<
0
>
(
arg
)
+
get
<
1
>
(
arg
)
+
get
<
2
>
(
arg
)
==
0
;
}
TEST
(
ArgsTest
,
AcceptsMoreTemplateArgsThanArityOfOriginalTuple
)
{
EXPECT_THAT
(
make_tuple
(
-
1
,
2
),
(
Args
<
0
,
0
,
1
>
(
SumIsZero
())));
EXPECT_THAT
(
make_tuple
(
1
,
2
),
Not
(
Args
<
0
,
0
,
1
>
(
SumIsZero
())));
}
TEST
(
ArgsTest
,
CanBeNested
)
{
const
tuple
<
short
,
int
,
long
,
int
>
t
(
4
,
5
,
6L
,
6
);
// NOLINT
EXPECT_THAT
(
t
,
(
Args
<
1
,
2
,
3
>
(
Args
<
1
,
2
>
(
Eq
()))));
EXPECT_THAT
(
t
,
(
Args
<
0
,
1
,
3
>
(
Args
<
0
,
2
>
(
Lt
()))));
}
TEST
(
ArgsTest
,
CanMatchTupleByValue
)
{
typedef
tuple
<
char
,
int
,
int
>
Tuple3
;
const
Matcher
<
Tuple3
>
m
=
Args
<
1
,
2
>
(
Lt
());
EXPECT_TRUE
(
m
.
Matches
(
Tuple3
(
'a'
,
1
,
2
)));
EXPECT_FALSE
(
m
.
Matches
(
Tuple3
(
'b'
,
2
,
2
)));
}
TEST
(
ArgsTest
,
CanMatchTupleByReference
)
{
typedef
tuple
<
char
,
char
,
int
>
Tuple3
;
const
Matcher
<
const
Tuple3
&>
m
=
Args
<
0
,
1
>
(
Lt
());
EXPECT_TRUE
(
m
.
Matches
(
Tuple3
(
'a'
,
'b'
,
2
)));
EXPECT_FALSE
(
m
.
Matches
(
Tuple3
(
'b'
,
'b'
,
2
)));
}
// Validates that arg is printed as str.
MATCHER_P
(
PrintsAs
,
str
,
""
)
{
typedef
GMOCK_REMOVE_CONST_
(
GMOCK_REMOVE_REFERENCE_
(
arg_type
))
RawTuple
;
return
testing
::
internal
::
UniversalPrinter
<
RawTuple
>::
PrintToString
(
arg
)
==
str
;
}
TEST
(
ArgsTest
,
AcceptsTenTemplateArgs
)
{
EXPECT_THAT
(
make_tuple
(
0
,
1L
,
2
,
3L
,
4
,
5
,
6
,
7
,
8
,
9
),
(
Args
<
9
,
8
,
7
,
6
,
5
,
4
,
3
,
2
,
1
,
0
>
(
PrintsAs
(
"(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)"
))));
EXPECT_THAT
(
make_tuple
(
0
,
1L
,
2
,
3L
,
4
,
5
,
6
,
7
,
8
,
9
),
Not
(
Args
<
9
,
8
,
7
,
6
,
5
,
4
,
3
,
2
,
1
,
0
>
(
PrintsAs
(
"(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)"
))));
}
TEST
(
ArgsTest
,
DescirbesSelfCorrectly
)
{
const
Matcher
<
tuple
<
int
,
bool
,
char
>
>
m
=
Args
<
2
,
0
>
(
Lt
());
EXPECT_EQ
(
"are a tuple whose fields (#2, #0) are a pair (x, y) where x < y"
,
Describe
(
m
));
}
TEST
(
ArgsTest
,
DescirbesNestedArgsCorrectly
)
{
const
Matcher
<
const
tuple
<
int
,
bool
,
char
,
int
>&>
m
=
Args
<
0
,
2
,
3
>
(
Args
<
2
,
0
>
(
Lt
()));
EXPECT_EQ
(
"are a tuple whose fields (#0, #2, #3) are a tuple "
"whose fields (#2, #0) are a pair (x, y) where x < y"
,
Describe
(
m
));
}
TEST
(
ArgsTest
,
DescribesNegationCorrectly
)
{
const
Matcher
<
tuple
<
int
,
char
>
>
m
=
Args
<
1
,
0
>
(
Gt
());
EXPECT_EQ
(
"are a tuple whose fields (#1, #0) are a pair (x, y) "
"where x > y is false"
,
DescribeNegation
(
m
));
}
// For testing ExplainMatchResultTo().
// For testing ExplainMatchResultTo().
class
GreaterThanMatcher
:
public
MatcherInterface
<
int
>
{
class
GreaterThanMatcher
:
public
MatcherInterface
<
int
>
{
public
:
public
:
...
@@ -926,8 +1030,9 @@ TEST(ContainsTest, AcceptsMatcher) {
...
@@ -926,8 +1030,9 @@ TEST(ContainsTest, AcceptsMatcher) {
TEST
(
ContainsTest
,
WorksForNativeArrayAsTuple
)
{
TEST
(
ContainsTest
,
WorksForNativeArrayAsTuple
)
{
const
int
a
[]
=
{
1
,
2
};
const
int
a
[]
=
{
1
,
2
};
EXPECT_THAT
(
make_tuple
(
a
,
2
),
Contains
(
1
));
const
int
*
const
pointer
=
a
;
EXPECT_THAT
(
make_tuple
(
a
,
2
),
Not
(
Contains
(
Gt
(
3
))));
EXPECT_THAT
(
make_tuple
(
pointer
,
2
),
Contains
(
1
));
EXPECT_THAT
(
make_tuple
(
pointer
,
2
),
Not
(
Contains
(
Gt
(
3
))));
}
}
TEST
(
ContainsTest
,
WorksForTwoDimensionalNativeArray
)
{
TEST
(
ContainsTest
,
WorksForTwoDimensionalNativeArray
)
{
...
...
test/gmock-internal-utils_test.cc
View file @
2661c682
...
@@ -941,7 +941,7 @@ TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
...
@@ -941,7 +941,7 @@ TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
EXPECT_EQ
(
a1
,
a2
.
begin
());
EXPECT_EQ
(
a1
,
a2
.
begin
());
const
NativeArray
<
int
>
a3
=
StlContainerView
<
tuple
<
int
*
,
size_t
>
>::
const
NativeArray
<
int
>
a3
=
StlContainerView
<
tuple
<
int
*
,
size_t
>
>::
Copy
(
make_tuple
(
a1
,
3
));
Copy
(
make_tuple
(
static_cast
<
int
*>
(
a1
)
,
3
));
ASSERT_EQ
(
3
,
a3
.
size
());
ASSERT_EQ
(
3
,
a3
.
size
());
EXPECT_EQ
(
0
,
a3
.
begin
()[
0
]);
EXPECT_EQ
(
0
,
a3
.
begin
()[
0
]);
EXPECT_EQ
(
1
,
a3
.
begin
()[
1
]);
EXPECT_EQ
(
1
,
a3
.
begin
()[
1
]);
...
...
test/gmock-matchers_test.cc
View file @
2661c682
...
@@ -1335,7 +1335,7 @@ TEST(Eq2Test, MatchesEqualArguments) {
...
@@ -1335,7 +1335,7 @@ TEST(Eq2Test, MatchesEqualArguments) {
// Tests that Eq() describes itself properly.
// Tests that Eq() describes itself properly.
TEST
(
Eq2Test
,
CanDescribeSelf
)
{
TEST
(
Eq2Test
,
CanDescribeSelf
)
{
Matcher
<
const
Tuple2
&>
m
=
Eq
();
Matcher
<
const
Tuple2
&>
m
=
Eq
();
EXPECT_EQ
(
"ar
gument #0 is equal to argument #1
"
,
Describe
(
m
));
EXPECT_EQ
(
"ar
e a pair (x, y) where x == y
"
,
Describe
(
m
));
}
}
// Tests that Ge() matches a 2-tuple where the first field >= the
// Tests that Ge() matches a 2-tuple where the first field >= the
...
@@ -1350,8 +1350,7 @@ TEST(Ge2Test, MatchesGreaterThanOrEqualArguments) {
...
@@ -1350,8 +1350,7 @@ TEST(Ge2Test, MatchesGreaterThanOrEqualArguments) {
// Tests that Ge() describes itself properly.
// Tests that Ge() describes itself properly.
TEST
(
Ge2Test
,
CanDescribeSelf
)
{
TEST
(
Ge2Test
,
CanDescribeSelf
)
{
Matcher
<
const
Tuple2
&>
m
=
Ge
();
Matcher
<
const
Tuple2
&>
m
=
Ge
();
EXPECT_EQ
(
"argument #0 is greater than or equal to argument #1"
,
EXPECT_EQ
(
"are a pair (x, y) where x >= y"
,
Describe
(
m
));
Describe
(
m
));
}
}
// Tests that Gt() matches a 2-tuple where the first field > the
// Tests that Gt() matches a 2-tuple where the first field > the
...
@@ -1366,7 +1365,7 @@ TEST(Gt2Test, MatchesGreaterThanArguments) {
...
@@ -1366,7 +1365,7 @@ TEST(Gt2Test, MatchesGreaterThanArguments) {
// Tests that Gt() describes itself properly.
// Tests that Gt() describes itself properly.
TEST
(
Gt2Test
,
CanDescribeSelf
)
{
TEST
(
Gt2Test
,
CanDescribeSelf
)
{
Matcher
<
const
Tuple2
&>
m
=
Gt
();
Matcher
<
const
Tuple2
&>
m
=
Gt
();
EXPECT_EQ
(
"ar
gument #0 is greater than argument #1
"
,
Describe
(
m
));
EXPECT_EQ
(
"ar
e a pair (x, y) where x > y
"
,
Describe
(
m
));
}
}
// Tests that Le() matches a 2-tuple where the first field <= the
// Tests that Le() matches a 2-tuple where the first field <= the
...
@@ -1381,8 +1380,7 @@ TEST(Le2Test, MatchesLessThanOrEqualArguments) {
...
@@ -1381,8 +1380,7 @@ TEST(Le2Test, MatchesLessThanOrEqualArguments) {
// Tests that Le() describes itself properly.
// Tests that Le() describes itself properly.
TEST
(
Le2Test
,
CanDescribeSelf
)
{
TEST
(
Le2Test
,
CanDescribeSelf
)
{
Matcher
<
const
Tuple2
&>
m
=
Le
();
Matcher
<
const
Tuple2
&>
m
=
Le
();
EXPECT_EQ
(
"argument #0 is less than or equal to argument #1"
,
EXPECT_EQ
(
"are a pair (x, y) where x <= y"
,
Describe
(
m
));
Describe
(
m
));
}
}
// Tests that Lt() matches a 2-tuple where the first field < the
// Tests that Lt() matches a 2-tuple where the first field < the
...
@@ -1397,7 +1395,7 @@ TEST(Lt2Test, MatchesLessThanArguments) {
...
@@ -1397,7 +1395,7 @@ TEST(Lt2Test, MatchesLessThanArguments) {
// Tests that Lt() describes itself properly.
// Tests that Lt() describes itself properly.
TEST
(
Lt2Test
,
CanDescribeSelf
)
{
TEST
(
Lt2Test
,
CanDescribeSelf
)
{
Matcher
<
const
Tuple2
&>
m
=
Lt
();
Matcher
<
const
Tuple2
&>
m
=
Lt
();
EXPECT_EQ
(
"ar
gument #0 is less than argument #1
"
,
Describe
(
m
));
EXPECT_EQ
(
"ar
e a pair (x, y) where x < y
"
,
Describe
(
m
));
}
}
// Tests that Ne() matches a 2-tuple where the first field != the
// Tests that Ne() matches a 2-tuple where the first field != the
...
@@ -1412,7 +1410,7 @@ TEST(Ne2Test, MatchesUnequalArguments) {
...
@@ -1412,7 +1410,7 @@ TEST(Ne2Test, MatchesUnequalArguments) {
// Tests that Ne() describes itself properly.
// Tests that Ne() describes itself properly.
TEST
(
Ne2Test
,
CanDescribeSelf
)
{
TEST
(
Ne2Test
,
CanDescribeSelf
)
{
Matcher
<
const
Tuple2
&>
m
=
Ne
();
Matcher
<
const
Tuple2
&>
m
=
Ne
();
EXPECT_EQ
(
"ar
gument #0 is not equal to argument #1
"
,
Describe
(
m
));
EXPECT_EQ
(
"ar
e a pair (x, y) where x != y
"
,
Describe
(
m
));
}
}
// Tests that Not(m) matches any value that doesn't match m.
// Tests that Not(m) matches any value that doesn't match m.
...
@@ -2948,11 +2946,12 @@ TEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) {
...
@@ -2948,11 +2946,12 @@ TEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) {
const
int
a2
[]
=
{
1
,
2
,
3
};
const
int
a2
[]
=
{
1
,
2
,
3
};
const
int
b
[]
=
{
1
,
2
,
3
,
4
};
const
int
b
[]
=
{
1
,
2
,
3
,
4
};
EXPECT_THAT
(
make_tuple
(
a1
,
3
),
ContainerEq
(
a2
));
const
int
*
const
p1
=
a1
;
EXPECT_THAT
(
make_tuple
(
a1
,
3
),
Not
(
ContainerEq
(
b
)));
EXPECT_THAT
(
make_tuple
(
p1
,
3
),
ContainerEq
(
a2
));
EXPECT_THAT
(
make_tuple
(
p1
,
3
),
Not
(
ContainerEq
(
b
)));
const
int
c
[]
=
{
1
,
3
,
2
};
const
int
c
[]
=
{
1
,
3
,
2
};
EXPECT_THAT
(
make_tuple
(
a
1
,
3
),
Not
(
ContainerEq
(
c
)));
EXPECT_THAT
(
make_tuple
(
p
1
,
3
),
Not
(
ContainerEq
(
c
)));
}
}
TEST
(
ContainerEqExtraTest
,
CopiesNativeArrayParameter
)
{
TEST
(
ContainerEqExtraTest
,
CopiesNativeArrayParameter
)
{
...
...
test/gmock_output_test_golden.txt
View file @
2661c682
...
@@ -183,8 +183,8 @@ Unexpected mock function call - returning default value.
...
@@ -183,8 +183,8 @@ Unexpected mock function call - returning default value.
Google Mock tried the following 1 expectation, but it didn't match:
Google Mock tried the following 1 expectation, but it didn't match:
FILE:#:
FILE:#:
Expected: argument #0 is greater than or equal to argument #1
Expected args: are a pair (x, y) where x >= y
Actual:
false
Actual:
don't match
Expected: to be called once
Expected: to be called once
Actual: never called - unsatisfied and active
Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.MismatchWithArguments
[ FAILED ] GMockOutputTest.MismatchWithArguments
...
@@ -199,8 +199,8 @@ Google Mock tried the following 1 expectation, but it didn't match:
...
@@ -199,8 +199,8 @@ Google Mock tried the following 1 expectation, but it didn't match:
FILE:#:
FILE:#:
Expected arg #0: is greater than or equal to 2
Expected arg #0: is greater than or equal to 2
Actual: 1
Actual: 1
Expected: argument #0 is greater than or equal to argument #1
Expected args: are a pair (x, y) where x >= y
Actual:
false
Actual:
don't match
Expected: to be called once
Expected: to be called once
Actual: never called - unsatisfied and active
Actual: never called - unsatisfied and active
[ FAILED ] GMockOutputTest.MismatchArgumentsAndWithArguments
[ FAILED ] GMockOutputTest.MismatchArgumentsAndWithArguments
...
...
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