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
a6e32f0a
Commit
a6e32f0a
authored
Jul 24, 2015
by
kosak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly specify return value for lambda in AsStdFunction() to ensure it
works properly where return type is a reference.
parent
f6df4c6b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
12 deletions
+22
-12
gmock-generated-function-mockers.h
include/gmock/gmock-generated-function-mockers.h
+11
-11
gmock-generated-function-mockers.h.pump
include/gmock/gmock-generated-function-mockers.h.pump
+1
-1
gmock-generated-function-mockers_test.cc
test/gmock-generated-function-mockers_test.cc
+10
-0
No files found.
include/gmock/gmock-generated-function-mockers.h
View file @
a6e32f0a
...
...
@@ -881,7 +881,7 @@ class MockFunction<R()> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
()
>
AsStdFunction
()
{
return
[
this
]()
{
return
[
this
]()
->
R
{
return
this
->
Call
();
};
}
...
...
@@ -900,7 +900,7 @@ class MockFunction<R(A0)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
)
{
return
[
this
](
A0
a0
)
->
R
{
return
this
->
Call
(
a0
);
};
}
...
...
@@ -919,7 +919,7 @@ class MockFunction<R(A0, A1)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
)
{
return
[
this
](
A0
a0
,
A1
a1
)
->
R
{
return
this
->
Call
(
a0
,
a1
);
};
}
...
...
@@ -938,7 +938,7 @@ class MockFunction<R(A0, A1, A2)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
,
A2
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
)
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
)
->
R
{
return
this
->
Call
(
a0
,
a1
,
a2
);
};
}
...
...
@@ -957,7 +957,7 @@ class MockFunction<R(A0, A1, A2, A3)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
)
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
)
->
R
{
return
this
->
Call
(
a0
,
a1
,
a2
,
a3
);
};
}
...
...
@@ -977,7 +977,7 @@ class MockFunction<R(A0, A1, A2, A3, A4)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
)
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
)
->
R
{
return
this
->
Call
(
a0
,
a1
,
a2
,
a3
,
a4
);
};
}
...
...
@@ -997,7 +997,7 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
)
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
)
->
R
{
return
this
->
Call
(
a0
,
a1
,
a2
,
a3
,
a4
,
a5
);
};
}
...
...
@@ -1017,7 +1017,7 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
)
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
)
->
R
{
return
this
->
Call
(
a0
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
);
};
}
...
...
@@ -1037,7 +1037,7 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
)
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
)
->
R
{
return
this
->
Call
(
a0
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
);
};
}
...
...
@@ -1058,7 +1058,7 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
,
A8
a8
)
{
A8
a8
)
->
R
{
return
this
->
Call
(
a0
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
);
};
}
...
...
@@ -1080,7 +1080,7 @@ class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
A0
,
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
>
AsStdFunction
()
{
return
[
this
](
A0
a0
,
A1
a1
,
A2
a2
,
A3
a3
,
A4
a4
,
A5
a5
,
A6
a6
,
A7
a7
,
A8
a8
,
A9
a9
)
{
A8
a8
,
A9
a9
)
->
R
{
return
this
->
Call
(
a0
,
a1
,
a2
,
a3
,
a4
,
a5
,
a6
,
a7
,
a8
,
a9
);
};
}
...
...
include/gmock/gmock-generated-function-mockers.h.pump
View file @
a6e32f0a
...
...
@@ -274,7 +274,7 @@ class MockFunction<R($ArgTypes)> {
#if GTEST_HAS_STD_FUNCTION_
std
::
function
<
R
(
$
ArgTypes
)
>
AsStdFunction
()
{
return
[
this
](
$
ArgDecls
)
{
return
[
this
](
$
ArgDecls
)
->
R
{
return
this
->
Call
(
$
ArgNames
);
};
}
...
...
test/gmock-generated-function-mockers_test.cc
View file @
a6e32f0a
...
...
@@ -606,6 +606,16 @@ TEST(MockFunctionTest, AsStdFunction) {
EXPECT_EQ
(
-
1
,
call
(
foo
.
AsStdFunction
(),
1
));
EXPECT_EQ
(
-
2
,
call
(
foo
.
AsStdFunction
(),
2
));
}
TEST
(
MockFunctionTest
,
AsStdFunctionReturnsReference
)
{
MockFunction
<
int
&
()
>
foo
;
int
value
=
1
;
EXPECT_CALL
(
foo
,
Call
()).
WillOnce
(
ReturnRef
(
value
));
int
&
ref
=
foo
.
AsStdFunction
()();
EXPECT_EQ
(
1
,
ref
);
value
=
2
;
EXPECT_EQ
(
2
,
ref
);
}
#endif // GTEST_HAS_STD_FUNCTION_
}
// namespace gmock_generated_function_mockers_test
...
...
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