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
4f660912
Commit
4f660912
authored
Feb 03, 2020
by
Abseil Team
Committed by
Andy Getz
Feb 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
Fix std::move to std::forward where appropriate to support reference types. PiperOrigin-RevId: 292923058
parent
74b44b2d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
34 deletions
+68
-34
gmock-generated-matchers.h
googlemock/include/gmock/gmock-generated-matchers.h
+55
-30
gmock-generated-matchers.h.pump
googlemock/include/gmock/gmock-generated-matchers.h.pump
+1
-1
gmock-matchers.h
googlemock/include/gmock/gmock-matchers.h
+4
-2
gmock-generated-matchers_test.cc
googlemock/test/gmock-generated-matchers_test.cc
+8
-1
No files found.
googlemock/include/gmock/gmock-generated-matchers.h
View file @
4f660912
...
@@ -100,7 +100,7 @@
...
@@ -100,7 +100,7 @@
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
public:\
public:\
explicit gmock_Impl(p0##_type gmock_p0)\
explicit gmock_Impl(p0##_type gmock_p0)\
: p0(::std::
move
(gmock_p0)) {}\
: p0(::std::
forward<p0##_type>
(gmock_p0)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -147,7 +147,8 @@
...
@@ -147,7 +147,8 @@
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)) {}\
: p0(::std::forward<p0##_type>(gmock_p0)), \
p1(::std::forward<p1##_type>(gmock_p1)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -197,8 +198,9 @@
...
@@ -197,8 +198,9 @@
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
GTEST_REFERENCE_TO_CONST_(arg_type)> {\
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
: p0(::std::forward<p0##_type>(gmock_p0)), \
p2(::std::move(gmock_p2)) {}\
p1(::std::forward<p1##_type>(gmock_p1)), \
p2(::std::forward<p2##_type>(gmock_p2)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -251,8 +253,10 @@
...
@@ -251,8 +253,10 @@
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3)\
p3##_type gmock_p3)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
: p0(::std::forward<p0##_type>(gmock_p0)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)) {}\
p1(::std::forward<p1##_type>(gmock_p1)), \
p2(::std::forward<p2##_type>(gmock_p2)), \
p3(::std::forward<p3##_type>(gmock_p3)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -311,9 +315,11 @@
...
@@ -311,9 +315,11 @@
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4)\
p3##_type gmock_p3, p4##_type gmock_p4)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
: p0(::std::forward<p0##_type>(gmock_p0)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p1(::std::forward<p1##_type>(gmock_p1)), \
p4(::std::move(gmock_p4)) {}\
p2(::std::forward<p2##_type>(gmock_p2)), \
p3(::std::forward<p3##_type>(gmock_p3)), \
p4(::std::forward<p4##_type>(gmock_p4)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -373,9 +379,12 @@
...
@@ -373,9 +379,12 @@
public:\
public:\
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
: p0(::std::forward<p0##_type>(gmock_p0)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p1(::std::forward<p1##_type>(gmock_p1)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)) {}\
p2(::std::forward<p2##_type>(gmock_p2)), \
p3(::std::forward<p3##_type>(gmock_p3)), \
p4(::std::forward<p4##_type>(gmock_p4)), \
p5(::std::forward<p5##_type>(gmock_p5)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -439,10 +448,13 @@
...
@@ -439,10 +448,13 @@
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6)\
p6##_type gmock_p6)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
: p0(::std::forward<p0##_type>(gmock_p0)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p1(::std::forward<p1##_type>(gmock_p1)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p2(::std::forward<p2##_type>(gmock_p2)), \
p6(::std::move(gmock_p6)) {}\
p3(::std::forward<p3##_type>(gmock_p3)), \
p4(::std::forward<p4##_type>(gmock_p4)), \
p5(::std::forward<p5##_type>(gmock_p5)), \
p6(::std::forward<p6##_type>(gmock_p6)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -512,10 +524,14 @@
...
@@ -512,10 +524,14 @@
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7)\
p6##_type gmock_p6, p7##_type gmock_p7)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
: p0(::std::forward<p0##_type>(gmock_p0)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p1(::std::forward<p1##_type>(gmock_p1)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p2(::std::forward<p2##_type>(gmock_p2)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)) {}\
p3(::std::forward<p3##_type>(gmock_p3)), \
p4(::std::forward<p4##_type>(gmock_p4)), \
p5(::std::forward<p5##_type>(gmock_p5)), \
p6(::std::forward<p6##_type>(gmock_p6)), \
p7(::std::forward<p7##_type>(gmock_p7)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -588,11 +604,15 @@
...
@@ -588,11 +604,15 @@
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
: p0(::std::forward<p0##_type>(gmock_p0)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p1(::std::forward<p1##_type>(gmock_p1)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p2(::std::forward<p2##_type>(gmock_p2)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)), \
p3(::std::forward<p3##_type>(gmock_p3)), \
p8(::std::move(gmock_p8)) {}\
p4(::std::forward<p4##_type>(gmock_p4)), \
p5(::std::forward<p5##_type>(gmock_p5)), \
p6(::std::forward<p6##_type>(gmock_p6)), \
p7(::std::forward<p7##_type>(gmock_p7)), \
p8(::std::forward<p8##_type>(gmock_p8)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
@@ -669,11 +689,16 @@
...
@@ -669,11 +689,16 @@
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
p9##_type gmock_p9)\
p9##_type gmock_p9)\
: p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1)), \
: p0(::std::forward<p0##_type>(gmock_p0)), \
p2(::std::move(gmock_p2)), p3(::std::move(gmock_p3)), \
p1(::std::forward<p1##_type>(gmock_p1)), \
p4(::std::move(gmock_p4)), p5(::std::move(gmock_p5)), \
p2(::std::forward<p2##_type>(gmock_p2)), \
p6(::std::move(gmock_p6)), p7(::std::move(gmock_p7)), \
p3(::std::forward<p3##_type>(gmock_p3)), \
p8(::std::move(gmock_p8)), p9(::std::move(gmock_p9)) {}\
p4(::std::forward<p4##_type>(gmock_p4)), \
p5(::std::forward<p5##_type>(gmock_p5)), \
p6(::std::forward<p6##_type>(gmock_p6)), \
p7(::std::forward<p7##_type>(gmock_p7)), \
p8(::std::forward<p8##_type>(gmock_p8)), \
p9(::std::forward<p9##_type>(gmock_p9)) {}\
bool MatchAndExplain(\
bool MatchAndExplain(\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
GTEST_REFERENCE_TO_CONST_(arg_type) arg,\
::testing::MatchResultListener* result_listener) const override;\
::testing::MatchResultListener* result_listener) const override;\
...
...
googlemock/include/gmock/gmock-generated-matchers.h.pump
View file @
4f660912
...
@@ -63,7 +63,7 @@ $var template = [[$if i==0 [[]] $else [[
...
@@ -63,7 +63,7 @@ $var template = [[$if i==0 [[]] $else [[
template
<
$
for
j
,
[[
typename
p
$
j
##
_type
]]
>
\
template
<
$
for
j
,
[[
typename
p
$
j
##
_type
]]
>
\
]]]]
]]]]
$
var
impl_ctor_param_list
=
[[
$
for
j
,
[[
p
$
j
##
_type
gmock_p
$
j
]]]]
$
var
impl_ctor_param_list
=
[[
$
for
j
,
[[
p
$
j
##
_type
gmock_p
$
j
]]]]
$
var
impl_inits
=
[[
$
if
i
==
0
[[]]
$
else
[[
:
$
for
j
,
[[
p
$
j
(
::
std
::
move
(
gmock_p
$
j
))]]]]]]
$
var
impl_inits
=
[[
$
if
i
==
0
[[]]
$
else
[[
:
$
for
j
,
[[
p
$
j
(
::
std
::
forward
<
p
$
j
##
_type
>
(
gmock_p
$
j
))]]]]]]
$
var
params
=
[[
$
for
j
,
[[
p
$
j
]]]]
$
var
params
=
[[
$
for
j
,
[[
p
$
j
]]]]
$
var
param_types
=
[[
$
if
i
==
0
[[]]
$
else
[[
<
$
for
j
,
[[
p
$
j
##
_type
]]
>
]]]]
$
var
param_types
=
[[
$
if
i
==
0
[[]]
$
else
[[
<
$
for
j
,
[[
p
$
j
##
_type
]]
>
]]]]
$
var
param_types_and_names
=
[[
$
for
j
,
[[
p
$
j
##
_type
p
$
j
]]]]
$
var
param_types_and_names
=
[[
$
for
j
,
[[
p
$
j
##
_type
p
$
j
]]]]
...
...
googlemock/include/gmock/gmock-matchers.h
View file @
4f660912
...
@@ -470,10 +470,12 @@ class MatcherBaseImpl<Derived<Ts...>> {
...
@@ -470,10 +470,12 @@ class MatcherBaseImpl<Derived<Ts...>> {
// conversions.
// conversions.
template
<
typename
E
=
std
::
enable_if
<
sizeof
...(
Ts
)
==
1
>
,
template
<
typename
E
=
std
::
enable_if
<
sizeof
...(
Ts
)
==
1
>
,
typename
E
::
type
*
=
nullptr
>
typename
E
::
type
*
=
nullptr
>
explicit
MatcherBaseImpl
(
Ts
...
params
)
:
params_
(
std
::
move
(
params
)...)
{}
explicit
MatcherBaseImpl
(
Ts
...
params
)
:
params_
(
std
::
forward
<
Ts
>
(
params
)...)
{}
template
<
typename
E
=
std
::
enable_if
<
sizeof
...(
Ts
)
!=
1
>
,
template
<
typename
E
=
std
::
enable_if
<
sizeof
...(
Ts
)
!=
1
>
,
typename
=
typename
E
::
type
>
typename
=
typename
E
::
type
>
MatcherBaseImpl
(
Ts
...
params
)
:
params_
(
std
::
move
(
params
)...)
{}
// NOLINT
MatcherBaseImpl
(
Ts
...
params
)
// NOLINT
:
params_
(
std
::
forward
<
Ts
>
(
params
)...)
{}
template
<
typename
F
>
template
<
typename
F
>
operator
::
testing
::
Matcher
<
F
>
()
const
{
// NOLINT(runtime/explicit)
operator
::
testing
::
Matcher
<
F
>
()
const
{
// NOLINT(runtime/explicit)
...
...
googlemock/test/gmock-generated-matchers_test.cc
View file @
4f660912
...
@@ -764,9 +764,16 @@ MATCHER_P2(ReferencesAnyOf, variable1, variable2, "") {
...
@@ -764,9 +764,16 @@ MATCHER_P2(ReferencesAnyOf, variable1, variable2, "") {
TEST
(
MatcherPnMacroTest
,
WorksWhenExplicitlyInstantiatedWithReferences
)
{
TEST
(
MatcherPnMacroTest
,
WorksWhenExplicitlyInstantiatedWithReferences
)
{
UncopyableFoo
foo1
(
'1'
),
foo2
(
'2'
),
foo3
(
'3'
);
UncopyableFoo
foo1
(
'1'
),
foo2
(
'2'
),
foo3
(
'3'
);
const
Matcher
<
const
UncopyableFoo
&>
m
=
const
Matcher
<
const
UncopyableFoo
&>
const_
m
=
ReferencesAnyOf
<
const
UncopyableFoo
&
,
const
UncopyableFoo
&>
(
foo1
,
foo2
);
ReferencesAnyOf
<
const
UncopyableFoo
&
,
const
UncopyableFoo
&>
(
foo1
,
foo2
);
EXPECT_TRUE
(
const_m
.
Matches
(
foo1
));
EXPECT_TRUE
(
const_m
.
Matches
(
foo2
));
EXPECT_FALSE
(
const_m
.
Matches
(
foo3
));
const
Matcher
<
UncopyableFoo
&>
m
=
ReferencesAnyOf
<
UncopyableFoo
&
,
UncopyableFoo
&>
(
foo1
,
foo2
);
EXPECT_TRUE
(
m
.
Matches
(
foo1
));
EXPECT_TRUE
(
m
.
Matches
(
foo1
));
EXPECT_TRUE
(
m
.
Matches
(
foo2
));
EXPECT_TRUE
(
m
.
Matches
(
foo2
));
EXPECT_FALSE
(
m
.
Matches
(
foo3
));
EXPECT_FALSE
(
m
.
Matches
(
foo3
));
...
...
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