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
fc8c6c47
Commit
fc8c6c47
authored
Mar 09, 2011
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disables SetArgPointee("string literal") for GCC 4.0- and Symbian, and
adds support for SetArgPointee(L"wide string literal") -- by Vlad Losev.
parent
62a35fbc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
5 deletions
+60
-5
gmock-actions.h
include/gmock/gmock-actions.h
+14
-0
gmock-actions_test.cc
test/gmock-actions_test.cc
+46
-5
No files found.
include/gmock/gmock-actions.h
View file @
fc8c6c47
...
@@ -981,7 +981,11 @@ SetArgPointee(const T& x) {
...
@@ -981,7 +981,11 @@ SetArgPointee(const T& x) {
return
MakePolymorphicAction
(
internal
::
SetArgumentPointeeAction
<
return
MakePolymorphicAction
(
internal
::
SetArgumentPointeeAction
<
N
,
T
,
internal
::
IsAProtocolMessage
<
T
>::
value
>
(
x
));
N
,
T
,
internal
::
IsAProtocolMessage
<
T
>::
value
>
(
x
));
}
}
#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
// This overload allows SetArgPointee() to accept a string literal.
// This overload allows SetArgPointee() to accept a string literal.
// GCC prior to the version 4.0 and Symbian C++ compiler cannot distinguish
// this overload from the templated version and emit a compile error.
template
<
size_t
N
>
template
<
size_t
N
>
PolymorphicAction
<
PolymorphicAction
<
internal
::
SetArgumentPointeeAction
<
N
,
const
char
*
,
false
>
>
internal
::
SetArgumentPointeeAction
<
N
,
const
char
*
,
false
>
>
...
@@ -989,6 +993,16 @@ SetArgPointee(const char* p) {
...
@@ -989,6 +993,16 @@ SetArgPointee(const char* p) {
return
MakePolymorphicAction
(
internal
::
SetArgumentPointeeAction
<
return
MakePolymorphicAction
(
internal
::
SetArgumentPointeeAction
<
N
,
const
char
*
,
false
>
(
p
));
N
,
const
char
*
,
false
>
(
p
));
}
}
template
<
size_t
N
>
PolymorphicAction
<
internal
::
SetArgumentPointeeAction
<
N
,
const
wchar_t
*
,
false
>
>
SetArgPointee
(
const
wchar_t
*
p
)
{
return
MakePolymorphicAction
(
internal
::
SetArgumentPointeeAction
<
N
,
const
wchar_t
*
,
false
>
(
p
));
}
#endif
// The following version is DEPRECATED.
// The following version is DEPRECATED.
template
<
size_t
N
,
typename
T
>
template
<
size_t
N
,
typename
T
>
PolymorphicAction
<
PolymorphicAction
<
...
...
test/gmock-actions_test.cc
View file @
fc8c6c47
...
@@ -714,23 +714,44 @@ TEST(SetArgPointeeTest, SetsTheNthPointee) {
...
@@ -714,23 +714,44 @@ TEST(SetArgPointeeTest, SetsTheNthPointee) {
EXPECT_EQ
(
'a'
,
ch
);
EXPECT_EQ
(
'a'
,
ch
);
}
}
#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
// Tests that SetArgPointee<N>() accepts a string literal.
// Tests that SetArgPointee<N>() accepts a string literal.
// GCC prior to v4.0 and the Symbian compiler do not support this.
TEST
(
SetArgPointeeTest
,
AcceptsStringLiteral
)
{
TEST
(
SetArgPointeeTest
,
AcceptsStringLiteral
)
{
typedef
void
MyFunction
(
bool
,
std
::
string
*
,
const
char
**
);
typedef
void
MyFunction
(
std
::
string
*
,
const
char
**
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
1
>
(
"hi"
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
0
>
(
"hi"
);
std
::
string
str
;
std
::
string
str
;
const
char
*
ptr
=
NULL
;
const
char
*
ptr
=
NULL
;
a
.
Perform
(
make_tuple
(
true
,
&
str
,
&
ptr
));
a
.
Perform
(
make_tuple
(
&
str
,
&
ptr
));
EXPECT_EQ
(
"hi"
,
str
);
EXPECT_EQ
(
"hi"
,
str
);
EXPECT_TRUE
(
ptr
==
NULL
);
EXPECT_TRUE
(
ptr
==
NULL
);
a
=
SetArgPointee
<
2
>
(
"world"
);
a
=
SetArgPointee
<
1
>
(
"world"
);
str
=
""
;
str
=
""
;
a
.
Perform
(
make_tuple
(
true
,
&
str
,
&
ptr
));
a
.
Perform
(
make_tuple
(
&
str
,
&
ptr
));
EXPECT_EQ
(
""
,
str
);
EXPECT_EQ
(
""
,
str
);
EXPECT_STREQ
(
"world"
,
ptr
);
EXPECT_STREQ
(
"world"
,
ptr
);
}
}
TEST
(
SetArgPointeeTest
,
AcceptsWideStringLiteral
)
{
typedef
void
MyFunction
(
const
wchar_t
**
);
Action
<
MyFunction
>
a
=
SetArgPointee
<
0
>
(
L"world"
);
const
wchar_t
*
ptr
=
NULL
;
a
.
Perform
(
make_tuple
(
&
ptr
));
EXPECT_STREQ
(
L"world"
,
ptr
);
# if GTEST_HAS_STD_WSTRING
typedef
void
MyStringFunction
(
std
::
wstring
*
);
Action
<
MyStringFunction
>
a2
=
SetArgPointee
<
0
>
(
L"world"
);
std
::
wstring
str
=
L""
;
a2
.
Perform
(
make_tuple
(
&
str
));
EXPECT_EQ
(
L"world"
,
str
);
# endif
}
#endif
// Tests that SetArgPointee<N>() accepts a char pointer.
// Tests that SetArgPointee<N>() accepts a char pointer.
TEST
(
SetArgPointeeTest
,
AcceptsCharPointer
)
{
TEST
(
SetArgPointeeTest
,
AcceptsCharPointer
)
{
typedef
void
MyFunction
(
bool
,
std
::
string
*
,
const
char
**
);
typedef
void
MyFunction
(
bool
,
std
::
string
*
,
const
char
**
);
...
@@ -751,6 +772,26 @@ TEST(SetArgPointeeTest, AcceptsCharPointer) {
...
@@ -751,6 +772,26 @@ TEST(SetArgPointeeTest, AcceptsCharPointer) {
EXPECT_EQ
(
world
,
ptr
);
EXPECT_EQ
(
world
,
ptr
);
}
}
TEST
(
SetArgPointeeTest
,
AcceptsWideCharPointer
)
{
typedef
void
MyFunction
(
bool
,
const
wchar_t
**
);
const
wchar_t
*
const
hi
=
L"hi"
;
Action
<
MyFunction
>
a
=
SetArgPointee
<
1
>
(
hi
);
const
wchar_t
*
ptr
=
NULL
;
a
.
Perform
(
make_tuple
(
true
,
&
ptr
));
EXPECT_EQ
(
hi
,
ptr
);
# if GTEST_HAS_STD_WSTRING
typedef
void
MyStringFunction
(
bool
,
std
::
wstring
*
);
wchar_t
world_array
[]
=
L"world"
;
wchar_t
*
const
world
=
world_array
;
Action
<
MyStringFunction
>
a2
=
SetArgPointee
<
1
>
(
world
);
std
::
wstring
str
;
a2
.
Perform
(
make_tuple
(
true
,
&
str
));
EXPECT_EQ
(
world_array
,
str
);
# endif
}
#if GTEST_HAS_PROTOBUF_
#if GTEST_HAS_PROTOBUF_
// Tests that SetArgPointee<N>(proto_buffer) sets the v1 protobuf
// Tests that SetArgPointee<N>(proto_buffer) sets the v1 protobuf
...
...
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