aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2011-03-09 01:18:08 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2011-03-09 01:18:08 +0000
commitfc8c6c479a5250b709ed7b4406e025439037e18e (patch)
treedaa8a90d0daedfaad62196bec42c63646f19f21d /test
parent62a35fbc5d316c4f82f37cb6e183eb8de210a94c (diff)
downloadgoogletest-fc8c6c479a5250b709ed7b4406e025439037e18e.tar.gz
googletest-fc8c6c479a5250b709ed7b4406e025439037e18e.tar.bz2
googletest-fc8c6c479a5250b709ed7b4406e025439037e18e.zip
Disables SetArgPointee("string literal") for GCC 4.0- and Symbian, and
adds support for SetArgPointee(L"wide string literal") -- by Vlad Losev.
Diffstat (limited to 'test')
-rw-r--r--test/gmock-actions_test.cc51
1 files changed, 46 insertions, 5 deletions
diff --git a/test/gmock-actions_test.cc b/test/gmock-actions_test.cc
index b3f8d52b..b7803fe9 100644
--- a/test/gmock-actions_test.cc
+++ b/test/gmock-actions_test.cc
@@ -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