Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
59214836
Commit
59214836
authored
Oct 05, 2010
by
zhanyong.wan
Browse files
Adds SetArgPointee to replace SetArgumentPointee.
parent
662d8a23
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
182 additions
and
53 deletions
+182
-53
include/gmock/gmock-actions.h
include/gmock/gmock-actions.h
+9
-0
scripts/gmock_doctor.py
scripts/gmock_doctor.py
+1
-0
test/gmock-actions_test.cc
test/gmock-actions_test.cc
+120
-0
test/gmock-generated-actions_test.cc
test/gmock-generated-actions_test.cc
+46
-46
test/gmock-more-actions_test.cc
test/gmock-more-actions_test.cc
+0
-1
test/gmock_link_test.h
test/gmock_link_test.h
+6
-6
No files found.
include/gmock/gmock-actions.h
View file @
59214836
...
@@ -1013,6 +1013,15 @@ inline internal::DoDefaultAction DoDefault() {
...
@@ -1013,6 +1013,15 @@ inline internal::DoDefaultAction DoDefault() {
// Creates an action that sets the variable pointed by the N-th
// Creates an action that sets the variable pointed by the N-th
// (0-based) function argument to 'value'.
// (0-based) function argument to 'value'.
template
<
size_t
N
,
typename
T
>
template
<
size_t
N
,
typename
T
>
PolymorphicAction
<
internal
::
SetArgumentPointeeAction
<
N
,
T
,
internal
::
IsAProtocolMessage
<
T
>::
value
>
>
SetArgPointee
(
const
T
&
x
)
{
return
MakePolymorphicAction
(
internal
::
SetArgumentPointeeAction
<
N
,
T
,
internal
::
IsAProtocolMessage
<
T
>::
value
>
(
x
));
}
// The following version is DEPRECATED.
template
<
size_t
N
,
typename
T
>
PolymorphicAction
<
PolymorphicAction
<
internal
::
SetArgumentPointeeAction
<
internal
::
SetArgumentPointeeAction
<
N
,
T
,
internal
::
IsAProtocolMessage
<
T
>::
value
>
>
N
,
T
,
internal
::
IsAProtocolMessage
<
T
>::
value
>
>
...
...
scripts/gmock_doctor.py
View file @
59214836
...
@@ -102,6 +102,7 @@ _COMMON_GMOCK_SYMBOLS = [
...
@@ -102,6 +102,7 @@ _COMMON_GMOCK_SYMBOLS = [
'ReturnRef'
,
'ReturnRef'
,
'SaveArg'
,
'SaveArg'
,
'SetArgReferee'
,
'SetArgReferee'
,
'SetArgPointee'
,
'SetArgumentPointee'
,
'SetArgumentPointee'
,
'SetArrayArgument'
,
'SetArrayArgument'
,
'SetErrnoAndReturn'
,
'SetErrnoAndReturn'
,
...
...
test/gmock-actions_test.cc
View file @
59214836
...
@@ -69,6 +69,7 @@ using testing::Return;
...
@@ -69,6 +69,7 @@ using testing::Return;
using
testing
::
ReturnNull
;
using
testing
::
ReturnNull
;
using
testing
::
ReturnRef
;
using
testing
::
ReturnRef
;
using
testing
::
ReturnRefOfCopy
;
using
testing
::
ReturnRefOfCopy
;
using
testing
::
SetArgPointee
;
using
testing
::
SetArgumentPointee
;
using
testing
::
SetArgumentPointee
;
#if !GTEST_OS_WINDOWS_MOBILE
#if !GTEST_OS_WINDOWS_MOBILE
...
@@ -694,6 +695,125 @@ TEST(DoDefaultTest, CannotBeUsedInOnCall) {
...
@@ -694,6 +695,125 @@ TEST(DoDefaultTest, CannotBeUsedInOnCall) {
},
"DoDefault() cannot be used in ON_CALL()"
);
},
"DoDefault() cannot be used in ON_CALL()"
);
}
}
// Tests that SetArgPointee<N>(v) sets the variable pointed to by
// the N-th (0-based) argument to v.
TEST
(
SetArgPointeeTest
,
SetsTheNthPointee
)
{
typedef
void
MyFunction
(
bool
,
int
*
,
char
*
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
1
>
(
2
);
int
n
=
0
;
char
ch
=
'\0'
;
a
.
Perform
(
make_tuple
(
true
,
&
n
,
&
ch
));
EXPECT_EQ
(
2
,
n
);
EXPECT_EQ
(
'\0'
,
ch
);
a
=
SetArgPointee
<
2
>
(
'a'
);
n
=
0
;
ch
=
'\0'
;
a
.
Perform
(
make_tuple
(
true
,
&
n
,
&
ch
));
EXPECT_EQ
(
0
,
n
);
EXPECT_EQ
(
'a'
,
ch
);
}
#if GTEST_HAS_PROTOBUF_
// Tests that SetArgPointee<N>(proto_buffer) sets the v1 protobuf
// variable pointed to by the N-th (0-based) argument to proto_buffer.
TEST
(
SetArgPointeeTest
,
SetsTheNthPointeeOfProtoBufferType
)
{
TestMessage
*
const
msg
=
new
TestMessage
;
msg
->
set_member
(
"yes"
);
TestMessage
orig_msg
;
orig_msg
.
CopyFrom
(
*
msg
);
Action
<
void
(
bool
,
TestMessage
*
)
>
a
=
SetArgPointee
<
1
>
(
*
msg
);
// SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer
// s.t. the action works even when the original proto_buffer has
// died. We ensure this behavior by deleting msg before using the
// action.
delete
msg
;
TestMessage
dest
;
EXPECT_FALSE
(
orig_msg
.
Equals
(
dest
));
a
.
Perform
(
make_tuple
(
true
,
&
dest
));
EXPECT_TRUE
(
orig_msg
.
Equals
(
dest
));
}
// Tests that SetArgPointee<N>(proto_buffer) sets the
// ::ProtocolMessage variable pointed to by the N-th (0-based)
// argument to proto_buffer.
TEST
(
SetArgPointeeTest
,
SetsTheNthPointeeOfProtoBufferBaseType
)
{
TestMessage
*
const
msg
=
new
TestMessage
;
msg
->
set_member
(
"yes"
);
TestMessage
orig_msg
;
orig_msg
.
CopyFrom
(
*
msg
);
Action
<
void
(
bool
,
::
ProtocolMessage
*
)
>
a
=
SetArgPointee
<
1
>
(
*
msg
);
// SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer
// s.t. the action works even when the original proto_buffer has
// died. We ensure this behavior by deleting msg before using the
// action.
delete
msg
;
TestMessage
dest
;
::
ProtocolMessage
*
const
dest_base
=
&
dest
;
EXPECT_FALSE
(
orig_msg
.
Equals
(
dest
));
a
.
Perform
(
make_tuple
(
true
,
dest_base
));
EXPECT_TRUE
(
orig_msg
.
Equals
(
dest
));
}
// Tests that SetArgPointee<N>(proto2_buffer) sets the v2
// protobuf variable pointed to by the N-th (0-based) argument to
// proto2_buffer.
TEST
(
SetArgPointeeTest
,
SetsTheNthPointeeOfProto2BufferType
)
{
using
testing
::
internal
::
FooMessage
;
FooMessage
*
const
msg
=
new
FooMessage
;
msg
->
set_int_field
(
2
);
msg
->
set_string_field
(
"hi"
);
FooMessage
orig_msg
;
orig_msg
.
CopyFrom
(
*
msg
);
Action
<
void
(
bool
,
FooMessage
*
)
>
a
=
SetArgPointee
<
1
>
(
*
msg
);
// SetArgPointee<N>(proto2_buffer) makes a copy of
// proto2_buffer s.t. the action works even when the original
// proto2_buffer has died. We ensure this behavior by deleting msg
// before using the action.
delete
msg
;
FooMessage
dest
;
dest
.
set_int_field
(
0
);
a
.
Perform
(
make_tuple
(
true
,
&
dest
));
EXPECT_EQ
(
2
,
dest
.
int_field
());
EXPECT_EQ
(
"hi"
,
dest
.
string_field
());
}
// Tests that SetArgPointee<N>(proto2_buffer) sets the
// proto2::Message variable pointed to by the N-th (0-based) argument
// to proto2_buffer.
TEST
(
SetArgPointeeTest
,
SetsTheNthPointeeOfProto2BufferBaseType
)
{
using
testing
::
internal
::
FooMessage
;
FooMessage
*
const
msg
=
new
FooMessage
;
msg
->
set_int_field
(
2
);
msg
->
set_string_field
(
"hi"
);
FooMessage
orig_msg
;
orig_msg
.
CopyFrom
(
*
msg
);
Action
<
void
(
bool
,
::
proto2
::
Message
*
)
>
a
=
SetArgPointee
<
1
>
(
*
msg
);
// SetArgPointee<N>(proto2_buffer) makes a copy of
// proto2_buffer s.t. the action works even when the original
// proto2_buffer has died. We ensure this behavior by deleting msg
// before using the action.
delete
msg
;
FooMessage
dest
;
dest
.
set_int_field
(
0
);
::
proto2
::
Message
*
const
dest_base
=
&
dest
;
a
.
Perform
(
make_tuple
(
true
,
dest_base
));
EXPECT_EQ
(
2
,
dest
.
int_field
());
EXPECT_EQ
(
"hi"
,
dest
.
string_field
());
}
#endif // GTEST_HAS_PROTOBUF_
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
// the N-th (0-based) argument to v.
// the N-th (0-based) argument to v.
TEST
(
SetArgumentPointeeTest
,
SetsTheNthPointee
)
{
TEST
(
SetArgumentPointeeTest
,
SetsTheNthPointee
)
{
...
...
test/gmock-generated-actions_test.cc
View file @
59214836
...
@@ -58,7 +58,7 @@ using testing::DoAll;
...
@@ -58,7 +58,7 @@ using testing::DoAll;
using
testing
::
Invoke
;
using
testing
::
Invoke
;
using
testing
::
Return
;
using
testing
::
Return
;
using
testing
::
ReturnNew
;
using
testing
::
ReturnNew
;
using
testing
::
SetArg
ument
Pointee
;
using
testing
::
SetArgPointee
;
using
testing
::
StaticAssertTypeEq
;
using
testing
::
StaticAssertTypeEq
;
using
testing
::
Unused
;
using
testing
::
Unused
;
using
testing
::
WithArgs
;
using
testing
::
WithArgs
;
...
@@ -419,7 +419,7 @@ TEST(WithArgsTest, VoidAction) {
...
@@ -419,7 +419,7 @@ TEST(WithArgsTest, VoidAction) {
// Tests DoAll(a1, a2).
// Tests DoAll(a1, a2).
TEST
(
DoAllTest
,
TwoActions
)
{
TEST
(
DoAllTest
,
TwoActions
)
{
int
n
=
0
;
int
n
=
0
;
Action
<
int
(
int
*
)
>
a
=
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
// NOLINT
Action
<
int
(
int
*
)
>
a
=
DoAll
(
SetArgPointee
<
0
>
(
1
),
// NOLINT
Return
(
2
));
Return
(
2
));
EXPECT_EQ
(
2
,
a
.
Perform
(
make_tuple
(
&
n
)));
EXPECT_EQ
(
2
,
a
.
Perform
(
make_tuple
(
&
n
)));
EXPECT_EQ
(
1
,
n
);
EXPECT_EQ
(
1
,
n
);
...
@@ -428,8 +428,8 @@ TEST(DoAllTest, TwoActions) {
...
@@ -428,8 +428,8 @@ TEST(DoAllTest, TwoActions) {
// Tests DoAll(a1, a2, a3).
// Tests DoAll(a1, a2, a3).
TEST
(
DoAllTest
,
ThreeActions
)
{
TEST
(
DoAllTest
,
ThreeActions
)
{
int
m
=
0
,
n
=
0
;
int
m
=
0
,
n
=
0
;
Action
<
int
(
int
*
,
int
*
)
>
a
=
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
// NOLINT
Action
<
int
(
int
*
,
int
*
)
>
a
=
DoAll
(
SetArgPointee
<
0
>
(
1
),
// NOLINT
SetArg
ument
Pointee
<
1
>
(
2
),
SetArgPointee
<
1
>
(
2
),
Return
(
3
));
Return
(
3
));
EXPECT_EQ
(
3
,
a
.
Perform
(
make_tuple
(
&
m
,
&
n
)));
EXPECT_EQ
(
3
,
a
.
Perform
(
make_tuple
(
&
m
,
&
n
)));
EXPECT_EQ
(
1
,
m
);
EXPECT_EQ
(
1
,
m
);
...
@@ -441,9 +441,9 @@ TEST(DoAllTest, FourActions) {
...
@@ -441,9 +441,9 @@ TEST(DoAllTest, FourActions) {
int
m
=
0
,
n
=
0
;
int
m
=
0
,
n
=
0
;
char
ch
=
'\0'
;
char
ch
=
'\0'
;
Action
<
int
(
int
*
,
int
*
,
char
*
)
>
a
=
// NOLINT
Action
<
int
(
int
*
,
int
*
,
char
*
)
>
a
=
// NOLINT
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
DoAll
(
SetArgPointee
<
0
>
(
1
),
SetArg
ument
Pointee
<
1
>
(
2
),
SetArgPointee
<
1
>
(
2
),
SetArg
ument
Pointee
<
2
>
(
'a'
),
SetArgPointee
<
2
>
(
'a'
),
Return
(
3
));
Return
(
3
));
EXPECT_EQ
(
3
,
a
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
ch
)));
EXPECT_EQ
(
3
,
a
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
ch
)));
EXPECT_EQ
(
1
,
m
);
EXPECT_EQ
(
1
,
m
);
...
@@ -456,10 +456,10 @@ TEST(DoAllTest, FiveActions) {
...
@@ -456,10 +456,10 @@ TEST(DoAllTest, FiveActions) {
int
m
=
0
,
n
=
0
;
int
m
=
0
,
n
=
0
;
char
a
=
'\0'
,
b
=
'\0'
;
char
a
=
'\0'
,
b
=
'\0'
;
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
)
>
action
=
// NOLINT
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
)
>
action
=
// NOLINT
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
DoAll
(
SetArgPointee
<
0
>
(
1
),
SetArg
ument
Pointee
<
1
>
(
2
),
SetArgPointee
<
1
>
(
2
),
SetArg
ument
Pointee
<
2
>
(
'a'
),
SetArgPointee
<
2
>
(
'a'
),
SetArg
ument
Pointee
<
3
>
(
'b'
),
SetArgPointee
<
3
>
(
'b'
),
Return
(
3
));
Return
(
3
));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
)));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
)));
EXPECT_EQ
(
1
,
m
);
EXPECT_EQ
(
1
,
m
);
...
@@ -473,11 +473,11 @@ TEST(DoAllTest, SixActions) {
...
@@ -473,11 +473,11 @@ TEST(DoAllTest, SixActions) {
int
m
=
0
,
n
=
0
;
int
m
=
0
,
n
=
0
;
char
a
=
'\0'
,
b
=
'\0'
,
c
=
'\0'
;
char
a
=
'\0'
,
b
=
'\0'
,
c
=
'\0'
;
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
)
>
action
=
// NOLINT
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
)
>
action
=
// NOLINT
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
DoAll
(
SetArgPointee
<
0
>
(
1
),
SetArg
ument
Pointee
<
1
>
(
2
),
SetArgPointee
<
1
>
(
2
),
SetArg
ument
Pointee
<
2
>
(
'a'
),
SetArgPointee
<
2
>
(
'a'
),
SetArg
ument
Pointee
<
3
>
(
'b'
),
SetArgPointee
<
3
>
(
'b'
),
SetArg
ument
Pointee
<
4
>
(
'c'
),
SetArgPointee
<
4
>
(
'c'
),
Return
(
3
));
Return
(
3
));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
)));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
)));
EXPECT_EQ
(
1
,
m
);
EXPECT_EQ
(
1
,
m
);
...
@@ -492,12 +492,12 @@ TEST(DoAllTest, SevenActions) {
...
@@ -492,12 +492,12 @@ TEST(DoAllTest, SevenActions) {
int
m
=
0
,
n
=
0
;
int
m
=
0
,
n
=
0
;
char
a
=
'\0'
,
b
=
'\0'
,
c
=
'\0'
,
d
=
'\0'
;
char
a
=
'\0'
,
b
=
'\0'
,
c
=
'\0'
,
d
=
'\0'
;
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
,
char
*
)
>
action
=
// NOLINT
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
,
char
*
)
>
action
=
// NOLINT
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
DoAll
(
SetArgPointee
<
0
>
(
1
),
SetArg
ument
Pointee
<
1
>
(
2
),
SetArgPointee
<
1
>
(
2
),
SetArg
ument
Pointee
<
2
>
(
'a'
),
SetArgPointee
<
2
>
(
'a'
),
SetArg
ument
Pointee
<
3
>
(
'b'
),
SetArgPointee
<
3
>
(
'b'
),
SetArg
ument
Pointee
<
4
>
(
'c'
),
SetArgPointee
<
4
>
(
'c'
),
SetArg
ument
Pointee
<
5
>
(
'd'
),
SetArgPointee
<
5
>
(
'd'
),
Return
(
3
));
Return
(
3
));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
,
&
d
)));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
,
&
d
)));
EXPECT_EQ
(
1
,
m
);
EXPECT_EQ
(
1
,
m
);
...
@@ -514,13 +514,13 @@ TEST(DoAllTest, EightActions) {
...
@@ -514,13 +514,13 @@ TEST(DoAllTest, EightActions) {
char
a
=
'\0'
,
b
=
'\0'
,
c
=
'\0'
,
d
=
'\0'
,
e
=
'\0'
;
char
a
=
'\0'
,
b
=
'\0'
,
c
=
'\0'
,
d
=
'\0'
,
e
=
'\0'
;
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
,
char
*
,
// NOLINT
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
,
char
*
,
// NOLINT
char
*
)
>
action
=
char
*
)
>
action
=
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
DoAll
(
SetArgPointee
<
0
>
(
1
),
SetArg
ument
Pointee
<
1
>
(
2
),
SetArgPointee
<
1
>
(
2
),
SetArg
ument
Pointee
<
2
>
(
'a'
),
SetArgPointee
<
2
>
(
'a'
),
SetArg
ument
Pointee
<
3
>
(
'b'
),
SetArgPointee
<
3
>
(
'b'
),
SetArg
ument
Pointee
<
4
>
(
'c'
),
SetArgPointee
<
4
>
(
'c'
),
SetArg
ument
Pointee
<
5
>
(
'd'
),
SetArgPointee
<
5
>
(
'd'
),
SetArg
ument
Pointee
<
6
>
(
'e'
),
SetArgPointee
<
6
>
(
'e'
),
Return
(
3
));
Return
(
3
));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
)));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
)));
EXPECT_EQ
(
1
,
m
);
EXPECT_EQ
(
1
,
m
);
...
@@ -538,14 +538,14 @@ TEST(DoAllTest, NineActions) {
...
@@ -538,14 +538,14 @@ TEST(DoAllTest, NineActions) {
char
a
=
'\0'
,
b
=
'\0'
,
c
=
'\0'
,
d
=
'\0'
,
e
=
'\0'
,
f
=
'\0'
;
char
a
=
'\0'
,
b
=
'\0'
,
c
=
'\0'
,
d
=
'\0'
,
e
=
'\0'
,
f
=
'\0'
;
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
,
char
*
,
// NOLINT
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
,
char
*
,
// NOLINT
char
*
,
char
*
)
>
action
=
char
*
,
char
*
)
>
action
=
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
DoAll
(
SetArgPointee
<
0
>
(
1
),
SetArg
ument
Pointee
<
1
>
(
2
),
SetArgPointee
<
1
>
(
2
),
SetArg
ument
Pointee
<
2
>
(
'a'
),
SetArgPointee
<
2
>
(
'a'
),
SetArg
ument
Pointee
<
3
>
(
'b'
),
SetArgPointee
<
3
>
(
'b'
),
SetArg
ument
Pointee
<
4
>
(
'c'
),
SetArgPointee
<
4
>
(
'c'
),
SetArg
ument
Pointee
<
5
>
(
'd'
),
SetArgPointee
<
5
>
(
'd'
),
SetArg
ument
Pointee
<
6
>
(
'e'
),
SetArgPointee
<
6
>
(
'e'
),
SetArg
ument
Pointee
<
7
>
(
'f'
),
SetArgPointee
<
7
>
(
'f'
),
Return
(
3
));
Return
(
3
));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
)));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
)));
EXPECT_EQ
(
1
,
m
);
EXPECT_EQ
(
1
,
m
);
...
@@ -565,15 +565,15 @@ TEST(DoAllTest, TenActions) {
...
@@ -565,15 +565,15 @@ TEST(DoAllTest, TenActions) {
char
e
=
'\0'
,
f
=
'\0'
,
g
=
'\0'
;
char
e
=
'\0'
,
f
=
'\0'
,
g
=
'\0'
;
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
,
char
*
,
// NOLINT
Action
<
int
(
int
*
,
int
*
,
char
*
,
char
*
,
char
*
,
char
*
,
// NOLINT
char
*
,
char
*
,
char
*
)
>
action
=
char
*
,
char
*
,
char
*
)
>
action
=
DoAll
(
SetArg
ument
Pointee
<
0
>
(
1
),
DoAll
(
SetArgPointee
<
0
>
(
1
),
SetArg
ument
Pointee
<
1
>
(
2
),
SetArgPointee
<
1
>
(
2
),
SetArg
ument
Pointee
<
2
>
(
'a'
),
SetArgPointee
<
2
>
(
'a'
),
SetArg
ument
Pointee
<
3
>
(
'b'
),
SetArgPointee
<
3
>
(
'b'
),
SetArg
ument
Pointee
<
4
>
(
'c'
),
SetArgPointee
<
4
>
(
'c'
),
SetArg
ument
Pointee
<
5
>
(
'd'
),
SetArgPointee
<
5
>
(
'd'
),
SetArg
ument
Pointee
<
6
>
(
'e'
),
SetArgPointee
<
6
>
(
'e'
),
SetArg
ument
Pointee
<
7
>
(
'f'
),
SetArgPointee
<
7
>
(
'f'
),
SetArg
ument
Pointee
<
8
>
(
'g'
),
SetArgPointee
<
8
>
(
'g'
),
Return
(
3
));
Return
(
3
));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
,
&
g
)));
EXPECT_EQ
(
3
,
action
.
Perform
(
make_tuple
(
&
m
,
&
n
,
&
a
,
&
b
,
&
c
,
&
d
,
&
e
,
&
f
,
&
g
)));
EXPECT_EQ
(
1
,
m
);
EXPECT_EQ
(
1
,
m
);
...
...
test/gmock-more-actions_test.cc
View file @
59214836
...
@@ -60,7 +60,6 @@ using testing::ReturnArg;
...
@@ -60,7 +60,6 @@ using testing::ReturnArg;
using
testing
::
ReturnPointee
;
using
testing
::
ReturnPointee
;
using
testing
::
SaveArg
;
using
testing
::
SaveArg
;
using
testing
::
SetArgReferee
;
using
testing
::
SetArgReferee
;
using
testing
::
SetArgumentPointee
;
using
testing
::
StaticAssertTypeEq
;
using
testing
::
StaticAssertTypeEq
;
using
testing
::
Unused
;
using
testing
::
Unused
;
using
testing
::
WithArg
;
using
testing
::
WithArg
;
...
...
test/gmock_link_test.h
View file @
59214836
...
@@ -44,7 +44,7 @@
...
@@ -44,7 +44,7 @@
// ReturnNull
// ReturnNull
// ReturnRef
// ReturnRef
// Assign
// Assign
// SetArg
ument
Pointee
// SetArgPointee
// SetArrayArgument
// SetArrayArgument
// SetErrnoAndReturn
// SetErrnoAndReturn
// Invoke(function)
// Invoke(function)
...
@@ -164,7 +164,7 @@ using testing::ResultOf;
...
@@ -164,7 +164,7 @@ using testing::ResultOf;
using
testing
::
Return
;
using
testing
::
Return
;
using
testing
::
ReturnNull
;
using
testing
::
ReturnNull
;
using
testing
::
ReturnRef
;
using
testing
::
ReturnRef
;
using
testing
::
SetArg
ument
Pointee
;
using
testing
::
SetArgPointee
;
using
testing
::
SetArrayArgument
;
using
testing
::
SetArrayArgument
;
using
testing
::
StartsWith
;
using
testing
::
StartsWith
;
using
testing
::
StrCaseEq
;
using
testing
::
StrCaseEq
;
...
@@ -281,12 +281,12 @@ TEST(LinkTest, TestAssign) {
...
@@ -281,12 +281,12 @@ TEST(LinkTest, TestAssign) {
mock
.
VoidFromString
(
NULL
);
mock
.
VoidFromString
(
NULL
);
}
}
// Tests the linkage of the SetArg
ument
Pointee action.
// Tests the linkage of the SetArgPointee action.
TEST
(
LinkTest
,
TestSetArg
ument
Pointee
)
{
TEST
(
LinkTest
,
TestSetArgPointee
)
{
Mock
mock
;
Mock
mock
;
char
ch
=
'x'
;
char
ch
=
'x'
;
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
SetArg
ument
Pointee
<
0
>
(
'y'
));
EXPECT_CALL
(
mock
,
VoidFromString
(
_
)).
WillOnce
(
SetArgPointee
<
0
>
(
'y'
));
mock
.
VoidFromString
(
&
ch
);
mock
.
VoidFromString
(
&
ch
);
}
}
...
@@ -381,7 +381,7 @@ TEST(LinkTest, TestDoAll) {
...
@@ -381,7 +381,7 @@ TEST(LinkTest, TestDoAll) {
char
ch
=
'x'
;
char
ch
=
'x'
;
EXPECT_CALL
(
mock
,
VoidFromString
(
_
))
EXPECT_CALL
(
mock
,
VoidFromString
(
_
))
.
WillOnce
(
DoAll
(
SetArg
ument
Pointee
<
0
>
(
'y'
),
Return
()));
.
WillOnce
(
DoAll
(
SetArgPointee
<
0
>
(
'y'
),
Return
()));
mock
.
VoidFromString
(
&
ch
);
mock
.
VoidFromString
(
&
ch
);
}
}
...
...
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