diff options
author | kosak <kosak@google.com> | 2014-11-17 02:04:46 +0000 |
---|---|---|
committer | kosak <kosak@google.com> | 2014-11-17 02:04:46 +0000 |
commit | 7123d831328321e854b78047effe7a57192a764f (patch) | |
tree | b04a49d7e0bc84e20b74fb245d8496a580a8c284 /include | |
parent | 506340a66b7814b741b4b4a032ca4b059086f1bb (diff) | |
download | googletest-7123d831328321e854b78047effe7a57192a764f.tar.gz googletest-7123d831328321e854b78047effe7a57192a764f.tar.bz2 googletest-7123d831328321e854b78047effe7a57192a764f.zip |
Fix gmock Action behaviour when return type is Wrapper
Diffstat (limited to 'include')
-rw-r--r-- | include/gmock/gmock-actions.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/gmock/gmock-actions.h b/include/gmock/gmock-actions.h index de502048..f92e479f 100644 --- a/include/gmock/gmock-actions.h +++ b/include/gmock/gmock-actions.h @@ -534,16 +534,20 @@ class ReturnAction { // Result without considering explicit constructors, thus resolving the // ambiguity. value_ is then initialized using its copy constructor. explicit Impl(const linked_ptr<R>& value) - : value_(ImplicitCast_<Result>(*value)) {} + : value_before_cast_(*value), + value_(ImplicitCast_<Result>(value_before_cast_)) {} virtual Result Perform(const ArgumentTuple&) { return value_; } private: GTEST_COMPILE_ASSERT_(!is_reference<Result>::value, Result_cannot_be_a_reference_type); + // We save the value before casting just in case it is being cast to a + // wrapper type. + R value_before_cast_; Result value_; - GTEST_DISALLOW_ASSIGN_(Impl); + GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl); }; // Partially specialize for ByMoveWrapper. This version of ReturnAction will |