diff options
author | kosak@google.com <kosak@google.com@8415998a-534a-0410-bf83-d39667b30386> | 2014-11-17 02:04:46 +0000 |
---|---|---|
committer | kosak@google.com <kosak@google.com@8415998a-534a-0410-bf83-d39667b30386> | 2014-11-17 02:04:46 +0000 |
commit | 309e1d5d3b1985d59b39da7e81045e59e88b2a4a (patch) | |
tree | b04a49d7e0bc84e20b74fb245d8496a580a8c284 /test | |
parent | 914cc9b6d5d7ba620318ff55b4058e11ae62aa42 (diff) | |
download | googlemock-309e1d5d3b1985d59b39da7e81045e59e88b2a4a.tar.gz |
Fix gmock Action behaviour when return type is Wrapper
git-svn-id: http://googlemock.googlecode.com/svn/trunk@492 8415998a-534a-0410-bf83-d39667b30386
Diffstat (limited to 'test')
-rw-r--r-- | test/gmock-actions_test.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/gmock-actions_test.cc b/test/gmock-actions_test.cc index 28b48f1..8089a81 100644 --- a/test/gmock-actions_test.cc +++ b/test/gmock-actions_test.cc @@ -509,6 +509,26 @@ TEST(ReturnTest, AcceptsStringLiteral) { EXPECT_EQ("world", a2.Perform(make_tuple())); } +// Test struct which wraps a vector of integers. Used in +// 'SupportsWrapperReturnType' test. +struct IntegerVectorWrapper { + std::vector<int> * v; + IntegerVectorWrapper(std::vector<int>& _v) : v(&_v) {} // NOLINT +}; + +// Tests that Return() works when return type is a wrapper type. +TEST(ReturnTest, SupportsWrapperReturnType) { + // Initialize vector of integers. + std::vector<int> v; + for (int i = 0; i < 5; ++i) v.push_back(i); + + // Return() called with 'v' as argument. The Action will return the same data + // as 'v' (copy) but it will be wrapped in an IntegerVectorWrapper. + Action<IntegerVectorWrapper()> a = Return(v); + const std::vector<int>& result = *(a.Perform(make_tuple()).v); + EXPECT_THAT(result, ::testing::ElementsAre(0, 1, 2, 3, 4)); +} + // Tests that Return(v) is covaraint. struct Base { |