summaryrefslogtreecommitdiff
path: root/test/gmock-generated-function-mockers_test.cc
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-03-01 06:58:38 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2013-03-01 06:58:38 +0000
commit26c778f8891be98b913e93b952a1667d05b0af8c (patch)
tree0b96bf68ac86535ff5372ceef98283fb8f41b3ba /test/gmock-generated-function-mockers_test.cc
parente6c09e80a3dd48f2ee02048a2856c7d6ede6a586 (diff)
downloadgooglemock-26c778f8891be98b913e93b952a1667d05b0af8c.tar.gz
Allows the return type of a mock method to contain unprotected commas.
git-svn-id: http://googlemock.googlecode.com/svn/trunk@421 8415998a-534a-0410-bf83-d39667b30386
Diffstat (limited to 'test/gmock-generated-function-mockers_test.cc')
-rw-r--r--test/gmock-generated-function-mockers_test.cc50
1 files changed, 49 insertions, 1 deletions
diff --git a/test/gmock-generated-function-mockers_test.cc b/test/gmock-generated-function-mockers_test.cc
index 2087f99..ea49b9c 100644
--- a/test/gmock-generated-function-mockers_test.cc
+++ b/test/gmock-generated-function-mockers_test.cc
@@ -129,9 +129,16 @@ class MockFoo : public FooInterface {
MOCK_METHOD1(TakesNonConstReference, bool(int&)); // NOLINT
MOCK_METHOD1(TakesConstReference, string(const int&));
+
#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
MOCK_METHOD1(TakesConst, bool(const int)); // NOLINT
-#endif // GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS
+#endif
+
+ // Tests that the function return type can contain unprotected comma.
+ MOCK_METHOD0(ReturnTypeWithComma, std::map<int, string>());
+ MOCK_CONST_METHOD1(ReturnTypeWithComma,
+ std::map<int, string>(int)); // NOLINT
+
MOCK_METHOD0(OverloadedOnArgumentNumber, int()); // NOLINT
MOCK_METHOD1(OverloadedOnArgumentNumber, int(int)); // NOLINT
@@ -143,6 +150,7 @@ class MockFoo : public FooInterface {
MOCK_METHOD1(TypeWithHole, int(int (*)())); // NOLINT
MOCK_METHOD1(TypeWithComma, int(const std::map<int, string>&)); // NOLINT
+
#if GTEST_OS_WINDOWS
MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int());
MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int));
@@ -150,6 +158,10 @@ class MockFoo : public FooInterface {
short d, int e, long f, float g, double h, unsigned i, char* j,
const string& k));
MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTConst, char(int));
+
+ // Tests that the function return type can contain unprotected comma.
+ MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTReturnTypeWithComma,
+ std::map<int, string>());
#endif // GTEST_OS_WINDOWS
private:
@@ -267,6 +279,17 @@ TEST_F(FunctionMockerTest, MocksFunctionsOverloadedOnConstnessOfThis) {
EXPECT_EQ('a', Const(*foo_).OverloadedOnConstness());
}
+TEST_F(FunctionMockerTest, MocksReturnTypeWithComma) {
+ const std::map<int, string> a_map;
+ EXPECT_CALL(mock_foo_, ReturnTypeWithComma())
+ .WillOnce(Return(a_map));
+ EXPECT_CALL(mock_foo_, ReturnTypeWithComma(42))
+ .WillOnce(Return(a_map));
+
+ EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma());
+ EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma(42));
+}
+
#if GTEST_OS_WINDOWS
// Tests mocking a nullary function with calltype.
TEST_F(FunctionMockerTest, MocksNullaryFunctionWithCallType) {
@@ -306,6 +329,14 @@ TEST_F(FunctionMockerTest, MocksFunctionsConstFunctionWithCallType) {
EXPECT_EQ('a', Const(*foo_).CTConst(0));
}
+TEST_F(FunctionMockerTest, MocksReturnTypeWithCommaAndCallType) {
+ const std::map<int, string> a_map;
+ EXPECT_CALL(mock_foo_, CTReturnTypeWithComma())
+ .WillOnce(Return(a_map));
+
+ EXPECT_EQ(a_map, mock_foo_.CTReturnTypeWithComma());
+}
+
#endif // GTEST_OS_WINDOWS
class MockB {
@@ -362,6 +393,10 @@ class MockStack : public StackInterface<T> {
MOCK_CONST_METHOD0_T(GetSize, int()); // NOLINT
MOCK_CONST_METHOD0_T(GetTop, const T&());
+ // Tests that the function return type can contain unprotected comma.
+ MOCK_METHOD0_T(ReturnTypeWithComma, std::map<int, int>());
+ MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map<int, int>(int)); // NOLINT
+
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStack);
};
@@ -389,6 +424,19 @@ TEST(TemplateMockTest, Works) {
EXPECT_EQ(0, mock.GetSize());
}
+TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
+ MockStack<int> mock;
+
+ const std::map<int, int> a_map;
+ EXPECT_CALL(mock, ReturnTypeWithComma())
+ .WillOnce(Return(a_map));
+ EXPECT_CALL(mock, ReturnTypeWithComma(1))
+ .WillOnce(Return(a_map));
+
+ EXPECT_EQ(a_map, mock.ReturnTypeWithComma());
+ EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));
+}
+
#if GTEST_OS_WINDOWS
// Tests mocking template interfaces with calltype.