Disables SetArgPointee("string literal") for GCC 4.0- and Symbian, and
adds support for SetArgPointee(L"wide string literal") -- by Vlad Losev.
This commit is contained in:
parent
62a35fbc5d
commit
fc8c6c479a
|
@ -981,7 +981,11 @@ SetArgPointee(const T& x) {
|
|||
return MakePolymorphicAction(internal::SetArgumentPointeeAction<
|
||||
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.
|
||||
// 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>
|
||||
PolymorphicAction<
|
||||
internal::SetArgumentPointeeAction<N, const char*, false> >
|
||||
|
@ -989,6 +993,16 @@ SetArgPointee(const char* p) {
|
|||
return MakePolymorphicAction(internal::SetArgumentPointeeAction<
|
||||
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.
|
||||
template <size_t N, typename T>
|
||||
PolymorphicAction<
|
||||
|
|
|
@ -714,23 +714,44 @@ TEST(SetArgPointeeTest, SetsTheNthPointee) {
|
|||
EXPECT_EQ('a', ch);
|
||||
}
|
||||
|
||||
#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)
|
||||
// Tests that SetArgPointee<N>() accepts a string literal.
|
||||
// GCC prior to v4.0 and the Symbian compiler do not support this.
|
||||
TEST(SetArgPointeeTest, AcceptsStringLiteral) {
|
||||
typedef void MyFunction(bool, std::string*, const char**);
|
||||
Action<MyFunction> a = SetArgPointee<1>("hi");
|
||||
typedef void MyFunction(std::string*, const char**);
|
||||
Action<MyFunction> a = SetArgPointee<0>("hi");
|
||||
std::string str;
|
||||
const char* ptr = NULL;
|
||||
a.Perform(make_tuple(true, &str, &ptr));
|
||||
a.Perform(make_tuple(&str, &ptr));
|
||||
EXPECT_EQ("hi", str);
|
||||
EXPECT_TRUE(ptr == NULL);
|
||||
|
||||
a = SetArgPointee<2>("world");
|
||||
a = SetArgPointee<1>("world");
|
||||
str = "";
|
||||
a.Perform(make_tuple(true, &str, &ptr));
|
||||
a.Perform(make_tuple(&str, &ptr));
|
||||
EXPECT_EQ("", str);
|
||||
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.
|
||||
TEST(SetArgPointeeTest, AcceptsCharPointer) {
|
||||
typedef void MyFunction(bool, std::string*, const char**);
|
||||
|
@ -751,6 +772,26 @@ TEST(SetArgPointeeTest, AcceptsCharPointer) {
|
|||
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_
|
||||
|
||||
// Tests that SetArgPointee<N>(proto_buffer) sets the v1 protobuf
|
||||
|
|
Loading…
Reference in New Issue
Block a user