| gmock-generated-actions.h | | gmock-generated-actions.h | |
| | | | |
| skipping to change at line 618 | | skipping to change at line 618 | |
| } | | } | |
| | | | |
| private: | | private: | |
| typedef typename SelectArgs<Result, ArgumentTuple, | | typedef typename SelectArgs<Result, ArgumentTuple, | |
| k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType; | | k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType; | |
| | | | |
| Action<InnerFunctionType> action_; | | Action<InnerFunctionType> action_; | |
| }; | | }; | |
| | | | |
| const InnerAction action_; | | const InnerAction action_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(WithArgsAction); | |
| }; | | }; | |
| | | | |
| // A macro from the ACTION* family (defined later in this file) | | // A macro from the ACTION* family (defined later in this file) | |
| // defines an action that can be used in a mock function. Typically, | | // defines an action that can be used in a mock function. Typically, | |
| // these actions only care about a subset of the arguments of the mock | | // these actions only care about a subset of the arguments of the mock | |
| // function. For example, if such an action only uses the second | | // function. For example, if such an action only uses the second | |
| // argument, it can be used in any mock function that takes >= 2 | | // argument, it can be used in any mock function that takes >= 2 | |
| // arguments where the type of the second argument is compatible. | | // arguments where the type of the second argument is compatible. | |
| // | | // | |
| // Therefore, the action implementation must be prepared to take more | | // Therefore, the action implementation must be prepared to take more | |
| | | | |
| skipping to change at line 1409 | | skipping to change at line 1411 | |
| }\ | | }\ | |
| template <typename arg0_type, typename arg1_type, typename arg2_type,
\ | | template <typename arg0_type, typename arg1_type, typename arg2_type,
\ | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| typename arg6_type, typename arg7_type, typename arg8_type, \ | | typename arg6_type, typename arg7_type, typename arg8_type, \ | |
| typename arg9_type>\ | | typename arg9_type>\ | |
| return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| GMOCK_INTERNAL_DEFN_##value_params\ | | GMOCK_INTERNAL_DEFN_##value_params\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(\ | | return ::testing::Action<F>(\ | |
| new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\ | | new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\ | |
| }\ | | }\ | |
| GMOCK_INTERNAL_DEFN_##value_params\ | | GMOCK_INTERNAL_DEFN_##value_params\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ | |
| };\ | | };\ | |
| template <GMOCK_INTERNAL_DECL_##template_params\ | | template <GMOCK_INTERNAL_DECL_##template_params\ | |
| GMOCK_INTERNAL_DECL_TYPE_##value_params>\ | | GMOCK_INTERNAL_DECL_TYPE_##value_params>\ | |
| inline GMOCK_ACTION_CLASS_(name, value_params)<\ | | inline GMOCK_ACTION_CLASS_(name, value_params)<\ | |
| GMOCK_INTERNAL_LIST_##template_params\ | | GMOCK_INTERNAL_LIST_##template_params\ | |
| GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\ | | GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\ | |
| GMOCK_INTERNAL_DECL_##value_params) {\ | | GMOCK_INTERNAL_DECL_##value_params) {\ | |
| return GMOCK_ACTION_CLASS_(name, value_params)<\ | | return GMOCK_ACTION_CLASS_(name, value_params)<\ | |
| GMOCK_INTERNAL_LIST_##template_params\ | | GMOCK_INTERNAL_LIST_##template_params\ | |
| GMOCK_INTERNAL_LIST_TYPE_##value_params>(\ | | GMOCK_INTERNAL_LIST_TYPE_##value_params>(\ | |
| | | | |
| skipping to change at line 1465 | | skipping to change at line 1471 | |
| Perform(this, args);\ | | Perform(this, args);\ | |
| }\ | | }\ | |
| template <typename arg0_type, typename arg1_type, typename arg2_type,
\ | | template <typename arg0_type, typename arg1_type, typename arg2_type,
\ | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| typename arg6_type, typename arg7_type, typename arg8_type, \ | | typename arg6_type, typename arg7_type, typename arg8_type, \ | |
| typename arg9_type>\ | | typename arg9_type>\ | |
| return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>());\ | | return ::testing::Action<F>(new gmock_Impl<F>());\ | |
| }\ | | }\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##Action);\ | |
| };\ | | };\ | |
| inline name##Action name() {\ | | inline name##Action name() {\ | |
| return name##Action();\ | | return name##Action();\ | |
| }\ | | }\ | |
| template <typename F>\ | | template <typename F>\ | |
| template <typename arg0_type, typename arg1_type, typename arg2_type, \ | | template <typename arg0_type, typename arg1_type, typename arg2_type, \ | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| typename arg6_type, typename arg7_type, typename arg8_type, \ | | typename arg6_type, typename arg7_type, typename arg8_type, \ | |
| typename arg9_type>\ | | typename arg9_type>\ | |
| typename ::testing::internal::Function<F>::Result\ | | typename ::testing::internal::Function<F>::Result\ | |
| | | | |
| skipping to change at line 1508 | | skipping to change at line 1518 | |
| }\ | | }\ | |
| template <typename arg0_type, typename arg1_type, typename arg2_type,
\ | | template <typename arg0_type, typename arg1_type, typename arg2_type,
\ | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| typename arg6_type, typename arg7_type, typename arg8_type, \ | | typename arg6_type, typename arg7_type, typename arg8_type, \ | |
| typename arg9_type>\ | | typename arg9_type>\ | |
| return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0));\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP);\ | |
| };\ | | };\ | |
| template <typename p0##_type>\ | | template <typename p0##_type>\ | |
| inline name##ActionP<p0##_type> name(p0##_type p0) {\ | | inline name##ActionP<p0##_type> name(p0##_type p0) {\ | |
| return name##ActionP<p0##_type>(p0);\ | | return name##ActionP<p0##_type>(p0);\ | |
| }\ | | }\ | |
| template <typename p0##_type>\ | | template <typename p0##_type>\ | |
| template <typename F>\ | | template <typename F>\ | |
| template <typename arg0_type, typename arg1_type, typename arg2_type, \ | | template <typename arg0_type, typename arg1_type, typename arg2_type, \ | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| typename arg6_type, typename arg7_type, typename arg8_type, \ | | typename arg6_type, typename arg7_type, typename arg8_type, \ | |
| | | | |
| skipping to change at line 1557 | | skipping to change at line 1571 | |
| template <typename arg0_type, typename arg1_type, typename arg2_type,
\ | | template <typename arg0_type, typename arg1_type, typename arg2_type,
\ | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| typename arg6_type, typename arg7_type, typename arg8_type, \ | | typename arg6_type, typename arg7_type, typename arg8_type, \ | |
| typename arg9_type>\ | | typename arg9_type>\ | |
| return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP2);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type>\ | | template <typename p0##_type, typename p1##_type>\ | |
| inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \ | | inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \ | |
| p1##_type p1) {\ | | p1##_type p1) {\ | |
| return name##ActionP2<p0##_type, p1##_type>(p0, p1);\ | | return name##ActionP2<p0##_type, p1##_type>(p0, p1);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type>\ | | template <typename p0##_type, typename p1##_type>\ | |
| template <typename F>\ | | template <typename F>\ | |
| template <typename arg0_type, typename arg1_type, typename arg2_type, \ | | template <typename arg0_type, typename arg1_type, typename arg2_type, \ | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| | | | |
| skipping to change at line 1609 | | skipping to change at line 1627 | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| typename arg6_type, typename arg7_type, typename arg8_type, \ | | typename arg6_type, typename arg7_type, typename arg8_type, \ | |
| typename arg9_type>\ | | typename arg9_type>\ | |
| return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP3);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type>\ | | template <typename p0##_type, typename p1##_type, typename p2##_type>\ | |
| inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0,
\ | | inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0,
\ | |
| p1##_type p1, p2##_type p2) {\ | | p1##_type p1, p2##_type p2) {\ | |
| return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\ | | return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type>\ | | template <typename p0##_type, typename p1##_type, typename p2##_type>\ | |
| template <typename F>\ | | template <typename F>\ | |
| template <typename arg0_type, typename arg1_type, typename arg2_type, \ | | template <typename arg0_type, typename arg1_type, typename arg2_type, \ | |
| typename arg3_type, typename arg4_type, typename arg5_type, \ | | typename arg3_type, typename arg4_type, typename arg5_type, \ | |
| | | | |
| skipping to change at line 1667 | | skipping to change at line 1689 | |
| typename arg6_type, typename arg7_type, typename arg8_type, \ | | typename arg6_type, typename arg7_type, typename arg8_type, \ | |
| typename arg9_type>\ | | typename arg9_type>\ | |
| return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP4);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type>\ | | typename p3##_type>\ | |
| inline name##ActionP4<p0##_type, p1##_type, p2##_type, \ | | inline name##ActionP4<p0##_type, p1##_type, p2##_type, \ | |
| p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \ | | p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \ | |
| p3##_type p3) {\ | | p3##_type p3) {\ | |
| return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p
1, \ | | return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p
1, \ | |
| p2, p3);\ | | p2, p3);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| | | | |
| skipping to change at line 1732 | | skipping to change at line 1758 | |
| typename arg9_type>\ | | typename arg9_type>\ | |
| return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP5);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type>\ | | typename p3##_type, typename p4##_type>\ | |
| inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | | p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | |
| p4##_type p4) {\ | | p4##_type p4) {\ | |
| return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type>(p0, p1, p2, p3, p4);\ | | p4##_type>(p0, p1, p2, p3, p4);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| | | | |
| skipping to change at line 1800 | | skipping to change at line 1830 | |
| return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | | return_type gmock_PerformImpl(const args_type& args, arg0_type arg0,
\ | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5)
);\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5)
);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP6);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type>\ | | typename p3##_type, typename p4##_type, typename p5##_type>\ | |
| inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2,
\ | | p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2,
\ | |
| p3##_type p3, p4##_type p4, p5##_type p5) {\ | | p3##_type p3, p4##_type p4, p5##_type p5) {\ | |
| return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\ | | p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| | | | |
| skipping to change at line 1872 | | skipping to change at line 1906 | |
| arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | | arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \ | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\ | |
| p6));\ | | p6));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP7);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type>\ | | typename p6##_type>\ | |
| inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \ | | p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \ | |
| p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ | | p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ | |
| p6##_type p6) {\ | | p6##_type p6) {\ | |
| return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\ | | p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\ | |
| | | | |
| skipping to change at line 1952 | | skipping to change at line 1990 | |
| arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | | arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \ | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\ | |
| p6, p7));\ | | p6, p7));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP8);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type>\ | | typename p6##_type, typename p7##_type>\ | |
| inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \ | | p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \ | |
| p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5,
\ | | p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5,
\ | |
| p6##_type p6, p7##_type p7) {\ | | p6##_type p6, p7##_type p7) {\ | |
| return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5,
\ | | p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5,
\ | |
| | | | |
| skipping to change at line 2037 | | skipping to change at line 2079 | |
| arg9_type arg9) const;\ | | arg9_type arg9) const;\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| p8##_type p8;\ | | p8##_type p8;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\ | |
| p6, p7, p8));\ | | p6, p7, p8));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| p8##_type p8;\ | | p8##_type p8;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP9);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type, typename p8##_type>\ | | typename p6##_type, typename p7##_type, typename p8##_type>\ | |
| inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type, \ | | p4##_type, p5##_type, p6##_type, p7##_type, \ | |
| p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | | p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | |
| p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ | | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ | |
| p8##_type p8) {\ | | p8##_type p8) {\ | |
| return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| | | | |
| skipping to change at line 2126 | | skipping to change at line 2172 | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| p8##_type p8;\ | | p8##_type p8;\ | |
| p9##_type p9;\ | | p9##_type p9;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename F> operator ::testing::Action<F>() const {\ | | template <typename F> operator ::testing::Action<F>() const {\ | |
| return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\ | | return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5,
\ | |
| p6, p7, p8, p9));\ | | p6, p7, p8, p9));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| p8##_type p8;\ | | p8##_type p8;\ | |
| p9##_type p9;\ | | p9##_type p9;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(name##ActionP10);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type, typename p8##_type, \ | | typename p6##_type, typename p7##_type, typename p8##_type, \ | |
| typename p9##_type>\ | | typename p9##_type>\ | |
| inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \ | | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \ | |
| p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | | p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | |
| p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8,
\ | | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8,
\ | |
| p9##_type p9) {\ | | p9##_type p9) {\ | |
| | | | |
| skipping to change at line 2175 | | skipping to change at line 2225 | |
| name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
, \ | | name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
, \ | |
| p5##_type, p6##_type, p7##_type, p8##_type, \ | | p5##_type, p6##_type, p7##_type, p8##_type, \ | |
| p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\ | | p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\ | |
| GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const | | GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const | |
| | | | |
| // TODO(wan@google.com): move the following to a different .h file | | // TODO(wan@google.com): move the following to a different .h file | |
| // such that we don't have to run 'pump' every time the code is | | // such that we don't have to run 'pump' every time the code is | |
| // updated. | | // updated. | |
| namespace testing { | | namespace testing { | |
| | | | |
|
| | | // The ACTION*() macros trigger warning C4100 (unreferenced formal | |
| | | // parameter) in MSVC with -W4. Unfortunately they cannot be fixed in | |
| | | // the macro definition, as the warnings are generated when the macro | |
| | | // is expanded and macro expansion cannot contain #pragma. Therefore | |
| | | // we suppress them here. | |
| | | #ifdef _MSC_VER | |
| | | #pragma warning(push) | |
| | | #pragma warning(disable:4100) | |
| | | #endif | |
| | | | |
| // Various overloads for InvokeArgument<N>(). | | // Various overloads for InvokeArgument<N>(). | |
| // | | // | |
| // The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th | | // The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th | |
| // (0-based) argument, which must be a k-ary callable, of the mock | | // (0-based) argument, which must be a k-ary callable, of the mock | |
| // function, with arguments a1, a2, ..., a_k. | | // function, with arguments a1, a2, ..., a_k. | |
| // | | // | |
| // Notes: | | // Notes: | |
| // | | // | |
| // 1. The arguments are passed by value by default. If you need to | | // 1. The arguments are passed by value by default. If you need to | |
| // pass an argument by reference, wrap it inside ByRef(). For | | // pass an argument by reference, wrap it inside ByRef(). For | |
| | | | |
| skipping to change at line 2353 | | skipping to change at line 2413 | |
| AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { | | AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { | |
| return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8); | | return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8); | |
| } | | } | |
| | | | |
| ACTION_TEMPLATE(ReturnNew, | | ACTION_TEMPLATE(ReturnNew, | |
| HAS_1_TEMPLATE_PARAMS(typename, T), | | HAS_1_TEMPLATE_PARAMS(typename, T), | |
| AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)
) { | | AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)
) { | |
| return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); | | return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); | |
| } | | } | |
| | | | |
|
| | | #ifdef _MSC_VER | |
| | | #pragma warning(pop) | |
| | | #endif | |
| | | | |
| } // namespace testing | | } // namespace testing | |
| | | | |
| #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ | | #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ | |
| | | | |
End of changes. 27 change blocks. |
| 0 lines changed or deleted | | 64 lines changed or added | |
|
| gmock-generated-function-mockers.h | | gmock-generated-function-mockers.h | |
| | | | |
| skipping to change at line 45 | | skipping to change at line 45 | |
| // | | // | |
| // This file implements function mockers of various arities. | | // This file implements function mockers of various arities. | |
| | | | |
| #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ | | #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ | |
| #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ | | #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ | |
| | | | |
| #include <gmock/gmock-spec-builders.h> | | #include <gmock/gmock-spec-builders.h> | |
| #include <gmock/internal/gmock-internal-utils.h> | | #include <gmock/internal/gmock-internal-utils.h> | |
| | | | |
| namespace testing { | | namespace testing { | |
|
| | | | |
| template <typename F> | | | |
| class MockSpec; | | | |
| | | | |
| namespace internal { | | namespace internal { | |
| | | | |
| template <typename F> | | template <typename F> | |
| class FunctionMockerBase; | | class FunctionMockerBase; | |
| | | | |
| // Note: class FunctionMocker really belongs to the ::testing | | // Note: class FunctionMocker really belongs to the ::testing | |
| // namespace. However if we define it in ::testing, MSVC will | | // namespace. However if we define it in ::testing, MSVC will | |
| // complain when classes in ::testing::internal declare it as a | | // complain when classes in ::testing::internal declare it as a | |
| // friend class template. To workaround this compiler bug, we define | | // friend class template. To workaround this compiler bug, we define | |
| // FunctionMocker in ::testing::internal and import it into ::testing. | | // FunctionMocker in ::testing::internal and import it into ::testing. | |
| | | | |
| skipping to change at line 74 | | skipping to change at line 70 | |
| internal::FunctionMockerBase<R()> { | | internal::FunctionMockerBase<R()> { | |
| public: | | public: | |
| typedef R F(); | | typedef R F(); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With() { | | MockSpec<F>& With() { | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke() { | | R Invoke() { | |
|
| return InvokeWith(ArgumentTuple()); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple()); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1> | | template <typename R, typename A1> | |
| class FunctionMocker<R(A1)> : public | | class FunctionMocker<R(A1)> : public | |
| internal::FunctionMockerBase<R(A1)> { | | internal::FunctionMockerBase<R(A1)> { | |
| public: | | public: | |
| typedef R F(A1); | | typedef R F(A1); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With(const Matcher<A1>& m1) { | | MockSpec<F>& With(const Matcher<A1>& m1) { | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1)); | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1) { | | R Invoke(A1 a1) { | |
|
| return InvokeWith(ArgumentTuple(a1)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2> | | template <typename R, typename A1, typename A2> | |
| class FunctionMocker<R(A1, A2)> : public | | class FunctionMocker<R(A1, A2)> : public | |
| internal::FunctionMockerBase<R(A1, A2)> { | | internal::FunctionMockerBase<R(A1, A2)> { | |
| public: | | public: | |
| typedef R F(A1, A2); | | typedef R F(A1, A2); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) { | | MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) { | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2)); | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2) { | | R Invoke(A1 a1, A2 a2) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2, typename A3> | | template <typename R, typename A1, typename A2, typename A3> | |
| class FunctionMocker<R(A1, A2, A3)> : public | | class FunctionMocker<R(A1, A2, A3)> : public | |
| internal::FunctionMockerBase<R(A1, A2, A3)> { | | internal::FunctionMockerBase<R(A1, A2, A3)> { | |
| public: | | public: | |
| typedef R F(A1, A2, A3); | | typedef R F(A1, A2, A3); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | | MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | |
| const Matcher<A3>& m3) { | | const Matcher<A3>& m3) { | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3)); | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2, A3 a3) { | | R Invoke(A1 a1, A2 a2, A3 a3) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2, a3)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2, a3)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2, typename A3, typename A4> | | template <typename R, typename A1, typename A2, typename A3, typename A4> | |
| class FunctionMocker<R(A1, A2, A3, A4)> : public | | class FunctionMocker<R(A1, A2, A3, A4)> : public | |
| internal::FunctionMockerBase<R(A1, A2, A3, A4)> { | | internal::FunctionMockerBase<R(A1, A2, A3, A4)> { | |
| public: | | public: | |
| typedef R F(A1, A2, A3, A4); | | typedef R F(A1, A2, A3, A4); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | | MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | |
| const Matcher<A3>& m3, const Matcher<A4>& m4) { | | const Matcher<A3>& m3, const Matcher<A4>& m4) { | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4)
); | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4)
); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) { | | R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2, a3, a4)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2, typename A3, typename A4, | | template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| typename A5> | | typename A5> | |
| class FunctionMocker<R(A1, A2, A3, A4, A5)> : public | | class FunctionMocker<R(A1, A2, A3, A4, A5)> : public | |
| internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> { | | internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> { | |
| public: | | public: | |
| typedef R F(A1, A2, A3, A4, A5); | | typedef R F(A1, A2, A3, A4, A5); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | | MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | |
| const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5)
{ | | const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5)
{ | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, | |
| m5)); | | m5)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { | | R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2, typename A3, typename A4, | | template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| typename A5, typename A6> | | typename A5, typename A6> | |
| class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public | | class FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public | |
| internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> { | | internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> { | |
| public: | | public: | |
| typedef R F(A1, A2, A3, A4, A5, A6); | | typedef R F(A1, A2, A3, A4, A5, A6); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | | MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | |
| const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | | const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | |
| const Matcher<A6>& m6) { | | const Matcher<A6>& m6) { | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | |
| m6)); | | m6)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { | | R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2, typename A3, typename A4, | | template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| typename A5, typename A6, typename A7> | | typename A5, typename A6, typename A7> | |
| class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public | | class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public | |
| internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> { | | internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> { | |
| public: | | public: | |
| typedef R F(A1, A2, A3, A4, A5, A6, A7); | | typedef R F(A1, A2, A3, A4, A5, A6, A7); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | | MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | |
| const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | | const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | |
| const Matcher<A6>& m6, const Matcher<A7>& m7) { | | const Matcher<A6>& m6, const Matcher<A7>& m7) { | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | |
| m6, m7)); | | m6, m7)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { | | R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2, typename A3, typename A4, | | template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| typename A5, typename A6, typename A7, typename A8> | | typename A5, typename A6, typename A7, typename A8> | |
| class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public | | class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public | |
| internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> { | | internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> { | |
| public: | | public: | |
| typedef R F(A1, A2, A3, A4, A5, A6, A7, A8); | | typedef R F(A1, A2, A3, A4, A5, A6, A7, A8); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | | MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | |
| const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | | const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | |
| const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8)
{ | | const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8)
{ | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | |
| m6, m7, m8)); | | m6, m7, m8)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { | | R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2, typename A3, typename A4, | | template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| typename A5, typename A6, typename A7, typename A8, typename A9> | | typename A5, typename A6, typename A7, typename A8, typename A9> | |
| class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public | | class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public | |
| internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> { | | internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> { | |
| public: | | public: | |
| typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9); | | typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9); | |
| typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple; | |
| | | | |
| skipping to change at line 249 | | skipping to change at line 281 | |
| MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | | MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2, | |
| const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | | const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | |
| const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8, | | const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8, | |
| const Matcher<A9>& m9) { | | const Matcher<A9>& m9) { | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | |
| m6, m7, m8, m9)); | | m6, m7, m8, m9)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) { | | R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9)); | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a | |
| | | 9)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <typename R, typename A1, typename A2, typename A3, typename A4, | | template <typename R, typename A1, typename A2, typename A3, typename A4, | |
| typename A5, typename A6, typename A7, typename A8, typename A9, | | typename A5, typename A6, typename A7, typename A8, typename A9, | |
| typename A10> | | typename A10> | |
| class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public | | class FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public | |
| internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)
> { | | internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)
> { | |
| public: | | public: | |
| typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); | | typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10); | |
| | | | |
| skipping to change at line 273 | | skipping to change at line 309 | |
| const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | | const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5, | |
| const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8, | | const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8, | |
| const Matcher<A9>& m9, const Matcher<A10>& m10) { | | const Matcher<A9>& m9, const Matcher<A10>& m10) { | |
| this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | | this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,
m5, | |
| m6, m7, m8, m9, m10)); | | m6, m7, m8, m9, m10)); | |
| return this->current_spec(); | | return this->current_spec(); | |
| } | | } | |
| | | | |
| R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, | | R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, | |
| A10 a10) { | | A10 a10) { | |
|
| return InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 | | // Even though gcc and MSVC don't enforce it, 'this->' is required | |
| )); | | // by the C++ standard [14.6.4] here, as the base class type is | |
| | | // dependent on the template argument (and thus shouldn't be | |
| | | // looked into when resolving InvokeWith). | |
| | | return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a | |
| | | 9, | |
| | | a10)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| } // namespace internal | | } // namespace internal | |
| | | | |
| // The style guide prohibits "using" statements in a namespace scope | | // The style guide prohibits "using" statements in a namespace scope | |
| // inside a header file. However, the FunctionMocker class template | | // inside a header file. However, the FunctionMocker class template | |
| // is meant to be defined in the ::testing namespace. The following | | // is meant to be defined in the ::testing namespace. The following | |
| // line is just a trick for working around a bug in MSVC 8.0, which | | // line is just a trick for working around a bug in MSVC 8.0, which | |
| // cannot handle it if we define FunctionMocker in ::testing. | | // cannot handle it if we define FunctionMocker in ::testing. | |
| | | | |
| skipping to change at line 756 | | skipping to change at line 797 | |
| // before check point "1", the second Bar("a") must happen after check | | // before check point "1", the second Bar("a") must happen after check | |
| // point "2", and nothing should happen between the two check | | // point "2", and nothing should happen between the two check | |
| // points. The explicit check points make it easy to tell which | | // points. The explicit check points make it easy to tell which | |
| // Bar("a") is called by which call to Foo(). | | // Bar("a") is called by which call to Foo(). | |
| template <typename F> | | template <typename F> | |
| class MockFunction; | | class MockFunction; | |
| | | | |
| template <typename R> | | template <typename R> | |
| class MockFunction<R()> { | | class MockFunction<R()> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD0_T(Call, R()); | | MOCK_METHOD0_T(Call, R()); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0> | | template <typename R, typename A0> | |
| class MockFunction<R(A0)> { | | class MockFunction<R(A0)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD1_T(Call, R(A0)); | | MOCK_METHOD1_T(Call, R(A0)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1> | | template <typename R, typename A0, typename A1> | |
| class MockFunction<R(A0, A1)> { | | class MockFunction<R(A0, A1)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD2_T(Call, R(A0, A1)); | | MOCK_METHOD2_T(Call, R(A0, A1)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1, typename A2> | | template <typename R, typename A0, typename A1, typename A2> | |
| class MockFunction<R(A0, A1, A2)> { | | class MockFunction<R(A0, A1, A2)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD3_T(Call, R(A0, A1, A2)); | | MOCK_METHOD3_T(Call, R(A0, A1, A2)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1, typename A2, typename A3> | | template <typename R, typename A0, typename A1, typename A2, typename A3> | |
| class MockFunction<R(A0, A1, A2, A3)> { | | class MockFunction<R(A0, A1, A2, A3)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD4_T(Call, R(A0, A1, A2, A3)); | | MOCK_METHOD4_T(Call, R(A0, A1, A2, A3)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1, typename A2, typename A3, | | template <typename R, typename A0, typename A1, typename A2, typename A3, | |
| typename A4> | | typename A4> | |
| class MockFunction<R(A0, A1, A2, A3, A4)> { | | class MockFunction<R(A0, A1, A2, A3, A4)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4)); | | MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1, typename A2, typename A3, | | template <typename R, typename A0, typename A1, typename A2, typename A3, | |
| typename A4, typename A5> | | typename A4, typename A5> | |
| class MockFunction<R(A0, A1, A2, A3, A4, A5)> { | | class MockFunction<R(A0, A1, A2, A3, A4, A5)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5)); | | MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1, typename A2, typename A3, | | template <typename R, typename A0, typename A1, typename A2, typename A3, | |
| typename A4, typename A5, typename A6> | | typename A4, typename A5, typename A6> | |
| class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> { | | class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6)); | | MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1, typename A2, typename A3, | | template <typename R, typename A0, typename A1, typename A2, typename A3, | |
| typename A4, typename A5, typename A6, typename A7> | | typename A4, typename A5, typename A6, typename A7> | |
| class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> { | | class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7)); | | MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1, typename A2, typename A3, | | template <typename R, typename A0, typename A1, typename A2, typename A3, | |
| typename A4, typename A5, typename A6, typename A7, typename A8> | | typename A4, typename A5, typename A6, typename A7, typename A8> | |
| class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> { | | class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8)); | | MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| template <typename R, typename A0, typename A1, typename A2, typename A3, | | template <typename R, typename A0, typename A1, typename A2, typename A3, | |
| typename A4, typename A5, typename A6, typename A7, typename A8, | | typename A4, typename A5, typename A6, typename A7, typename A8, | |
| typename A9> | | typename A9> | |
| class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> { | | class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> { | |
| public: | | public: | |
|
| | | MockFunction() {} | |
| | | | |
| MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)); | | MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)); | |
|
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction); | |
| }; | | }; | |
| | | | |
| } // namespace testing | | } // namespace testing | |
| | | | |
| #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ | | #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_ | |
| | | | |
End of changes. 34 change blocks. |
| 16 lines changed or deleted | | 113 lines changed or added | |
|
| gmock-generated-matchers.h | | gmock-generated-matchers.h | |
|
| // This file was GENERATED by a script. DO NOT EDIT BY HAND!!! | | // This file was GENERATED by command: | |
| | | // pump.py gmock-generated-matchers.h.pump | |
| | | // DO NOT EDIT BY HAND!!! | |
| | | | |
| // Copyright 2008, Google Inc. | | // Copyright 2008, Google Inc. | |
| // All rights reserved. | | // All rights reserved. | |
| // | | // | |
| // Redistribution and use in source and binary forms, with or without | | // Redistribution and use in source and binary forms, with or without | |
| // modification, are permitted provided that the following conditions are | | // modification, are permitted provided that the following conditions are | |
| // met: | | // met: | |
| // | | // | |
| // * Redistributions of source code must retain the above copyright | | // * Redistributions of source code must retain the above copyright | |
| // notice, this list of conditions and the following disclaimer. | | // notice, this list of conditions and the following disclaimer. | |
| | | | |
| skipping to change at line 92 | | skipping to change at line 94 | |
| get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t)); | | get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t)); | |
| } | | } | |
| }; | | }; | |
| | | | |
| // The following specialization is used for 0 ~ 9 selectors. | | // The following specialization is used for 0 ~ 9 selectors. | |
| | | | |
| template <class Tuple> | | template <class Tuple> | |
| class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> { | | class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> { | |
| public: | | public: | |
| typedef ::std::tr1::tuple<> type; | | typedef ::std::tr1::tuple<> type; | |
|
| static type GetSelectedFields(const Tuple& t) { | | static type GetSelectedFields(const Tuple& /* t */) { | |
| using ::std::tr1::get; | | using ::std::tr1::get; | |
| return type(); | | return type(); | |
| } | | } | |
| }; | | }; | |
| | | | |
| template <class Tuple, int k0> | | template <class Tuple, int k0> | |
| class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> { | | class TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> { | |
| public: | | public: | |
| typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type; | | typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type; | |
| static type GetSelectedFields(const Tuple& t) { | | static type GetSelectedFields(const Tuple& t) { | |
| | | | |
| skipping to change at line 232 | | skipping to change at line 234 | |
| // ArgsTuple may have top-level const or reference modifiers. | | // ArgsTuple may have top-level const or reference modifiers. | |
| typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(ArgsTuple)) RawArgsTu
ple; | | typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(ArgsTuple)) RawArgsTu
ple; | |
| typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4,
k5, | | typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4,
k5, | |
| k6, k7, k8, k9>::type SelectedArgs; | | k6, k7, k8, k9>::type SelectedArgs; | |
| typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher; | | typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher; | |
| | | | |
| template <typename InnerMatcher> | | template <typename InnerMatcher> | |
| explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher) | | explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher) | |
| : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher))
{} | | : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher))
{} | |
| | | | |
|
| virtual bool Matches(ArgsTuple args) const { | | virtual bool MatchAndExplain(ArgsTuple args, | |
| return inner_matcher_.Matches(GetSelectedArgs(args)); | | MatchResultListener* listener) const { | |
| | | const SelectedArgs& selected_args = GetSelectedArgs(args); | |
| | | if (!listener->IsInterested()) | |
| | | return inner_matcher_.Matches(selected_args); | |
| | | | |
| | | PrintIndices(listener->stream()); | |
| | | *listener << "are " << PrintToString(selected_args); | |
| | | | |
| | | StringMatchResultListener inner_listener; | |
| | | const bool match = inner_matcher_.MatchAndExplain(selected_args, | |
| | | &inner_listener); | |
| | | PrintIfNotEmpty(inner_listener.str(), listener->stream()); | |
| | | return match; | |
| } | | } | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
|
| | | *os << "are a tuple "; | |
| PrintIndices(os); | | PrintIndices(os); | |
| inner_matcher_.DescribeTo(os); | | inner_matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
|
| | | *os << "are a tuple "; | |
| PrintIndices(os); | | PrintIndices(os); | |
| inner_matcher_.DescribeNegationTo(os); | | inner_matcher_.DescribeNegationTo(os); | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(ArgsTuple args, | | | |
| ::std::ostream* os) const { | | | |
| inner_matcher_.ExplainMatchResultTo(GetSelectedArgs(args), os); | | | |
| } | | | |
| | | | |
| private: | | private: | |
| static SelectedArgs GetSelectedArgs(ArgsTuple args) { | | static SelectedArgs GetSelectedArgs(ArgsTuple args) { | |
| return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, | | return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, | |
| k9>::GetSelectedFields(args); | | k9>::GetSelectedFields(args); | |
| } | | } | |
| | | | |
| // Prints the indices of the selected fields. | | // Prints the indices of the selected fields. | |
| static void PrintIndices(::std::ostream* os) { | | static void PrintIndices(::std::ostream* os) { | |
|
| *os << "are a tuple whose fields ("; | | *os << "whose fields ("; | |
| const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 }; | | const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 }; | |
| for (int i = 0; i < 10; i++) { | | for (int i = 0; i < 10; i++) { | |
| if (indices[i] < 0) | | if (indices[i] < 0) | |
| break; | | break; | |
| | | | |
| if (i >= 1) | | if (i >= 1) | |
| *os << ", "; | | *os << ", "; | |
| | | | |
| *os << "#" << indices[i]; | | *os << "#" << indices[i]; | |
| } | | } | |
| *os << ") "; | | *os << ") "; | |
| } | | } | |
| | | | |
| const MonomorphicInnerMatcher inner_matcher_; | | const MonomorphicInnerMatcher inner_matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl); | |
| }; | | }; | |
| | | | |
| template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1, | | template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1, | |
| int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, | | int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, | |
| int k8 = -1, int k9 = -1> | | int k8 = -1, int k9 = -1> | |
| class ArgsMatcher { | | class ArgsMatcher { | |
| public: | | public: | |
| explicit ArgsMatcher(const InnerMatcher& inner_matcher) | | explicit ArgsMatcher(const InnerMatcher& inner_matcher) | |
| : inner_matcher_(inner_matcher) {} | | : inner_matcher_(inner_matcher) {} | |
| | | | |
| template <typename ArgsTuple> | | template <typename ArgsTuple> | |
| operator Matcher<ArgsTuple>() const { | | operator Matcher<ArgsTuple>() const { | |
| return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k
5, | | return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k
5, | |
| k6, k7, k8, k9>(inner_matcher_)); | | k6, k7, k8, k9>(inner_matcher_)); | |
| } | | } | |
| | | | |
|
| | | private: | |
| const InnerMatcher inner_matcher_; | | const InnerMatcher inner_matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ArgsMatcher); | |
| }; | | }; | |
| | | | |
| // Implements ElementsAre() of 1-10 arguments. | | // Implements ElementsAre() of 1-10 arguments. | |
| | | | |
| template <typename T1> | | template <typename T1> | |
| class ElementsAreMatcher1 { | | class ElementsAreMatcher1 { | |
| public: | | public: | |
| explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {} | | explicit ElementsAreMatcher1(const T1& e1) : e1_(e1) {} | |
| | | | |
| template <typename Container> | | template <typename Container> | |
| | | | |
| skipping to change at line 320 | | skipping to change at line 336 | |
| // added the linked_ptr in it to our other linked_ptrs list. | | // added the linked_ptr in it to our other linked_ptrs list. | |
| // Hence we implement ElementsAreMatcher1 specially to avoid using | | // Hence we implement ElementsAreMatcher1 specially to avoid using | |
| // a local array. | | // a local array. | |
| const Matcher<const Element&> matcher = | | const Matcher<const Element&> matcher = | |
| MatcherCast<const Element&>(e1_); | | MatcherCast<const Element&>(e1_); | |
| return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 1)); | | return MakeMatcher(new ElementsAreMatcherImpl<Container>(&matcher, 1)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2> | | template <typename T1, typename T2> | |
| class ElementsAreMatcher2 { | | class ElementsAreMatcher2 { | |
| public: | | public: | |
| ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {} | | ElementsAreMatcher2(const T1& e1, const T2& e2) : e1_(e1), e2_(e2) {} | |
| | | | |
| template <typename Container> | | template <typename Container> | |
| operator Matcher<Container>() const { | | operator Matcher<Container>() const { | |
| typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) | | typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) | |
| | | | |
| skipping to change at line 345 | | skipping to change at line 363 | |
| MatcherCast<const Element&>(e1_), | | MatcherCast<const Element&>(e1_), | |
| MatcherCast<const Element&>(e2_), | | MatcherCast<const Element&>(e2_), | |
| }; | | }; | |
| | | | |
| return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2)); | | return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 2)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2, typename T3> | | template <typename T1, typename T2, typename T3> | |
| class ElementsAreMatcher3 { | | class ElementsAreMatcher3 { | |
| public: | | public: | |
| ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1), | | ElementsAreMatcher3(const T1& e1, const T2& e2, const T3& e3) : e1_(e1), | |
| e2_(e2), e3_(e3) {} | | e2_(e2), e3_(e3) {} | |
| | | | |
| template <typename Container> | | template <typename Container> | |
| operator Matcher<Container>() const { | | operator Matcher<Container>() const { | |
| | | | |
| skipping to change at line 373 | | skipping to change at line 393 | |
| MatcherCast<const Element&>(e3_), | | MatcherCast<const Element&>(e3_), | |
| }; | | }; | |
| | | | |
| return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3)); | | return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 3)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
| const T3& e3_; | | const T3& e3_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2, typename T3, typename T4> | | template <typename T1, typename T2, typename T3, typename T4> | |
| class ElementsAreMatcher4 { | | class ElementsAreMatcher4 { | |
| public: | | public: | |
| ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3, | | ElementsAreMatcher4(const T1& e1, const T2& e2, const T3& e3, | |
| const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {} | | const T4& e4) : e1_(e1), e2_(e2), e3_(e3), e4_(e4) {} | |
| | | | |
| template <typename Container> | | template <typename Container> | |
| operator Matcher<Container>() const { | | operator Matcher<Container>() const { | |
| | | | |
| skipping to change at line 403 | | skipping to change at line 425 | |
| }; | | }; | |
| | | | |
| return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4)); | | return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 4)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
| const T3& e3_; | | const T3& e3_; | |
| const T4& e4_; | | const T4& e4_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2, typename T3, typename T4, typename T5> | | template <typename T1, typename T2, typename T3, typename T4, typename T5> | |
| class ElementsAreMatcher5 { | | class ElementsAreMatcher5 { | |
| public: | | public: | |
| ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | | ElementsAreMatcher5(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | |
| const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {} | | const T5& e5) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5) {} | |
| | | | |
| template <typename Container> | | template <typename Container> | |
| operator Matcher<Container>() const { | | operator Matcher<Container>() const { | |
| | | | |
| skipping to change at line 435 | | skipping to change at line 459 | |
| | | | |
| return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5)); | | return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 5)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
| const T3& e3_; | | const T3& e3_; | |
| const T4& e4_; | | const T4& e4_; | |
| const T5& e5_; | | const T5& e5_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2, typename T3, typename T4, typename T5, | | template <typename T1, typename T2, typename T3, typename T4, typename T5, | |
| typename T6> | | typename T6> | |
| class ElementsAreMatcher6 { | | class ElementsAreMatcher6 { | |
| public: | | public: | |
| ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | | ElementsAreMatcher6(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | |
| const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), | | const T5& e5, const T6& e6) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), | |
| e5_(e5), e6_(e6) {} | | e5_(e5), e6_(e6) {} | |
| | | | |
| | | | |
| skipping to change at line 471 | | skipping to change at line 497 | |
| return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 6)); | | return MakeMatcher(new ElementsAreMatcherImpl<Container>(matchers, 6)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
| const T3& e3_; | | const T3& e3_; | |
| const T4& e4_; | | const T4& e4_; | |
| const T5& e5_; | | const T5& e5_; | |
| const T6& e6_; | | const T6& e6_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2, typename T3, typename T4, typename T5, | | template <typename T1, typename T2, typename T3, typename T4, typename T5, | |
| typename T6, typename T7> | | typename T6, typename T7> | |
| class ElementsAreMatcher7 { | | class ElementsAreMatcher7 { | |
| public: | | public: | |
| ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | | ElementsAreMatcher7(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | |
| const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3)
, | | const T5& e5, const T6& e6, const T7& e7) : e1_(e1), e2_(e2), e3_(e3)
, | |
| e4_(e4), e5_(e5), e6_(e6), e7_(e7) {} | | e4_(e4), e5_(e5), e6_(e6), e7_(e7) {} | |
| | | | |
| | | | |
| skipping to change at line 509 | | skipping to change at line 537 | |
| } | | } | |
| | | | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
| const T3& e3_; | | const T3& e3_; | |
| const T4& e4_; | | const T4& e4_; | |
| const T5& e5_; | | const T5& e5_; | |
| const T6& e6_; | | const T6& e6_; | |
| const T7& e7_; | | const T7& e7_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2, typename T3, typename T4, typename T5, | | template <typename T1, typename T2, typename T3, typename T4, typename T5, | |
| typename T6, typename T7, typename T8> | | typename T6, typename T7, typename T8> | |
| class ElementsAreMatcher8 { | | class ElementsAreMatcher8 { | |
| public: | | public: | |
| ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | | ElementsAreMatcher8(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | |
| const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1), | | const T5& e5, const T6& e6, const T7& e7, const T8& e8) : e1_(e1), | |
| e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {} | | e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), e7_(e7), e8_(e8) {} | |
| | | | |
| | | | |
| skipping to change at line 549 | | skipping to change at line 579 | |
| | | | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
| const T3& e3_; | | const T3& e3_; | |
| const T4& e4_; | | const T4& e4_; | |
| const T5& e5_; | | const T5& e5_; | |
| const T6& e6_; | | const T6& e6_; | |
| const T7& e7_; | | const T7& e7_; | |
| const T8& e8_; | | const T8& e8_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2, typename T3, typename T4, typename T5, | | template <typename T1, typename T2, typename T3, typename T4, typename T5, | |
| typename T6, typename T7, typename T8, typename T9> | | typename T6, typename T7, typename T8, typename T9> | |
| class ElementsAreMatcher9 { | | class ElementsAreMatcher9 { | |
| public: | | public: | |
| ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | | ElementsAreMatcher9(const T1& e1, const T2& e2, const T3& e3, const T4& e
4, | |
| const T5& e5, const T6& e6, const T7& e7, const T8& e8, | | const T5& e5, const T6& e6, const T7& e7, const T8& e8, | |
| const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), | | const T9& e9) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6), | |
| e7_(e7), e8_(e8), e9_(e9) {} | | e7_(e7), e8_(e8), e9_(e9) {} | |
| | | | |
| skipping to change at line 592 | | skipping to change at line 624 | |
| private: | | private: | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
| const T3& e3_; | | const T3& e3_; | |
| const T4& e4_; | | const T4& e4_; | |
| const T5& e5_; | | const T5& e5_; | |
| const T6& e6_; | | const T6& e6_; | |
| const T7& e7_; | | const T7& e7_; | |
| const T8& e8_; | | const T8& e8_; | |
| const T9& e9_; | | const T9& e9_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9); | |
| }; | | }; | |
| | | | |
| template <typename T1, typename T2, typename T3, typename T4, typename T5, | | template <typename T1, typename T2, typename T3, typename T4, typename T5, | |
| typename T6, typename T7, typename T8, typename T9, typename T10> | | typename T6, typename T7, typename T8, typename T9, typename T10> | |
| class ElementsAreMatcher10 { | | class ElementsAreMatcher10 { | |
| public: | | public: | |
| ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4&
e4, | | ElementsAreMatcher10(const T1& e1, const T2& e2, const T3& e3, const T4&
e4, | |
| const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9, | | const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9, | |
| const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6
), | | const T10& e10) : e1_(e1), e2_(e2), e3_(e3), e4_(e4), e5_(e5), e6_(e6
), | |
| e7_(e7), e8_(e8), e9_(e9), e10_(e10) {} | | e7_(e7), e8_(e8), e9_(e9), e10_(e10) {} | |
| | | | |
| skipping to change at line 637 | | skipping to change at line 671 | |
| const T1& e1_; | | const T1& e1_; | |
| const T2& e2_; | | const T2& e2_; | |
| const T3& e3_; | | const T3& e3_; | |
| const T4& e4_; | | const T4& e4_; | |
| const T5& e5_; | | const T5& e5_; | |
| const T6& e6_; | | const T6& e6_; | |
| const T7& e7_; | | const T7& e7_; | |
| const T8& e8_; | | const T8& e8_; | |
| const T9& e9_; | | const T9& e9_; | |
| const T10& e10_; | | const T10& e10_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10); | |
| }; | | }; | |
| | | | |
| } // namespace internal | | } // namespace internal | |
| | | | |
| // Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected | | // Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected | |
| // fields of it matches a_matcher. C++ doesn't support default | | // fields of it matches a_matcher. C++ doesn't support default | |
| // arguments for function templates, so we have to overload it. | | // arguments for function templates, so we have to overload it. | |
| template <typename InnerMatcher> | | template <typename InnerMatcher> | |
| inline internal::ArgsMatcher<InnerMatcher> | | inline internal::ArgsMatcher<InnerMatcher> | |
| Args(const InnerMatcher& matcher) { | | Args(const InnerMatcher& matcher) { | |
| | | | |
| skipping to change at line 830 | | skipping to change at line 866 | |
| | | | |
| template <typename T, size_t N> | | template <typename T, size_t N> | |
| inline internal::ElementsAreArrayMatcher<T> | | inline internal::ElementsAreArrayMatcher<T> | |
| ElementsAreArray(const T (&array)[N]) { | | ElementsAreArray(const T (&array)[N]) { | |
| return internal::ElementsAreArrayMatcher<T>(array, N); | | return internal::ElementsAreArrayMatcher<T>(array, N); | |
| } | | } | |
| | | | |
| } // namespace testing | | } // namespace testing | |
| | | | |
| // The MATCHER* family of macros can be used in a namespace scope to | | // The MATCHER* family of macros can be used in a namespace scope to | |
|
| // define custom matchers easily. The syntax: | | // define custom matchers easily. | |
| | | // | |
| | | // Basic Usage | |
| | | // =========== | |
| | | // | |
| | | // The syntax | |
| // | | // | |
| // MATCHER(name, description_string) { statements; } | | // MATCHER(name, description_string) { statements; } | |
| // | | // | |
|
| // will define a matcher with the given name that executes the | | // defines a matcher with the given name that executes the statements, | |
| // statements, which must return a bool to indicate if the match | | // which must return a bool to indicate if the match succeeds. Inside | |
| // succeeds. Inside the statements, you can refer to the value being | | // the statements, you can refer to the value being matched by 'arg', | |
| // matched by 'arg', and refer to its type by 'arg_type'. | | // and refer to its type by 'arg_type'. | |
| // | | // | |
| // The description string documents what the matcher does, and is used | | // The description string documents what the matcher does, and is used | |
| // to generate the failure message when the match fails. Since a | | // to generate the failure message when the match fails. Since a | |
| // MATCHER() is usually defined in a header file shared by multiple | | // MATCHER() is usually defined in a header file shared by multiple | |
| // C++ source files, we require the description to be a C-string | | // C++ source files, we require the description to be a C-string | |
| // literal to avoid possible side effects. It can be empty, in which | | // literal to avoid possible side effects. It can be empty, in which | |
| // case we'll use the sequence of words in the matcher name as the | | // case we'll use the sequence of words in the matcher name as the | |
| // description. | | // description. | |
| // | | // | |
| // For example: | | // For example: | |
| | | | |
| skipping to change at line 870 | | skipping to change at line 911 | |
| // | | // | |
| // If the above assertion fails, it will print something like: | | // If the above assertion fails, it will print something like: | |
| // | | // | |
| // Value of: some_expression | | // Value of: some_expression | |
| // Expected: is even | | // Expected: is even | |
| // Actual: 7 | | // Actual: 7 | |
| // | | // | |
| // where the description "is even" is automatically calculated from the | | // where the description "is even" is automatically calculated from the | |
| // matcher name IsEven. | | // matcher name IsEven. | |
| // | | // | |
|
| | | // Argument Type | |
| | | // ============= | |
| | | // | |
| // Note that the type of the value being matched (arg_type) is | | // Note that the type of the value being matched (arg_type) is | |
| // determined by the context in which you use the matcher and is | | // determined by the context in which you use the matcher and is | |
| // supplied to you by the compiler, so you don't need to worry about | | // supplied to you by the compiler, so you don't need to worry about | |
| // declaring it (nor can you). This allows the matcher to be | | // declaring it (nor can you). This allows the matcher to be | |
| // polymorphic. For example, IsEven() can be used to match any type | | // polymorphic. For example, IsEven() can be used to match any type | |
| // where the value of "(arg % 2) == 0" can be implicitly converted to | | // where the value of "(arg % 2) == 0" can be implicitly converted to | |
| // a bool. In the "Bar(IsEven())" example above, if method Bar() | | // a bool. In the "Bar(IsEven())" example above, if method Bar() | |
| // takes an int, 'arg_type' will be int; if it takes an unsigned long, | | // takes an int, 'arg_type' will be int; if it takes an unsigned long, | |
| // 'arg_type' will be unsigned long; and so on. | | // 'arg_type' will be unsigned long; and so on. | |
| // | | // | |
|
| | | // Parameterizing Matchers | |
| | | // ======================= | |
| | | // | |
| // Sometimes you'll want to parameterize the matcher. For that you | | // Sometimes you'll want to parameterize the matcher. For that you | |
| // can use another macro: | | // can use another macro: | |
| // | | // | |
| // MATCHER_P(name, param_name, description_string) { statements; } | | // MATCHER_P(name, param_name, description_string) { statements; } | |
| // | | // | |
| // For example: | | // For example: | |
| // | | // | |
| // MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; } | | // MATCHER_P(HasAbsoluteValue, value, "") { return abs(arg) == value; } | |
| // | | // | |
| // will allow you to write: | | // will allow you to write: | |
| | | | |
| skipping to change at line 910 | | skipping to change at line 957 | |
| // printed, making the message human-friendly. | | // printed, making the message human-friendly. | |
| // | | // | |
| // In the matcher definition body, you can write 'foo_type' to | | // In the matcher definition body, you can write 'foo_type' to | |
| // reference the type of a parameter named 'foo'. For example, in the | | // reference the type of a parameter named 'foo'. For example, in the | |
| // body of MATCHER_P(HasAbsoluteValue, value) above, you can write | | // body of MATCHER_P(HasAbsoluteValue, value) above, you can write | |
| // 'value_type' to refer to the type of 'value'. | | // 'value_type' to refer to the type of 'value'. | |
| // | | // | |
| // We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to | | // We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to | |
| // support multi-parameter matchers. | | // support multi-parameter matchers. | |
| // | | // | |
|
| | | // Describing Parameterized Matchers | |
| | | // ================================= | |
| | | // | |
| // When defining a parameterized matcher, you can use Python-style | | // When defining a parameterized matcher, you can use Python-style | |
| // interpolations in the description string to refer to the parameter | | // interpolations in the description string to refer to the parameter | |
| // values. We support the following syntax currently: | | // values. We support the following syntax currently: | |
| // | | // | |
| // %% a single '%' character | | // %% a single '%' character | |
| // %(*)s all parameters of the matcher printed as a tuple | | // %(*)s all parameters of the matcher printed as a tuple | |
| // %(foo)s value of the matcher parameter named 'foo' | | // %(foo)s value of the matcher parameter named 'foo' | |
| // | | // | |
| // For example, | | // For example, | |
| // | | // | |
| | | | |
| skipping to change at line 942 | | skipping to change at line 992 | |
| // parameter values printed as a tuple. For example, | | // parameter values printed as a tuple. For example, | |
| // | | // | |
| // MATCHER_P2(InClosedRange, low, hi, "") { ... } | | // MATCHER_P2(InClosedRange, low, hi, "") { ... } | |
| // ... | | // ... | |
| // EXPECT_THAT(3, InClosedRange(4, 6)); | | // EXPECT_THAT(3, InClosedRange(4, 6)); | |
| // | | // | |
| // would generate a failure that contains the text: | | // would generate a failure that contains the text: | |
| // | | // | |
| // Expected: in closed range (4, 6) | | // Expected: in closed range (4, 6) | |
| // | | // | |
|
| | | // Types of Matcher Parameters | |
| | | // =========================== | |
| | | // | |
| // For the purpose of typing, you can view | | // For the purpose of typing, you can view | |
| // | | // | |
| // MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... } | | // MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... } | |
| // | | // | |
| // as shorthand for | | // as shorthand for | |
| // | | // | |
| // template <typename p1_type, ..., typename pk_type> | | // template <typename p1_type, ..., typename pk_type> | |
| // FooMatcherPk<p1_type, ..., pk_type> | | // FooMatcherPk<p1_type, ..., pk_type> | |
| // Foo(p1_type p1, ..., pk_type pk) { ... } | | // Foo(p1_type p1, ..., pk_type pk) { ... } | |
| // | | // | |
| | | | |
| skipping to change at line 969 | | skipping to change at line 1022 | |
| // to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This | | // to a variable of type FooMatcherPk<p1_type, ..., pk_type>. This | |
| // can be useful when composing matchers. | | // can be useful when composing matchers. | |
| // | | // | |
| // While you can instantiate a matcher template with reference types, | | // While you can instantiate a matcher template with reference types, | |
| // passing the parameters by pointer usually makes your code more | | // passing the parameters by pointer usually makes your code more | |
| // readable. If, however, you still want to pass a parameter by | | // readable. If, however, you still want to pass a parameter by | |
| // reference, be aware that in the failure message generated by the | | // reference, be aware that in the failure message generated by the | |
| // matcher you will see the value of the referenced object but not its | | // matcher you will see the value of the referenced object but not its | |
| // address. | | // address. | |
| // | | // | |
|
| | | // Explaining Match Results | |
| | | // ======================== | |
| | | // | |
| | | // Sometimes the matcher description alone isn't enough to explain why | |
| | | // the match has failed or succeeded. For example, when expecting a | |
| | | // long string, it can be very helpful to also print the diff between | |
| | | // the expected string and the actual one. To achieve that, you can | |
| | | // optionally stream additional information to a special variable | |
| | | // named result_listener, whose type is a pointer to class | |
| | | // MatchResultListener: | |
| | | // | |
| | | // MATCHER_P(EqualsLongString, str, "") { | |
| | | // if (arg == str) return true; | |
| | | // | |
| | | // *result_listener << "the difference: " | |
| | | /// << DiffStrings(str, arg); | |
| | | // return false; | |
| | | // } | |
| | | // | |
| | | // Overloading Matchers | |
| | | // ==================== | |
| | | // | |
| // You can overload matchers with different numbers of parameters: | | // You can overload matchers with different numbers of parameters: | |
| // | | // | |
| // MATCHER_P(Blah, a, description_string1) { ... } | | // MATCHER_P(Blah, a, description_string1) { ... } | |
| // MATCHER_P2(Blah, a, b, description_string2) { ... } | | // MATCHER_P2(Blah, a, b, description_string2) { ... } | |
| // | | // | |
|
| // While it's tempting to always use the MATCHER* macros when defining | | // Caveats | |
| // a new matcher, you should also consider implementing | | // ======= | |
| // MatcherInterface or using MakePolymorphicMatcher() instead, | | | |
| // especially if you need to use the matcher a lot. While these | | | |
| // approaches require more work, they give you more control on the | | | |
| // types of the value being matched and the matcher parameters, which | | | |
| // in general leads to better compiler error messages that pay off in | | | |
| // the long run. They also allow overloading matchers based on | | | |
| // parameter types (as opposed to just based on the number of | | | |
| // parameters). | | | |
| // | | // | |
|
| // CAVEAT: | | // When defining a new matcher, you should also consider implementing | |
| | | // MatcherInterface or using MakePolymorphicMatcher(). These | |
| | | // approaches require more work than the MATCHER* macros, but also | |
| | | // give you more control on the types of the value being matched and | |
| | | // the matcher parameters, which may leads to better compiler error | |
| | | // messages when the matcher is used wrong. They also allow | |
| | | // overloading matchers based on parameter types (as opposed to just | |
| | | // based on the number of parameters). | |
| // | | // | |
| // MATCHER*() can only be used in a namespace scope. The reason is | | // MATCHER*() can only be used in a namespace scope. The reason is | |
| // that C++ doesn't yet allow function-local types to be used to | | // that C++ doesn't yet allow function-local types to be used to | |
| // instantiate templates. The up-coming C++0x standard will fix this. | | // instantiate templates. The up-coming C++0x standard will fix this. | |
| // Once that's done, we'll consider supporting using MATCHER*() inside | | // Once that's done, we'll consider supporting using MATCHER*() inside | |
| // a function. | | // a function. | |
| // | | // | |
|
| // MORE INFORMATION: | | // More Information | |
| | | // ================ | |
| // | | // | |
| // To learn more about using these macros, please search for 'MATCHER' | | // To learn more about using these macros, please search for 'MATCHER' | |
| // on http://code.google.com/p/googlemock/wiki/CookBook. | | // on http://code.google.com/p/googlemock/wiki/CookBook. | |
| | | | |
| #define MATCHER(name, description)\ | | #define MATCHER(name, description)\ | |
| class name##Matcher {\ | | class name##Matcher {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(const ::testing::internal::Interpolations& gmock_interp)\ | | gmock_Impl(const ::testing::internal::Interpolations& gmock_interp)\ | |
| : gmock_interp_(gmock_interp) {}\ | | : gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<>());\ | | ::std::tr1::tuple<>());\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(gmock_interp_));\ | | new gmock_Impl<arg_type>(gmock_interp_));\ | |
| }\ | | }\ | |
| name##Matcher() {\ | | name##Matcher() {\ | |
| const char* gmock_param_names[] = { NULL };\ | | const char* gmock_param_names[] = { NULL };\ | |
| gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | | gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##Matcher);\ | |
| };\ | | };\ | |
| inline name##Matcher name() {\ | | inline name##Matcher name() {\ | |
| return name##Matcher();\ | | return name##Matcher();\ | |
| }\ | | }\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
|
| bool name##Matcher::\ | | bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P(name, p0, description)\ | | #define MATCHER_P(name, p0, description)\ | |
| template <typename p0##_type>\ | | template <typename p0##_type>\ | |
| class name##MatcherP {\ | | class name##MatcherP {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| explicit gmock_Impl(p0##_type gmock_p0, \ | | explicit gmock_Impl(p0##_type gmock_p0, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), gmock_interp_(gmock_interp) {}\ | | : p0(gmock_p0), gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type>(p0));\ | | ::std::tr1::tuple<p0##_type>(p0));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, gmock_interp_));\ | | new gmock_Impl<arg_type>(p0, gmock_interp_));\ | |
| }\ | | }\ | |
| name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\ | | name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\ | |
| const char* gmock_param_names[] = { #p0, NULL };\ | | const char* gmock_param_names[] = { #p0, NULL };\ | |
| gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | | gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP);\ | |
| };\ | | };\ | |
| template <typename p0##_type>\ | | template <typename p0##_type>\ | |
| inline name##MatcherP<p0##_type> name(p0##_type p0) {\ | | inline name##MatcherP<p0##_type> name(p0##_type p0) {\ | |
| return name##MatcherP<p0##_type>(p0);\ | | return name##MatcherP<p0##_type>(p0);\ | |
| }\ | | }\ | |
| template <typename p0##_type>\ | | template <typename p0##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
|
| bool name##MatcherP<p0##_type>::\ | | bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P2(name, p0, p1, description)\ | | #define MATCHER_P2(name, p0, p1, description)\ | |
| template <typename p0##_type, typename p1##_type>\ | | template <typename p0##_type, typename p1##_type>\ | |
| class name##MatcherP2 {\ | | class name##MatcherP2 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), gmock_interp_(gmock_interp) {}\ | | : p0(gmock_p0), p1(gmock_p1), gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1));\ | | ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, gmock_interp_));\ | | new gmock_Impl<arg_type>(p0, p1, gmock_interp_));\ | |
| }\ | | }\ | |
| name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0),
\ | | name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0),
\ | |
| p1(gmock_p1) {\ | | p1(gmock_p1) {\ | |
| const char* gmock_param_names[] = { #p0, #p1, NULL };\ | | const char* gmock_param_names[] = { #p0, #p1, NULL };\ | |
| gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | | gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type>\ | | template <typename p0##_type, typename p1##_type>\ | |
| inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \ | | inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \ | |
| p1##_type p1) {\ | | p1##_type p1) {\ | |
| return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\ | | return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type>\ | | template <typename p0##_type, typename p1##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
|
| bool name##MatcherP2<p0##_type, p1##_type>::\ | | bool name##MatcherP2<p0##_type, \ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P3(name, p0, p1, p2, description)\ | | #define MATCHER_P3(name, p0, p1, p2, description)\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type>\ | | template <typename p0##_type, typename p1##_type, typename p2##_type>\ | |
| class name##MatcherP3 {\ | | class name##MatcherP3 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \ | | : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \ | |
| gmock_interp_(gmock_interp) {}\ | | gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1,
\ | | ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1,
\ | |
| p2));\ | | p2));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, p2, gmock_interp_));\ | | new gmock_Impl<arg_type>(p0, p1, p2, gmock_interp_));\ | |
| }\ | | }\ | |
| name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \ | | name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\ | | p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\ | |
| const char* gmock_param_names[] = { #p0, #p1, #p2, NULL };\ | | const char* gmock_param_names[] = { #p0, #p1, #p2, NULL };\ | |
| gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | | gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type>\ | | template <typename p0##_type, typename p1##_type, typename p2##_type>\ | |
| inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0
, \ | | inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0
, \ | |
| p1##_type p1, p2##_type p2) {\ | | p1##_type p1, p2##_type p2) {\ | |
| return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\ | | return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type>\ | | template <typename p0##_type, typename p1##_type, typename p2##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
|
| bool name##MatcherP3<p0##_type, p1##_type, p2##_type>::\ | | bool name##MatcherP3<p0##_type, p1##_type, \ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P4(name, p0, p1, p2, p3, description)\ | | #define MATCHER_P4(name, p0, p1, p2, p3, description)\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type>\ | | typename p3##_type>\ | |
| class name##MatcherP4 {\ | | class name##MatcherP4 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | |
| p3##_type gmock_p3, \ | | p3##_type gmock_p3, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | | : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | |
| gmock_interp_(gmock_interp) {}\ | | gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \ | | ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \ | |
| p3##_type>(p0, p1, p2, p3));\ | | p3##_type>(p0, p1, p2, p3));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, p2, p3, gmock_interp_));\ | | new gmock_Impl<arg_type>(p0, p1, p2, p3, gmock_interp_));\ | |
| }\ | | }\ | |
| name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \ | | name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1
), \ | | p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1
), \ | |
| p2(gmock_p2), p3(gmock_p3) {\ | | p2(gmock_p2), p3(gmock_p3) {\ | |
| const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, NULL };\ | | const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, NULL };\ | |
| gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | | gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type>\ | | typename p3##_type>\ | |
| inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \ | | inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \ | |
| p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \ | | p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \ | |
| p3##_type p3) {\ | | p3##_type p3) {\ | |
| return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0,
\ | | return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0,
\ | |
| p1, p2, p3);\ | | p1, p2, p3);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type>\ | | typename p3##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
|
| bool name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>::\ | | bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\ | | #define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type>\ | | typename p3##_type, typename p4##_type>\ | |
| class name##MatcherP5 {\ | | class name##MatcherP5 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | |
| p3##_type gmock_p3, p4##_type gmock_p4, \ | | p3##_type gmock_p3, p4##_type gmock_p4, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | | : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | |
| p4(gmock_p4), gmock_interp_(gmock_interp) {}\ | | p4(gmock_p4), gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | | ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | |
| p4##_type>(p0, p1, p2, p3, p4));\ | | p4##_type>(p0, p1, p2, p3, p4));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, gmock_interp_));\ | | new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, gmock_interp_));\ | |
| }\ | | }\ | |
| name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \ | | name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| p2##_type gmock_p2, p3##_type gmock_p3, \ | | p2##_type gmock_p2, p3##_type gmock_p3, \ | |
| p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \ | | p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \ | |
| p3(gmock_p3), p4(gmock_p4) {\ | | p3(gmock_p3), p4(gmock_p4) {\ | |
| const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, NULL };\ | | const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, NULL };\ | |
| gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | | gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type>\ | | typename p3##_type, typename p4##_type>\ | |
| inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | | p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | |
| p4##_type p4) {\ | | p4##_type p4) {\ | |
| return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type>(p0, p1, p2, p3, p4);\ | | p4##_type>(p0, p1, p2, p3, p4);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type>\ | | typename p3##_type, typename p4##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
|
| bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ | | bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| e>::\ | | p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\ | | #define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type>\ | | typename p3##_type, typename p4##_type, typename p5##_type>\ | |
| class name##MatcherP6 {\ | | class name##MatcherP6 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | |
| p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | | : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | |
| p4(gmock_p4), p5(gmock_p5), gmock_interp_(gmock_interp) {}\ | | p4(gmock_p4), p5(gmock_p5), gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | | ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | |
| p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5));\ | | p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, gmock_interp_));
\ | | new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, gmock_interp_));
\ | |
| }\ | | }\ | |
| name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \ | | name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | |
| p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \ | | p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \ | |
| p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\ | | p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\ | |
| const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, NUL
L };\ | | const char* gmock_param_names[] = { #p0, #p1, #p2, #p3, #p4, #p5, NUL
L };\ | |
| gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | | gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type>\ | | typename p3##_type, typename p4##_type, typename p5##_type>\ | |
| inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2,
\ | | p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2,
\ | |
| p3##_type p3, p4##_type p4, p5##_type p5) {\ | | p3##_type p3, p4##_type p4, p5##_type p5) {\ | |
| return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\ | | p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type>\ | | typename p3##_type, typename p4##_type, typename p5##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \ | | bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \ | |
|
| p5##_type>::\ | | p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\ | | #define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type>\ | | typename p6##_type>\ | |
| class name##MatcherP7 {\ | | class name##MatcherP7 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | |
| p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | |
| p6##_type gmock_p6, \ | | p6##_type gmock_p6, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | | : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | |
| p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \ | | p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \ | |
| gmock_interp_(gmock_interp) {}\ | | gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | | ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | |
| p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5
, \ | | p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5
, \ | |
| p6));\ | | p6));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, gmock_interp
_));\ | | new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, gmock_interp
_));\ | |
| }\ | | }\ | |
| name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \ | | name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | |
| p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1
), \ | | p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1
), \ | |
| p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \ | | p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \ | |
| | | | |
| skipping to change at line 1422 | | skipping to change at line 1553 | |
| gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | | gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\ | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type>\ | | typename p6##_type>\ | |
| inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \ | | p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \ | |
| p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ | | p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \ | |
| p6##_type p6) {\ | | p6##_type p6) {\ | |
| return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\ | | p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type>\ | | typename p6##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \ | | bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \ | |
|
| p5##_type, p6##_type>::\ | | p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\ | | #define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type>\ | | typename p6##_type, typename p7##_type>\ | |
| class name##MatcherP8 {\ | | class name##MatcherP8 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | |
| p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | |
| p6##_type gmock_p6, p7##_type gmock_p7, \ | | p6##_type gmock_p6, p7##_type gmock_p7, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | | : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | |
| p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \ | | p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \ | |
| gmock_interp_(gmock_interp) {}\ | | gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | | ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2,
\ | | p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2,
\ | |
| p3, p4, p5, p6, p7));\ | | p3, p4, p5, p6, p7));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, \ | | new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, \ | |
| gmock_interp_));\ | | gmock_interp_));\ | |
| }\ | | }\ | |
| name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \ | | name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | |
| p5##_type gmock_p5, p6##_type gmock_p6, \ | | p5##_type gmock_p5, p6##_type gmock_p6, \ | |
| | | | |
| skipping to change at line 1503 | | skipping to change at line 1641 | |
| gmock_param_names, ("" description ""));\ | | gmock_param_names, ("" description ""));\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type>\ | | typename p6##_type, typename p7##_type>\ | |
| inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \ | | p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \ | |
| p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5,
\ | | p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5,
\ | |
| p6##_type p6, p7##_type p7) {\ | | p6##_type p6, p7##_type p7) {\ | |
| return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5,
\ | | p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5,
\ | |
| p6, p7);\ | | p6, p7);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type>\ | | typename p6##_type, typename p7##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \ | | bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \ | |
|
| p5##_type, p6##_type, p7##_type>::\ | | p5##_type, p6##_type, \ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\ | | #define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type, typename p8##_type>\ | | typename p6##_type, typename p7##_type, typename p8##_type>\ | |
| class name##MatcherP9 {\ | | class name##MatcherP9 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | |
| p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | |
| p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ | | p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | | : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | |
| p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \ | | p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \ | |
| p8(gmock_p8), gmock_interp_(gmock_interp) {}\ | | p8(gmock_p8), gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | | ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type, \ | | p4##_type, p5##_type, p6##_type, p7##_type, \ | |
| p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\ | | p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| p8##_type p8;\ | | p8##_type p8;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, \ | | new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, \ | |
| gmock_interp_));\ | | gmock_interp_));\ | |
| }\ | | }\ | |
| name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \ | | name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | |
| p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ | | p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ | |
| | | | |
| skipping to change at line 1587 | | skipping to change at line 1733 | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| p8##_type p8;\ | | p8##_type p8;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type, typename p8##_type>\ | | typename p6##_type, typename p7##_type, typename p8##_type>\ | |
| inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type, \ | | p4##_type, p5##_type, p6##_type, p7##_type, \ | |
| p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | | p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | |
| p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ | | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \ | |
| p8##_type p8) {\ | | p8##_type p8) {\ | |
| return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2,
\ | | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2,
\ | |
| p3, p4, p5, p6, p7, p8);\ | | p3, p4, p5, p6, p7, p8);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type, typename p8##_type>\ | | typename p6##_type, typename p7##_type, typename p8##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \ | | bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_typ
e, \ | |
|
| p5##_type, p6##_type, p7##_type, p8##_type>::\ | | p5##_type, p6##_type, p7##_type, \ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, descripti
on)\ | | #define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, descripti
on)\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type, typename p8##_type, \ | | typename p6##_type, typename p7##_type, typename p8##_type, \ | |
| typename p9##_type>\ | | typename p9##_type>\ | |
| class name##MatcherP10 {\ | | class name##MatcherP10 {\ | |
| public:\ | | public:\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | | class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\ | |
| public:\ | | public:\ | |
| gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | | gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2
, \ | |
| p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | | p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \ | |
| p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ | | p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \ | |
| p9##_type gmock_p9, \ | | p9##_type gmock_p9, \ | |
| const ::testing::internal::Interpolations& gmock_interp)\ | | const ::testing::internal::Interpolations& gmock_interp)\ | |
| : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | | : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \ | |
| p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \ | | p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \ | |
| p8(gmock_p8), p9(gmock_p9), gmock_interp_(gmock_interp) {}\ | | p8(gmock_p8), p9(gmock_p9), gmock_interp_(gmock_interp) {}\ | |
|
| virtual bool Matches(arg_type arg) const;\ | | virtual bool MatchAndExplain(\ | |
| | | arg_type arg, ::testing::MatchResultListener* result_listener) co | |
| | | nst;\ | |
| virtual void DescribeTo(::std::ostream* gmock_os) const {\ | | virtual void DescribeTo(::std::ostream* gmock_os) const {\ | |
| const ::testing::internal::Strings& gmock_printed_params = \ | | const ::testing::internal::Strings& gmock_printed_params = \ | |
| ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | | ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\ | |
| ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | | ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_typ
e, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type, p8##_type,
\ | | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type,
\ | |
| p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\ | | p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\ | |
| *gmock_os << ::testing::internal::FormatMatcherDescription(\ | | *gmock_os << ::testing::internal::FormatMatcherDescription(\ | |
| #name, description, gmock_interp_, gmock_printed_param
s);\ | | #name, description, gmock_interp_, gmock_printed_param
s);\ | |
| }\ | | }\ | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| p8##_type p8;\ | | p8##_type p8;\ | |
| p9##_type p9;\ | | p9##_type p9;\ | |
| const ::testing::internal::Interpolations gmock_interp_;\ | | const ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | private:\ | |
| | | GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ | |
| };\ | | };\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| operator ::testing::Matcher<arg_type>() const {\ | | operator ::testing::Matcher<arg_type>() const {\ | |
| return ::testing::Matcher<arg_type>(\ | | return ::testing::Matcher<arg_type>(\ | |
| new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9,
\ | | new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9,
\ | |
| gmock_interp_));\ | | gmock_interp_));\ | |
| }\ | | }\ | |
| name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \ | | name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \ | |
| p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | | p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \ | |
| p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ | | p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \ | |
| | | | |
| skipping to change at line 1676 | | skipping to change at line 1830 | |
| p0##_type p0;\ | | p0##_type p0;\ | |
| p1##_type p1;\ | | p1##_type p1;\ | |
| p2##_type p2;\ | | p2##_type p2;\ | |
| p3##_type p3;\ | | p3##_type p3;\ | |
| p4##_type p4;\ | | p4##_type p4;\ | |
| p5##_type p5;\ | | p5##_type p5;\ | |
| p6##_type p6;\ | | p6##_type p6;\ | |
| p7##_type p7;\ | | p7##_type p7;\ | |
| p8##_type p8;\ | | p8##_type p8;\ | |
| p9##_type p9;\ | | p9##_type p9;\ | |
|
| | | private:\ | |
| ::testing::internal::Interpolations gmock_interp_;\ | | ::testing::internal::Interpolations gmock_interp_;\ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\ | |
| };\ | | };\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type, typename p8##_type, \ | | typename p6##_type, typename p7##_type, typename p8##_type, \ | |
| typename p9##_type>\ | | typename p9##_type>\ | |
| inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \ | | inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \ | | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \ | |
| p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | | p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p
3, \ | |
| p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8,
\ | | p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8,
\ | |
| p9##_type p9) {\ | | p9##_type p9) {\ | |
| return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \ | | return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
| p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p
0, \ | | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p
0, \ | |
| p1, p2, p3, p4, p5, p6, p7, p8, p9);\ | | p1, p2, p3, p4, p5, p6, p7, p8, p9);\ | |
| }\ | | }\ | |
| template <typename p0##_type, typename p1##_type, typename p2##_type, \ | | template <typename p0##_type, typename p1##_type, typename p2##_type, \ | |
| typename p3##_type, typename p4##_type, typename p5##_type, \ | | typename p3##_type, typename p4##_type, typename p5##_type, \ | |
| typename p6##_type, typename p7##_type, typename p8##_type, \ | | typename p6##_type, typename p7##_type, typename p8##_type, \ | |
| typename p9##_type>\ | | typename p9##_type>\ | |
| template <typename arg_type>\ | | template <typename arg_type>\ | |
| bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \ | | bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \ | |
|
| p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>::\ | | p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \ | |
| gmock_Impl<arg_type>::Matches(arg_type arg) const | | p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\ | |
| | | arg_type arg,\ | |
| | | ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSE | |
| | | D_)\ | |
| | | const | |
| | | | |
| #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ | | #endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_ | |
| | | | |
End of changes. 85 change blocks. |
| 61 lines changed or deleted | | 241 lines changed or added | |
|
| gmock-matchers.h | | gmock-matchers.h | |
| | | | |
| skipping to change at line 67 | | skipping to change at line 67 | |
| // MatcherInterface<T> interface, and | | // MatcherInterface<T> interface, and | |
| // 2. a factory function that creates a Matcher<T> object from a | | // 2. a factory function that creates a Matcher<T> object from a | |
| // FooMatcherImpl*. | | // FooMatcherImpl*. | |
| // | | // | |
| // The two-level delegation design makes it possible to allow a user | | // The two-level delegation design makes it possible to allow a user | |
| // to write "v" instead of "Eq(v)" where a Matcher is expected, which | | // to write "v" instead of "Eq(v)" where a Matcher is expected, which | |
| // is impossible if we pass matchers by pointers. It also eases | | // is impossible if we pass matchers by pointers. It also eases | |
| // ownership management as Matcher objects can now be copied like | | // ownership management as Matcher objects can now be copied like | |
| // plain values. | | // plain values. | |
| | | | |
|
| | | // MatchResultListener is an abstract class. Its << operator can be | |
| | | // used by a matcher to explain why a value matches or doesn't match. | |
| | | // | |
| | | // TODO(wan@google.com): add method | |
| | | // bool InterestedInWhy(bool result) const; | |
| | | // to indicate whether the listener is interested in why the match | |
| | | // result is 'result'. | |
| | | class MatchResultListener { | |
| | | public: | |
| | | // Creates a listener object with the given underlying ostream. The | |
| | | // listener does not own the ostream. | |
| | | explicit MatchResultListener(::std::ostream* os) : stream_(os) {} | |
| | | virtual ~MatchResultListener() = 0; // Makes this class abstract. | |
| | | | |
| | | // Streams x to the underlying ostream; does nothing if the ostream | |
| | | // is NULL. | |
| | | template <typename T> | |
| | | MatchResultListener& operator<<(const T& x) { | |
| | | if (stream_ != NULL) | |
| | | *stream_ << x; | |
| | | return *this; | |
| | | } | |
| | | | |
| | | // Returns the underlying ostream. | |
| | | ::std::ostream* stream() { return stream_; } | |
| | | | |
| | | // Returns true iff the listener is interested in an explanation of | |
| | | // the match result. A matcher's MatchAndExplain() method can use | |
| | | // this information to avoid generating the explanation when no one | |
| | | // intends to hear it. | |
| | | bool IsInterested() const { return stream_ != NULL; } | |
| | | | |
| | | private: | |
| | | ::std::ostream* const stream_; | |
| | | | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener); | |
| | | }; | |
| | | | |
| | | inline MatchResultListener::~MatchResultListener() { | |
| | | } | |
| | | | |
| // The implementation of a matcher. | | // The implementation of a matcher. | |
| template <typename T> | | template <typename T> | |
| class MatcherInterface { | | class MatcherInterface { | |
| public: | | public: | |
| virtual ~MatcherInterface() {} | | virtual ~MatcherInterface() {} | |
| | | | |
|
| // Returns true iff the matcher matches x. | | // Returns true iff the matcher matches x; also explains the match | |
| virtual bool Matches(T x) const = 0; | | // result to 'listener', in the form of a non-restrictive relative | |
| | | // clause ("which ...", "whose ...", etc) that describes x. For | |
| | | // example, the MatchAndExplain() method of the Pointee(...) matcher | |
| | | // should generate an explanation like "which points to ...". | |
| | | // | |
| | | // You should override this method when defining a new matcher. | |
| | | // | |
| | | // It's the responsibility of the caller (Google Mock) to guarantee | |
| | | // that 'listener' is not NULL. This helps to simplify a matcher's | |
| | | // implementation when it doesn't care about the performance, as it | |
| | | // can talk to 'listener' without checking its validity first. | |
| | | // However, in order to implement dummy listeners efficiently, | |
| | | // listener->stream() may be NULL. | |
| | | virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = | |
| | | 0; | |
| | | | |
|
| // Describes this matcher to an ostream. | | // Describes this matcher to an ostream. The function should print | |
| | | // a verb phrase that describes the property a value matching this | |
| | | // matcher should have. The subject of the verb phrase is the value | |
| | | // being matched. For example, the DescribeTo() method of the Gt(7) | |
| | | // matcher prints "is greater than 7". | |
| virtual void DescribeTo(::std::ostream* os) const = 0; | | virtual void DescribeTo(::std::ostream* os) const = 0; | |
| | | | |
| // Describes the negation of this matcher to an ostream. For | | // Describes the negation of this matcher to an ostream. For | |
| // example, if the description of this matcher is "is greater than | | // example, if the description of this matcher is "is greater than | |
| // 7", the negated description could be "is not greater than 7". | | // 7", the negated description could be "is not greater than 7". | |
| // You are not required to override this when implementing | | // You are not required to override this when implementing | |
| // MatcherInterface, but it is highly advised so that your matcher | | // MatcherInterface, but it is highly advised so that your matcher | |
| // can produce good error messages. | | // can produce good error messages. | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "not ("; | | *os << "not ("; | |
| DescribeTo(os); | | DescribeTo(os); | |
| *os << ")"; | | *os << ")"; | |
| } | | } | |
|
| | | | |
| // Explains why x matches, or doesn't match, the matcher. Override | | | |
| // this to provide any additional information that helps a user | | | |
| // understand the match result. | | | |
| virtual void ExplainMatchResultTo(T /* x */, ::std::ostream* /* os */) co | | | |
| nst { | | | |
| // By default, nothing more needs to be explained, as Google Mock | | | |
| // has already printed the value of x when this function is | | | |
| // called. | | | |
| } | | | |
| }; | | }; | |
| | | | |
| namespace internal { | | namespace internal { | |
| | | | |
|
| | | // A match result listener that ignores the explanation. | |
| | | class DummyMatchResultListener : public MatchResultListener { | |
| | | public: | |
| | | DummyMatchResultListener() : MatchResultListener(NULL) {} | |
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener); | |
| | | }; | |
| | | | |
| | | // A match result listener that forwards the explanation to a given | |
| | | // ostream. The difference between this and MatchResultListener is | |
| | | // that the former is concrete. | |
| | | class StreamMatchResultListener : public MatchResultListener { | |
| | | public: | |
| | | explicit StreamMatchResultListener(::std::ostream* os) | |
| | | : MatchResultListener(os) {} | |
| | | | |
| | | private: | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener); | |
| | | }; | |
| | | | |
| | | // A match result listener that stores the explanation in a string. | |
| | | class StringMatchResultListener : public MatchResultListener { | |
| | | public: | |
| | | StringMatchResultListener() : MatchResultListener(&ss_) {} | |
| | | | |
| | | // Returns the explanation heard so far. | |
| | | internal::string str() const { return ss_.str(); } | |
| | | | |
| | | private: | |
| | | ::std::stringstream ss_; | |
| | | | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener); | |
| | | }; | |
| | | | |
| // An internal class for implementing Matcher<T>, which will derive | | // An internal class for implementing Matcher<T>, which will derive | |
| // from it. We put functionalities common to all Matcher<T> | | // from it. We put functionalities common to all Matcher<T> | |
| // specializations here to avoid code duplication. | | // specializations here to avoid code duplication. | |
| template <typename T> | | template <typename T> | |
| class MatcherBase { | | class MatcherBase { | |
| public: | | public: | |
|
| | | // Returns true iff the matcher matches x; also explains the match | |
| | | // result to 'listener'. | |
| | | bool MatchAndExplain(T x, MatchResultListener* listener) const { | |
| | | return impl_->MatchAndExplain(x, listener); | |
| | | } | |
| | | | |
| // Returns true iff this matcher matches x. | | // Returns true iff this matcher matches x. | |
|
| bool Matches(T x) const { return impl_->Matches(x); } | | bool Matches(T x) const { | |
| | | DummyMatchResultListener dummy; | |
| | | return MatchAndExplain(x, &dummy); | |
| | | } | |
| | | | |
| // Describes this matcher to an ostream. | | // Describes this matcher to an ostream. | |
| void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); } | | void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); } | |
| | | | |
| // Describes the negation of this matcher to an ostream. | | // Describes the negation of this matcher to an ostream. | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| impl_->DescribeNegationTo(os); | | impl_->DescribeNegationTo(os); | |
| } | | } | |
| | | | |
| // Explains why x matches, or doesn't match, the matcher. | | // Explains why x matches, or doesn't match, the matcher. | |
| void ExplainMatchResultTo(T x, ::std::ostream* os) const { | | void ExplainMatchResultTo(T x, ::std::ostream* os) const { | |
|
| impl_->ExplainMatchResultTo(x, os); | | StreamMatchResultListener listener(os); | |
| | | MatchAndExplain(x, &listener); | |
| } | | } | |
|
| | | | |
| protected: | | protected: | |
| MatcherBase() {} | | MatcherBase() {} | |
| | | | |
| // Constructs a matcher from its implementation. | | // Constructs a matcher from its implementation. | |
| explicit MatcherBase(const MatcherInterface<T>* impl) | | explicit MatcherBase(const MatcherInterface<T>* impl) | |
| : impl_(impl) {} | | : impl_(impl) {} | |
| | | | |
| virtual ~MatcherBase() {} | | virtual ~MatcherBase() {} | |
|
| | | | |
| private: | | private: | |
| // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar | | // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar | |
| // interfaces. The former dynamically allocates a chunk of memory | | // interfaces. The former dynamically allocates a chunk of memory | |
| // to hold the reference count, while the latter tracks all | | // to hold the reference count, while the latter tracks all | |
| // references using a circular linked list without allocating | | // references using a circular linked list without allocating | |
| // memory. It has been observed that linked_ptr performs better in | | // memory. It has been observed that linked_ptr performs better in | |
| // typical scenarios. However, shared_ptr can out-perform | | // typical scenarios. However, shared_ptr can out-perform | |
| // linked_ptr when there are many more uses of the copy constructor | | // linked_ptr when there are many more uses of the copy constructor | |
| // than the default constructor. | | // than the default constructor. | |
| // | | // | |
| | | | |
| skipping to change at line 147 | | skipping to change at line 243 | |
| // memory. It has been observed that linked_ptr performs better in | | // memory. It has been observed that linked_ptr performs better in | |
| // typical scenarios. However, shared_ptr can out-perform | | // typical scenarios. However, shared_ptr can out-perform | |
| // linked_ptr when there are many more uses of the copy constructor | | // linked_ptr when there are many more uses of the copy constructor | |
| // than the default constructor. | | // than the default constructor. | |
| // | | // | |
| // If performance becomes a problem, we should see if using | | // If performance becomes a problem, we should see if using | |
| // shared_ptr helps. | | // shared_ptr helps. | |
| ::testing::internal::linked_ptr<const MatcherInterface<T> > impl_; | | ::testing::internal::linked_ptr<const MatcherInterface<T> > impl_; | |
| }; | | }; | |
| | | | |
|
| // The default implementation of ExplainMatchResultTo() for | | | |
| // polymorphic matchers. | | | |
| template <typename PolymorphicMatcherImpl, typename T> | | | |
| inline void ExplainMatchResultTo(const PolymorphicMatcherImpl& /* impl */, | | | |
| const T& /* x */, | | | |
| ::std::ostream* /* os */) { | | | |
| // By default, nothing more needs to be said, as Google Mock already | | | |
| // prints the value of x elsewhere. | | | |
| } | | | |
| | | | |
| } // namespace internal | | } // namespace internal | |
| | | | |
| // A Matcher<T> is a copyable and IMMUTABLE (except by assignment) | | // A Matcher<T> is a copyable and IMMUTABLE (except by assignment) | |
| // object that can check whether a value of type T matches. The | | // object that can check whether a value of type T matches. The | |
| // implementation of Matcher<T> is just a linked_ptr to const | | // implementation of Matcher<T> is just a linked_ptr to const | |
| // MatcherInterface<T>, so copying is fairly cheap. Don't inherit | | // MatcherInterface<T>, so copying is fairly cheap. Don't inherit | |
| // from Matcher! | | // from Matcher! | |
| template <typename T> | | template <typename T> | |
| class Matcher : public internal::MatcherBase<T> { | | class Matcher : public internal::MatcherBase<T> { | |
| public: | | public: | |
| | | | |
| skipping to change at line 221 | | skipping to change at line 307 | |
| Matcher(const internal::string& s); // NOLINT | | Matcher(const internal::string& s); // NOLINT | |
| | | | |
| // Allows the user to write "foo" instead of Eq("foo") sometimes. | | // Allows the user to write "foo" instead of Eq("foo") sometimes. | |
| Matcher(const char* s); // NOLINT | | Matcher(const char* s); // NOLINT | |
| }; | | }; | |
| | | | |
| // The PolymorphicMatcher class template makes it easy to implement a | | // The PolymorphicMatcher class template makes it easy to implement a | |
| // polymorphic matcher (i.e. a matcher that can match values of more | | // polymorphic matcher (i.e. a matcher that can match values of more | |
| // than one type, e.g. Eq(n) and NotNull()). | | // than one type, e.g. Eq(n) and NotNull()). | |
| // | | // | |
|
| // To define a polymorphic matcher, a user first provides a Impl class | | // To define a polymorphic matcher, a user should provide an Impl | |
| // that has a Matches() method, a DescribeTo() method, and a | | // class that has a DescribeTo() method and a DescribeNegationTo() | |
| // DescribeNegationTo() method. The Matches() method is usually a | | // method, and define a member function (or member function template) | |
| // method template (such that it works with multiple types). Then the | | | |
| // user creates the polymorphic matcher using | | | |
| // MakePolymorphicMatcher(). To provide additional explanation to the | | | |
| // match result, define a FREE function (or function template) | | | |
| // | | // | |
|
| // void ExplainMatchResultTo(const Impl& matcher, const Value& value, | | // bool MatchAndExplain(const Value& value, | |
| // ::std::ostream* os); | | // MatchResultListener* listener) const; | |
| // | | // | |
|
| // in the SAME NAME SPACE where Impl is defined. See the definition | | // See the definition of NotNull() for a complete example. | |
| // of NotNull() for a complete example. | | | |
| template <class Impl> | | template <class Impl> | |
| class PolymorphicMatcher { | | class PolymorphicMatcher { | |
| public: | | public: | |
|
| explicit PolymorphicMatcher(const Impl& impl) : impl_(impl) {} | | explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {} | |
| | | | |
| // Returns a mutable reference to the underlying matcher | | // Returns a mutable reference to the underlying matcher | |
| // implementation object. | | // implementation object. | |
| Impl& mutable_impl() { return impl_; } | | Impl& mutable_impl() { return impl_; } | |
| | | | |
| // Returns an immutable reference to the underlying matcher | | // Returns an immutable reference to the underlying matcher | |
| // implementation object. | | // implementation object. | |
| const Impl& impl() const { return impl_; } | | const Impl& impl() const { return impl_; } | |
| | | | |
| template <typename T> | | template <typename T> | |
| | | | |
| skipping to change at line 251 | | skipping to change at line 332 | |
| Impl& mutable_impl() { return impl_; } | | Impl& mutable_impl() { return impl_; } | |
| | | | |
| // Returns an immutable reference to the underlying matcher | | // Returns an immutable reference to the underlying matcher | |
| // implementation object. | | // implementation object. | |
| const Impl& impl() const { return impl_; } | | const Impl& impl() const { return impl_; } | |
| | | | |
| template <typename T> | | template <typename T> | |
| operator Matcher<T>() const { | | operator Matcher<T>() const { | |
| return Matcher<T>(new MonomorphicImpl<T>(impl_)); | | return Matcher<T>(new MonomorphicImpl<T>(impl_)); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| template <typename T> | | template <typename T> | |
| class MonomorphicImpl : public MatcherInterface<T> { | | class MonomorphicImpl : public MatcherInterface<T> { | |
| public: | | public: | |
| explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {} | | explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {} | |
| | | | |
|
| virtual bool Matches(T x) const { return impl_.Matches(x); } | | | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| impl_.DescribeTo(os); | | impl_.DescribeTo(os); | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| impl_.DescribeNegationTo(os); | | impl_.DescribeNegationTo(os); | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const { | | virtual bool MatchAndExplain(T x, MatchResultListener* listener) const | |
| using ::testing::internal::ExplainMatchResultTo; | | { | |
| | | return impl_.MatchAndExplain(x, listener); | |
| // C++ uses Argument-Dependent Look-up (aka Koenig Look-up) to | | | |
| // resolve the call to ExplainMatchResultTo() here. This | | | |
| // means that if there's a ExplainMatchResultTo() function | | | |
| // defined in the name space where class Impl is defined, it | | | |
| // will be picked by the compiler as the better match. | | | |
| // Otherwise the default implementation of it in | | | |
| // ::testing::internal will be picked. | | | |
| // | | | |
| // This look-up rule lets a writer of a polymorphic matcher | | | |
| // customize the behavior of ExplainMatchResultTo() when he | | | |
| // cares to. Nothing needs to be done by the writer if he | | | |
| // doesn't need to customize it. | | | |
| ExplainMatchResultTo(impl_, x, os); | | | |
| } | | } | |
| | | | |
| private: | | private: | |
| const Impl impl_; | | const Impl impl_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(MonomorphicImpl); | |
| }; | | }; | |
| | | | |
| Impl impl_; | | Impl impl_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher); | |
| }; | | }; | |
| | | | |
| // Creates a matcher from its implementation. This is easier to use | | // Creates a matcher from its implementation. This is easier to use | |
| // than the Matcher<T> constructor as it doesn't require you to | | // than the Matcher<T> constructor as it doesn't require you to | |
| // explicitly write the template argument, e.g. | | // explicitly write the template argument, e.g. | |
| // | | // | |
| // MakeMatcher(foo); | | // MakeMatcher(foo); | |
| // vs | | // vs | |
| // Matcher<const string&>(foo); | | // Matcher<const string&>(foo); | |
| template <typename T> | | template <typename T> | |
| | | | |
| skipping to change at line 386 | | skipping to change at line 456 | |
| } | | } | |
| | | | |
| // A<T>() returns a matcher that matches any value of type T. | | // A<T>() returns a matcher that matches any value of type T. | |
| template <typename T> | | template <typename T> | |
| Matcher<T> A(); | | Matcher<T> A(); | |
| | | | |
| // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION | | // Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION | |
| // and MUST NOT BE USED IN USER CODE!!! | | // and MUST NOT BE USED IN USER CODE!!! | |
| namespace internal { | | namespace internal { | |
| | | | |
|
| // Appends the explanation on the result of matcher.Matches(value) to | | // If the explanation is not empty, prints it to the ostream. | |
| // os iff the explanation is not empty. | | inline void PrintIfNotEmpty(const internal::string& explanation, | |
| template <typename T> | | std::ostream* os) { | |
| void ExplainMatchResultAsNeededTo(const Matcher<T>& matcher, T value, | | if (explanation != "" && os != NULL) { | |
| ::std::ostream* os) { | | *os << ", " << explanation; | |
| ::std::stringstream reason; | | | |
| matcher.ExplainMatchResultTo(value, &reason); | | | |
| const internal::string s = reason.str(); | | | |
| if (s != "") { | | | |
| *os << " (" << s << ")"; | | | |
| } | | } | |
| } | | } | |
| | | | |
|
| | | // Matches the value against the given matcher, prints the value and explai | |
| | | ns | |
| | | // the match result to the listener. Returns the match result. | |
| | | // 'listener' must not be NULL. | |
| | | // Value cannot be passed by const reference, because some matchers take a | |
| | | // non-const argument. | |
| | | template <typename Value, typename T> | |
| | | bool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher, | |
| | | MatchResultListener* listener) { | |
| | | if (!listener->IsInterested()) { | |
| | | // If the listener is not interested, we do not need to construct the | |
| | | // inner explanation. | |
| | | return matcher.Matches(value); | |
| | | } | |
| | | | |
| | | StringMatchResultListener inner_listener; | |
| | | const bool match = matcher.MatchAndExplain(value, &inner_listener); | |
| | | | |
| | | UniversalPrint(value, listener->stream()); | |
| | | PrintIfNotEmpty(inner_listener.str(), listener->stream()); | |
| | | | |
| | | return match; | |
| | | } | |
| | | | |
| // An internal helper class for doing compile-time loop on a tuple's | | // An internal helper class for doing compile-time loop on a tuple's | |
| // fields. | | // fields. | |
| template <size_t N> | | template <size_t N> | |
| class TuplePrefix { | | class TuplePrefix { | |
| public: | | public: | |
| // TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true | | // TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true | |
| // iff the first N fields of matcher_tuple matches the first N | | // iff the first N fields of matcher_tuple matches the first N | |
| // fields of value_tuple, respectively. | | // fields of value_tuple, respectively. | |
| template <typename MatcherTuple, typename ValueTuple> | | template <typename MatcherTuple, typename ValueTuple> | |
| static bool Matches(const MatcherTuple& matcher_tuple, | | static bool Matches(const MatcherTuple& matcher_tuple, | |
| const ValueTuple& value_tuple) { | | const ValueTuple& value_tuple) { | |
| using ::std::tr1::get; | | using ::std::tr1::get; | |
| return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple) | | return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple) | |
| && get<N - 1>(matcher_tuple).Matches(get<N - 1>(value_tuple)); | | && get<N - 1>(matcher_tuple).Matches(get<N - 1>(value_tuple)); | |
| } | | } | |
| | | | |
|
| // TuplePrefix<N>::DescribeMatchFailuresTo(matchers, values, os) | | // TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os) | |
| // describes failures in matching the first N fields of matchers | | // describes failures in matching the first N fields of matchers | |
| // against the first N fields of values. If there is no failure, | | // against the first N fields of values. If there is no failure, | |
| // nothing will be streamed to os. | | // nothing will be streamed to os. | |
| template <typename MatcherTuple, typename ValueTuple> | | template <typename MatcherTuple, typename ValueTuple> | |
|
| static void DescribeMatchFailuresTo(const MatcherTuple& matchers, | | static void ExplainMatchFailuresTo(const MatcherTuple& matchers, | |
| const ValueTuple& values, | | const ValueTuple& values, | |
| ::std::ostream* os) { | | ::std::ostream* os) { | |
| using ::std::tr1::tuple_element; | | using ::std::tr1::tuple_element; | |
| using ::std::tr1::get; | | using ::std::tr1::get; | |
| | | | |
| // First, describes failures in the first N - 1 fields. | | // First, describes failures in the first N - 1 fields. | |
|
| TuplePrefix<N - 1>::DescribeMatchFailuresTo(matchers, values, os); | | TuplePrefix<N - 1>::ExplainMatchFailuresTo(matchers, values, os); | |
| | | | |
| // Then describes the failure (if any) in the (N - 1)-th (0-based) | | // Then describes the failure (if any) in the (N - 1)-th (0-based) | |
| // field. | | // field. | |
| typename tuple_element<N - 1, MatcherTuple>::type matcher = | | typename tuple_element<N - 1, MatcherTuple>::type matcher = | |
| get<N - 1>(matchers); | | get<N - 1>(matchers); | |
| typedef typename tuple_element<N - 1, ValueTuple>::type Value; | | typedef typename tuple_element<N - 1, ValueTuple>::type Value; | |
| Value value = get<N - 1>(values); | | Value value = get<N - 1>(values); | |
|
| if (!matcher.Matches(value)) { | | StringMatchResultListener listener; | |
| | | if (!matcher.MatchAndExplain(value, &listener)) { | |
| // TODO(wan): include in the message the name of the parameter | | // TODO(wan): include in the message the name of the parameter | |
| // as used in MOCK_METHOD*() when possible. | | // as used in MOCK_METHOD*() when possible. | |
| *os << " Expected arg #" << N - 1 << ": "; | | *os << " Expected arg #" << N - 1 << ": "; | |
| get<N - 1>(matchers).DescribeTo(os); | | get<N - 1>(matchers).DescribeTo(os); | |
| *os << "\n Actual: "; | | *os << "\n Actual: "; | |
| // We remove the reference in type Value to prevent the | | // We remove the reference in type Value to prevent the | |
| // universal printer from printing the address of value, which | | // universal printer from printing the address of value, which | |
| // isn't interesting to the user most of the time. The | | // isn't interesting to the user most of the time. The | |
|
| // matcher's ExplainMatchResultTo() method handles the case when | | // matcher's MatchAndExplain() method handles the case when | |
| // the address is interesting. | | // the address is interesting. | |
|
| internal::UniversalPrinter<GMOCK_REMOVE_REFERENCE_(Value)>:: | | internal::UniversalPrint(value, os); | |
| Print(value, os); | | PrintIfNotEmpty(listener.str(), os); | |
| ExplainMatchResultAsNeededTo<Value>(matcher, value, os); | | | |
| *os << "\n"; | | *os << "\n"; | |
| } | | } | |
| } | | } | |
| }; | | }; | |
| | | | |
| // The base case. | | // The base case. | |
| template <> | | template <> | |
| class TuplePrefix<0> { | | class TuplePrefix<0> { | |
| public: | | public: | |
| template <typename MatcherTuple, typename ValueTuple> | | template <typename MatcherTuple, typename ValueTuple> | |
| static bool Matches(const MatcherTuple& /* matcher_tuple */, | | static bool Matches(const MatcherTuple& /* matcher_tuple */, | |
| const ValueTuple& /* value_tuple */) { | | const ValueTuple& /* value_tuple */) { | |
| return true; | | return true; | |
| } | | } | |
| | | | |
| template <typename MatcherTuple, typename ValueTuple> | | template <typename MatcherTuple, typename ValueTuple> | |
|
| static void DescribeMatchFailuresTo(const MatcherTuple& /* matchers */, | | static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */, | |
| const ValueTuple& /* values */, | | const ValueTuple& /* values */, | |
| ::std::ostream* /* os */) {} | | ::std::ostream* /* os */) {} | |
| }; | | }; | |
| | | | |
| // TupleMatches(matcher_tuple, value_tuple) returns true iff all | | // TupleMatches(matcher_tuple, value_tuple) returns true iff all | |
| // matchers in matcher_tuple match the corresponding fields in | | // matchers in matcher_tuple match the corresponding fields in | |
| // value_tuple. It is a compiler error if matcher_tuple and | | // value_tuple. It is a compiler error if matcher_tuple and | |
| // value_tuple have different number of fields or incompatible field | | // value_tuple have different number of fields or incompatible field | |
| // types. | | // types. | |
| template <typename MatcherTuple, typename ValueTuple> | | template <typename MatcherTuple, typename ValueTuple> | |
| bool TupleMatches(const MatcherTuple& matcher_tuple, | | bool TupleMatches(const MatcherTuple& matcher_tuple, | |
| const ValueTuple& value_tuple) { | | const ValueTuple& value_tuple) { | |
| | | | |
| skipping to change at line 491 | | skipping to change at line 579 | |
| GMOCK_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value == | | GMOCK_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value == | |
| tuple_size<ValueTuple>::value, | | tuple_size<ValueTuple>::value, | |
| matcher_and_value_have_different_numbers_of_fields)
; | | matcher_and_value_have_different_numbers_of_fields)
; | |
| return TuplePrefix<tuple_size<ValueTuple>::value>:: | | return TuplePrefix<tuple_size<ValueTuple>::value>:: | |
| Matches(matcher_tuple, value_tuple); | | Matches(matcher_tuple, value_tuple); | |
| } | | } | |
| | | | |
| // Describes failures in matching matchers against values. If there | | // Describes failures in matching matchers against values. If there | |
| // is no failure, nothing will be streamed to os. | | // is no failure, nothing will be streamed to os. | |
| template <typename MatcherTuple, typename ValueTuple> | | template <typename MatcherTuple, typename ValueTuple> | |
|
| void DescribeMatchFailureTupleTo(const MatcherTuple& matchers, | | void ExplainMatchFailureTupleTo(const MatcherTuple& matchers, | |
| const ValueTuple& values, | | const ValueTuple& values, | |
| ::std::ostream* os) { | | ::std::ostream* os) { | |
| using ::std::tr1::tuple_size; | | using ::std::tr1::tuple_size; | |
|
| TuplePrefix<tuple_size<MatcherTuple>::value>::DescribeMatchFailuresTo( | | TuplePrefix<tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo( | |
| matchers, values, os); | | matchers, values, os); | |
| } | | } | |
| | | | |
| // The MatcherCastImpl class template is a helper for implementing | | // The MatcherCastImpl class template is a helper for implementing | |
| // MatcherCast(). We need this helper in order to partially | | // MatcherCast(). We need this helper in order to partially | |
| // specialize the implementation of MatcherCast() (C++ allows | | // specialize the implementation of MatcherCast() (C++ allows | |
| // class/struct templates to be partially specialized, but not | | // class/struct templates to be partially specialized, but not | |
| // function templates.). | | // function templates.). | |
| | | | |
| // This general version is used when MatcherCast()'s argument is a | | // This general version is used when MatcherCast()'s argument is a | |
| | | | |
| skipping to change at line 525 | | skipping to change at line 613 | |
| | | | |
| // This more specialized version is used when MatcherCast()'s argument | | // This more specialized version is used when MatcherCast()'s argument | |
| // is already a Matcher. This only compiles when type T can be | | // is already a Matcher. This only compiles when type T can be | |
| // statically converted to type U. | | // statically converted to type U. | |
| template <typename T, typename U> | | template <typename T, typename U> | |
| class MatcherCastImpl<T, Matcher<U> > { | | class MatcherCastImpl<T, Matcher<U> > { | |
| public: | | public: | |
| static Matcher<T> Cast(const Matcher<U>& source_matcher) { | | static Matcher<T> Cast(const Matcher<U>& source_matcher) { | |
| return Matcher<T>(new Impl(source_matcher)); | | return Matcher<T>(new Impl(source_matcher)); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| class Impl : public MatcherInterface<T> { | | class Impl : public MatcherInterface<T> { | |
| public: | | public: | |
| explicit Impl(const Matcher<U>& source_matcher) | | explicit Impl(const Matcher<U>& source_matcher) | |
| : source_matcher_(source_matcher) {} | | : source_matcher_(source_matcher) {} | |
| | | | |
| // We delegate the matching logic to the source matcher. | | // We delegate the matching logic to the source matcher. | |
|
| virtual bool Matches(T x) const { | | virtual bool MatchAndExplain(T x, MatchResultListener* listener) const | |
| return source_matcher_.Matches(static_cast<U>(x)); | | { | |
| | | return source_matcher_.MatchAndExplain(static_cast<U>(x), listener); | |
| } | | } | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| source_matcher_.DescribeTo(os); | | source_matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| source_matcher_.DescribeNegationTo(os); | | source_matcher_.DescribeNegationTo(os); | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const { | | | |
| source_matcher_.ExplainMatchResultTo(static_cast<U>(x), os); | | | |
| } | | | |
| private: | | private: | |
| const Matcher<U> source_matcher_; | | const Matcher<U> source_matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(Impl); | |
| }; | | }; | |
| }; | | }; | |
| | | | |
| // This even more specialized version is used for efficiently casting | | // This even more specialized version is used for efficiently casting | |
| // a matcher to its own type. | | // a matcher to its own type. | |
| template <typename T> | | template <typename T> | |
| class MatcherCastImpl<T, Matcher<T> > { | | class MatcherCastImpl<T, Matcher<T> > { | |
| public: | | public: | |
| static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; } | | static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; } | |
| }; | | }; | |
| | | | |
| // Implements A<T>(). | | // Implements A<T>(). | |
| template <typename T> | | template <typename T> | |
| class AnyMatcherImpl : public MatcherInterface<T> { | | class AnyMatcherImpl : public MatcherInterface<T> { | |
| public: | | public: | |
|
| virtual bool Matches(T /* x */) const { return true; } | | virtual bool MatchAndExplain( | |
| | | T /* x */, MatchResultListener* /* listener */) const { return true; | |
| | | } | |
| virtual void DescribeTo(::std::ostream* os) const { *os << "is anything";
} | | virtual void DescribeTo(::std::ostream* os) const { *os << "is anything";
} | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| // This is mostly for completeness' safe, as it's not very useful | | // This is mostly for completeness' safe, as it's not very useful | |
| // to write Not(A<bool>()). However we cannot completely rule out | | // to write Not(A<bool>()). However we cannot completely rule out | |
| // such a possibility, and it doesn't hurt to be prepared. | | // such a possibility, and it doesn't hurt to be prepared. | |
| *os << "never matches"; | | *os << "never matches"; | |
| } | | } | |
| }; | | }; | |
| | | | |
| // Implements _, a matcher that matches any value of any | | // Implements _, a matcher that matches any value of any | |
| | | | |
| skipping to change at line 597 | | skipping to change at line 686 | |
| // | | // | |
| // The matcher defined here is polymorphic (for example, Eq(5) can be | | // The matcher defined here is polymorphic (for example, Eq(5) can be | |
| // used to match an int, a short, a double, etc). Therefore we use | | // used to match an int, a short, a double, etc). Therefore we use | |
| // a template type conversion operator in the implementation. | | // a template type conversion operator in the implementation. | |
| // | | // | |
| // We define this as a macro in order to eliminate duplicated source | | // We define this as a macro in order to eliminate duplicated source | |
| // code. | | // code. | |
| // | | // | |
| // The following template definition assumes that the Rhs parameter is | | // The following template definition assumes that the Rhs parameter is | |
| // a "bare" type (i.e. neither 'const T' nor 'T&'). | | // a "bare" type (i.e. neither 'const T' nor 'T&'). | |
|
| #define GMOCK_IMPLEMENT_COMPARISON_MATCHER_(name, op, relation) \ | | #define GMOCK_IMPLEMENT_COMPARISON_MATCHER_( \ | |
| | | name, op, relation, negated_relation) \ | |
| template <typename Rhs> class name##Matcher { \ | | template <typename Rhs> class name##Matcher { \ | |
| public: \ | | public: \ | |
| explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \ | | explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \ | |
| template <typename Lhs> \ | | template <typename Lhs> \ | |
| operator Matcher<Lhs>() const { \ | | operator Matcher<Lhs>() const { \ | |
| return MakeMatcher(new Impl<Lhs>(rhs_)); \ | | return MakeMatcher(new Impl<Lhs>(rhs_)); \ | |
| } \ | | } \ | |
| private: \ | | private: \ | |
| template <typename Lhs> \ | | template <typename Lhs> \ | |
| class Impl : public MatcherInterface<Lhs> { \ | | class Impl : public MatcherInterface<Lhs> { \ | |
| public: \ | | public: \ | |
| explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \ | | explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \ | |
|
| virtual bool Matches(Lhs lhs) const { return lhs op rhs_; } \ | | virtual bool MatchAndExplain(\ | |
| | | Lhs lhs, MatchResultListener* /* listener */) const { \ | |
| | | return lhs op rhs_; \ | |
| | | } \ | |
| virtual void DescribeTo(::std::ostream* os) const { \ | | virtual void DescribeTo(::std::ostream* os) const { \ | |
|
| *os << "is " relation " "; \ | | *os << relation " "; \ | |
| UniversalPrinter<Rhs>::Print(rhs_, os); \ | | UniversalPrinter<Rhs>::Print(rhs_, os); \ | |
| } \ | | } \ | |
| virtual void DescribeNegationTo(::std::ostream* os) const { \ | | virtual void DescribeNegationTo(::std::ostream* os) const { \ | |
|
| *os << "is not " relation " "; \ | | *os << negated_relation " "; \ | |
| UniversalPrinter<Rhs>::Print(rhs_, os); \ | | UniversalPrinter<Rhs>::Print(rhs_, os); \ | |
| } \ | | } \ | |
| private: \ | | private: \ | |
| Rhs rhs_; \ | | Rhs rhs_; \ | |
|
| | | GTEST_DISALLOW_ASSIGN_(Impl); \ | |
| }; \ | | }; \ | |
| Rhs rhs_; \ | | Rhs rhs_; \ | |
|
| | | GTEST_DISALLOW_ASSIGN_(name##Matcher); \ | |
| } | | } | |
| | | | |
| // Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v) | | // Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v) | |
| // respectively. | | // respectively. | |
|
| GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, "equal to"); | | GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, "is equal to", "isn't equal to" | |
| GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, >=, "greater than or equal to"); | | ); | |
| GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, >, "greater than"); | | GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, >=, "is >=", "isn't >="); | |
| GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, <=, "less than or equal to"); | | GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, >, "is >", "isn't >"); | |
| GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, <, "less than"); | | GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, <=, "is <=", "isn't <="); | |
| GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "not equal to"); | | GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, <, "is <", "isn't <"); | |
| | | GMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, "isn't equal to", "is equal to" | |
| | | ); | |
| | | | |
| #undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_ | | #undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_ | |
| | | | |
|
| // Implements the polymorphic IsNull() matcher, which matches any | | // Implements the polymorphic IsNull() matcher, which matches any raw or sm
art | |
| // pointer that is NULL. | | // pointer that is NULL. | |
| class IsNullMatcher { | | class IsNullMatcher { | |
| public: | | public: | |
|
| template <typename T> | | template <typename Pointer> | |
| bool Matches(T* p) const { return p == NULL; } | | bool MatchAndExplain(const Pointer& p, | |
| | | MatchResultListener* /* listener */) const { | |
| | | return GetRawPointer(p) == NULL; | |
| | | } | |
| | | | |
| void DescribeTo(::std::ostream* os) const { *os << "is NULL"; } | | void DescribeTo(::std::ostream* os) const { *os << "is NULL"; } | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
|
| *os << "is not NULL"; | | *os << "isn't NULL"; | |
| } | | } | |
| }; | | }; | |
| | | | |
|
| // Implements the polymorphic NotNull() matcher, which matches any | | // Implements the polymorphic NotNull() matcher, which matches any raw or s
mart | |
| // pointer that is not NULL. | | // pointer that is not NULL. | |
| class NotNullMatcher { | | class NotNullMatcher { | |
| public: | | public: | |
|
| template <typename T> | | template <typename Pointer> | |
| bool Matches(T* p) const { return p != NULL; } | | bool MatchAndExplain(const Pointer& p, | |
| | | MatchResultListener* /* listener */) const { | |
| | | return GetRawPointer(p) != NULL; | |
| | | } | |
| | | | |
|
| void DescribeTo(::std::ostream* os) const { *os << "is not NULL"; } | | void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; } | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "is NULL"; | | *os << "is NULL"; | |
| } | | } | |
| }; | | }; | |
| | | | |
| // Ref(variable) matches any argument that is a reference to | | // Ref(variable) matches any argument that is a reference to | |
| // 'variable'. This matcher is polymorphic as it can match any | | // 'variable'. This matcher is polymorphic as it can match any | |
| // super type of the type of 'variable'. | | // super type of the type of 'variable'. | |
| // | | // | |
| // The RefMatcher template class implements Ref(variable). It can | | // The RefMatcher template class implements Ref(variable). It can | |
| | | | |
| skipping to change at line 700 | | skipping to change at line 801 | |
| | | | |
| template <typename Super> | | template <typename Super> | |
| operator Matcher<Super&>() const { | | operator Matcher<Super&>() const { | |
| // By passing object_ (type T&) to Impl(), which expects a Super&, | | // By passing object_ (type T&) to Impl(), which expects a Super&, | |
| // we make sure that Super is a super type of T. In particular, | | // we make sure that Super is a super type of T. In particular, | |
| // this catches using Ref(const_value) as a matcher for a | | // this catches using Ref(const_value) as a matcher for a | |
| // non-const reference, as you cannot implicitly convert a const | | // non-const reference, as you cannot implicitly convert a const | |
| // reference to a non-const reference. | | // reference to a non-const reference. | |
| return MakeMatcher(new Impl<Super>(object_)); | | return MakeMatcher(new Impl<Super>(object_)); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| template <typename Super> | | template <typename Super> | |
| class Impl : public MatcherInterface<Super&> { | | class Impl : public MatcherInterface<Super&> { | |
| public: | | public: | |
| explicit Impl(Super& x) : object_(x) {} // NOLINT | | explicit Impl(Super& x) : object_(x) {} // NOLINT | |
| | | | |
|
| // Matches() takes a Super& (as opposed to const Super&) in | | // MatchAndExplain() takes a Super& (as opposed to const Super&) | |
| // order to match the interface MatcherInterface<Super&>. | | // in order to match the interface MatcherInterface<Super&>. | |
| virtual bool Matches(Super& x) const { return &x == &object_; } // NOL | | virtual bool MatchAndExplain( | |
| INT | | Super& x, MatchResultListener* listener) const { | |
| | | *listener << "which is located @" << static_cast<const void*>(&x); | |
| | | return &x == &object_; | |
| | | } | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| *os << "references the variable "; | | *os << "references the variable "; | |
| UniversalPrinter<Super&>::Print(object_, os); | | UniversalPrinter<Super&>::Print(object_, os); | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "does not reference the variable "; | | *os << "does not reference the variable "; | |
| UniversalPrinter<Super&>::Print(object_, os); | | UniversalPrinter<Super&>::Print(object_, os); | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(Super& x, // NOLINT | | | |
| ::std::ostream* os) const { | | | |
| *os << "is located @" << static_cast<const void*>(&x); | | | |
| } | | | |
| private: | | private: | |
| const Super& object_; | | const Super& object_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(Impl); | |
| }; | | }; | |
| | | | |
| T& object_; | | T& object_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(RefMatcher); | |
| }; | | }; | |
| | | | |
| // Polymorphic helper functions for narrow and wide string matchers. | | // Polymorphic helper functions for narrow and wide string matchers. | |
| inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs)
{ | | inline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs)
{ | |
| return String::CaseInsensitiveCStringEquals(lhs, rhs); | | return String::CaseInsensitiveCStringEquals(lhs, rhs); | |
| } | | } | |
| | | | |
| inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs, | | inline bool CaseInsensitiveCStringEquals(const wchar_t* lhs, | |
| const wchar_t* rhs) { | | const wchar_t* rhs) { | |
| return String::CaseInsensitiveWideCStringEquals(lhs, rhs); | | return String::CaseInsensitiveWideCStringEquals(lhs, rhs); | |
| | | | |
| skipping to change at line 778 | | skipping to change at line 884 | |
| class StrEqualityMatcher { | | class StrEqualityMatcher { | |
| public: | | public: | |
| typedef typename StringType::const_pointer ConstCharPointer; | | typedef typename StringType::const_pointer ConstCharPointer; | |
| | | | |
| StrEqualityMatcher(const StringType& str, bool expect_eq, | | StrEqualityMatcher(const StringType& str, bool expect_eq, | |
| bool case_sensitive) | | bool case_sensitive) | |
| : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive
) {} | | : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive
) {} | |
| | | | |
| // When expect_eq_ is true, returns true iff s is equal to string_; | | // When expect_eq_ is true, returns true iff s is equal to string_; | |
| // otherwise returns true iff s is not equal to string_. | | // otherwise returns true iff s is not equal to string_. | |
|
| bool Matches(ConstCharPointer s) const { | | bool MatchAndExplain(ConstCharPointer s, | |
| | | MatchResultListener* listener) const { | |
| if (s == NULL) { | | if (s == NULL) { | |
| return !expect_eq_; | | return !expect_eq_; | |
| } | | } | |
|
| return Matches(StringType(s)); | | return MatchAndExplain(StringType(s), listener); | |
| } | | } | |
| | | | |
|
| bool Matches(const StringType& s) const { | | bool MatchAndExplain(const StringType& s, | |
| | | MatchResultListener* /* listener */) const { | |
| const bool eq = case_sensitive_ ? s == string_ : | | const bool eq = case_sensitive_ ? s == string_ : | |
| CaseInsensitiveStringEquals(s, string_); | | CaseInsensitiveStringEquals(s, string_); | |
| return expect_eq_ == eq; | | return expect_eq_ == eq; | |
| } | | } | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| DescribeToHelper(expect_eq_, os); | | DescribeToHelper(expect_eq_, os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| | | | |
| skipping to change at line 798 | | skipping to change at line 906 | |
| return expect_eq_ == eq; | | return expect_eq_ == eq; | |
| } | | } | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| DescribeToHelper(expect_eq_, os); | | DescribeToHelper(expect_eq_, os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| DescribeToHelper(!expect_eq_, os); | | DescribeToHelper(!expect_eq_, os); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| void DescribeToHelper(bool expect_eq, ::std::ostream* os) const { | | void DescribeToHelper(bool expect_eq, ::std::ostream* os) const { | |
|
| *os << "is "; | | *os << (expect_eq ? "is " : "isn't "); | |
| if (!expect_eq) { | | | |
| *os << "not "; | | | |
| } | | | |
| *os << "equal to "; | | *os << "equal to "; | |
| if (!case_sensitive_) { | | if (!case_sensitive_) { | |
| *os << "(ignoring case) "; | | *os << "(ignoring case) "; | |
| } | | } | |
| UniversalPrinter<StringType>::Print(string_, os); | | UniversalPrinter<StringType>::Print(string_, os); | |
| } | | } | |
| | | | |
| const StringType string_; | | const StringType string_; | |
| const bool expect_eq_; | | const bool expect_eq_; | |
| const bool case_sensitive_; | | const bool case_sensitive_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher); | |
| }; | | }; | |
| | | | |
| // Implements the polymorphic HasSubstr(substring) matcher, which | | // Implements the polymorphic HasSubstr(substring) matcher, which | |
| // can be used as a Matcher<T> as long as T can be converted to a | | // can be used as a Matcher<T> as long as T can be converted to a | |
| // string. | | // string. | |
| template <typename StringType> | | template <typename StringType> | |
| class HasSubstrMatcher { | | class HasSubstrMatcher { | |
| public: | | public: | |
| typedef typename StringType::const_pointer ConstCharPointer; | | typedef typename StringType::const_pointer ConstCharPointer; | |
| | | | |
| explicit HasSubstrMatcher(const StringType& substring) | | explicit HasSubstrMatcher(const StringType& substring) | |
| : substring_(substring) {} | | : substring_(substring) {} | |
| | | | |
| // These overloaded methods allow HasSubstr(substring) to be used as a | | // These overloaded methods allow HasSubstr(substring) to be used as a | |
| // Matcher<T> as long as T can be converted to string. Returns true | | // Matcher<T> as long as T can be converted to string. Returns true | |
| // iff s contains substring_ as a substring. | | // iff s contains substring_ as a substring. | |
|
| bool Matches(ConstCharPointer s) const { | | bool MatchAndExplain(ConstCharPointer s, | |
| return s != NULL && Matches(StringType(s)); | | MatchResultListener* listener) const { | |
| | | return s != NULL && MatchAndExplain(StringType(s), listener); | |
| } | | } | |
| | | | |
|
| bool Matches(const StringType& s) const { | | bool MatchAndExplain(const StringType& s, | |
| | | MatchResultListener* /* listener */) const { | |
| return s.find(substring_) != StringType::npos; | | return s.find(substring_) != StringType::npos; | |
| } | | } | |
| | | | |
| // Describes what this matcher matches. | | // Describes what this matcher matches. | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << "has substring "; | | *os << "has substring "; | |
| UniversalPrinter<StringType>::Print(substring_, os); | | UniversalPrinter<StringType>::Print(substring_, os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| | | | |
| skipping to change at line 848 | | skipping to change at line 958 | |
| // Describes what this matcher matches. | | // Describes what this matcher matches. | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << "has substring "; | | *os << "has substring "; | |
| UniversalPrinter<StringType>::Print(substring_, os); | | UniversalPrinter<StringType>::Print(substring_, os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "has no substring "; | | *os << "has no substring "; | |
| UniversalPrinter<StringType>::Print(substring_, os); | | UniversalPrinter<StringType>::Print(substring_, os); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const StringType substring_; | | const StringType substring_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher); | |
| }; | | }; | |
| | | | |
| // Implements the polymorphic StartsWith(substring) matcher, which | | // Implements the polymorphic StartsWith(substring) matcher, which | |
| // can be used as a Matcher<T> as long as T can be converted to a | | // can be used as a Matcher<T> as long as T can be converted to a | |
| // string. | | // string. | |
| template <typename StringType> | | template <typename StringType> | |
| class StartsWithMatcher { | | class StartsWithMatcher { | |
| public: | | public: | |
| typedef typename StringType::const_pointer ConstCharPointer; | | typedef typename StringType::const_pointer ConstCharPointer; | |
| | | | |
| explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) { | | explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) { | |
| } | | } | |
| | | | |
| // These overloaded methods allow StartsWith(prefix) to be used as a | | // These overloaded methods allow StartsWith(prefix) to be used as a | |
| // Matcher<T> as long as T can be converted to string. Returns true | | // Matcher<T> as long as T can be converted to string. Returns true | |
| // iff s starts with prefix_. | | // iff s starts with prefix_. | |
|
| bool Matches(ConstCharPointer s) const { | | bool MatchAndExplain(ConstCharPointer s, | |
| return s != NULL && Matches(StringType(s)); | | MatchResultListener* listener) const { | |
| | | return s != NULL && MatchAndExplain(StringType(s), listener); | |
| } | | } | |
| | | | |
|
| bool Matches(const StringType& s) const { | | bool MatchAndExplain(const StringType& s, | |
| | | MatchResultListener* /* listener */) const { | |
| return s.length() >= prefix_.length() && | | return s.length() >= prefix_.length() && | |
| s.substr(0, prefix_.length()) == prefix_; | | s.substr(0, prefix_.length()) == prefix_; | |
| } | | } | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << "starts with "; | | *os << "starts with "; | |
| UniversalPrinter<StringType>::Print(prefix_, os); | | UniversalPrinter<StringType>::Print(prefix_, os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| | | | |
| skipping to change at line 884 | | skipping to change at line 999 | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << "starts with "; | | *os << "starts with "; | |
| UniversalPrinter<StringType>::Print(prefix_, os); | | UniversalPrinter<StringType>::Print(prefix_, os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "doesn't start with "; | | *os << "doesn't start with "; | |
| UniversalPrinter<StringType>::Print(prefix_, os); | | UniversalPrinter<StringType>::Print(prefix_, os); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const StringType prefix_; | | const StringType prefix_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(StartsWithMatcher); | |
| }; | | }; | |
| | | | |
| // Implements the polymorphic EndsWith(substring) matcher, which | | // Implements the polymorphic EndsWith(substring) matcher, which | |
| // can be used as a Matcher<T> as long as T can be converted to a | | // can be used as a Matcher<T> as long as T can be converted to a | |
| // string. | | // string. | |
| template <typename StringType> | | template <typename StringType> | |
| class EndsWithMatcher { | | class EndsWithMatcher { | |
| public: | | public: | |
| typedef typename StringType::const_pointer ConstCharPointer; | | typedef typename StringType::const_pointer ConstCharPointer; | |
| | | | |
| explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {} | | explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {} | |
| | | | |
| // These overloaded methods allow EndsWith(suffix) to be used as a | | // These overloaded methods allow EndsWith(suffix) to be used as a | |
| // Matcher<T> as long as T can be converted to string. Returns true | | // Matcher<T> as long as T can be converted to string. Returns true | |
| // iff s ends with suffix_. | | // iff s ends with suffix_. | |
|
| bool Matches(ConstCharPointer s) const { | | bool MatchAndExplain(ConstCharPointer s, | |
| return s != NULL && Matches(StringType(s)); | | MatchResultListener* listener) const { | |
| | | return s != NULL && MatchAndExplain(StringType(s), listener); | |
| } | | } | |
| | | | |
|
| bool Matches(const StringType& s) const { | | bool MatchAndExplain(const StringType& s, | |
| | | MatchResultListener* /* listener */) const { | |
| return s.length() >= suffix_.length() && | | return s.length() >= suffix_.length() && | |
| s.substr(s.length() - suffix_.length()) == suffix_; | | s.substr(s.length() - suffix_.length()) == suffix_; | |
| } | | } | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << "ends with "; | | *os << "ends with "; | |
| UniversalPrinter<StringType>::Print(suffix_, os); | | UniversalPrinter<StringType>::Print(suffix_, os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| | | | |
| skipping to change at line 919 | | skipping to change at line 1039 | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << "ends with "; | | *os << "ends with "; | |
| UniversalPrinter<StringType>::Print(suffix_, os); | | UniversalPrinter<StringType>::Print(suffix_, os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "doesn't end with "; | | *os << "doesn't end with "; | |
| UniversalPrinter<StringType>::Print(suffix_, os); | | UniversalPrinter<StringType>::Print(suffix_, os); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const StringType suffix_; | | const StringType suffix_; | |
|
| }; | | | |
| | | | |
|
| #if GMOCK_HAS_REGEX | | GTEST_DISALLOW_ASSIGN_(EndsWithMatcher); | |
| | | }; | |
| | | | |
| // Implements polymorphic matchers MatchesRegex(regex) and | | // Implements polymorphic matchers MatchesRegex(regex) and | |
| // ContainsRegex(regex), which can be used as a Matcher<T> as long as | | // ContainsRegex(regex), which can be used as a Matcher<T> as long as | |
| // T can be converted to a string. | | // T can be converted to a string. | |
| class MatchesRegexMatcher { | | class MatchesRegexMatcher { | |
| public: | | public: | |
| MatchesRegexMatcher(const RE* regex, bool full_match) | | MatchesRegexMatcher(const RE* regex, bool full_match) | |
| : regex_(regex), full_match_(full_match) {} | | : regex_(regex), full_match_(full_match) {} | |
| | | | |
| // These overloaded methods allow MatchesRegex(regex) to be used as | | // These overloaded methods allow MatchesRegex(regex) to be used as | |
| // a Matcher<T> as long as T can be converted to string. Returns | | // a Matcher<T> as long as T can be converted to string. Returns | |
| // true iff s matches regular expression regex. When full_match_ is | | // true iff s matches regular expression regex. When full_match_ is | |
| // true, a full match is done; otherwise a partial match is done. | | // true, a full match is done; otherwise a partial match is done. | |
|
| bool Matches(const char* s) const { | | bool MatchAndExplain(const char* s, | |
| return s != NULL && Matches(internal::string(s)); | | MatchResultListener* listener) const { | |
| | | return s != NULL && MatchAndExplain(internal::string(s), listener); | |
| } | | } | |
| | | | |
|
| bool Matches(const internal::string& s) const { | | bool MatchAndExplain(const internal::string& s, | |
| | | MatchResultListener* /* listener */) const { | |
| return full_match_ ? RE::FullMatch(s, *regex_) : | | return full_match_ ? RE::FullMatch(s, *regex_) : | |
| RE::PartialMatch(s, *regex_); | | RE::PartialMatch(s, *regex_); | |
| } | | } | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << (full_match_ ? "matches" : "contains") | | *os << (full_match_ ? "matches" : "contains") | |
| << " regular expression "; | | << " regular expression "; | |
| UniversalPrinter<internal::string>::Print(regex_->pattern(), os); | | UniversalPrinter<internal::string>::Print(regex_->pattern(), os); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 957 | | skipping to change at line 1080 | |
| *os << (full_match_ ? "matches" : "contains") | | *os << (full_match_ ? "matches" : "contains") | |
| << " regular expression "; | | << " regular expression "; | |
| UniversalPrinter<internal::string>::Print(regex_->pattern(), os); | | UniversalPrinter<internal::string>::Print(regex_->pattern(), os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "doesn't " << (full_match_ ? "match" : "contain") | | *os << "doesn't " << (full_match_ ? "match" : "contain") | |
| << " regular expression "; | | << " regular expression "; | |
| UniversalPrinter<internal::string>::Print(regex_->pattern(), os); | | UniversalPrinter<internal::string>::Print(regex_->pattern(), os); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const internal::linked_ptr<const RE> regex_; | | const internal::linked_ptr<const RE> regex_; | |
| const bool full_match_; | | const bool full_match_; | |
|
| }; | | | |
| | | | |
|
| #endif // GMOCK_HAS_REGEX | | GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher); | |
| | | }; | |
| | | | |
| // Implements a matcher that compares the two fields of a 2-tuple | | // Implements a matcher that compares the two fields of a 2-tuple | |
| // using one of the ==, <=, <, etc, operators. The two fields being | | // using one of the ==, <=, <, etc, operators. The two fields being | |
| // compared don't have to have the same type. | | // compared don't have to have the same type. | |
| // | | // | |
| // The matcher defined here is polymorphic (for example, Eq() can be | | // The matcher defined here is polymorphic (for example, Eq() can be | |
| // used to match a tuple<int, short>, a tuple<const long&, double>, | | // used to match a tuple<int, short>, a tuple<const long&, double>, | |
| // etc). Therefore we use a template type conversion operator in the | | // etc). Therefore we use a template type conversion operator in the | |
| // implementation. | | // implementation. | |
| // | | // | |
| | | | |
| skipping to change at line 986 | | skipping to change at line 1110 | |
| class name##2Matcher { \ | | class name##2Matcher { \ | |
| public: \ | | public: \ | |
| template <typename T1, typename T2> \ | | template <typename T1, typename T2> \ | |
| operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \ | | operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \ | |
| return MakeMatcher(new Impl<T1, T2>); \ | | return MakeMatcher(new Impl<T1, T2>); \ | |
| } \ | | } \ | |
| private: \ | | private: \ | |
| template <typename T1, typename T2> \ | | template <typename T1, typename T2> \ | |
| class Impl : public MatcherInterface<const ::std::tr1::tuple<T1, T2>&>
{ \ | | class Impl : public MatcherInterface<const ::std::tr1::tuple<T1, T2>&>
{ \ | |
| public: \ | | public: \ | |
|
| virtual bool Matches(const ::std::tr1::tuple<T1, T2>& args) const { \ | | virtual bool MatchAndExplain( \ | |
| | | const ::std::tr1::tuple<T1, T2>& args, \ | |
| | | MatchResultListener* /* listener */) const { \ | |
| return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \ | | return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \ | |
| } \ | | } \ | |
| virtual void DescribeTo(::std::ostream* os) const { \ | | virtual void DescribeTo(::std::ostream* os) const { \ | |
| *os << "are a pair (x, y) where x " #op " y"; \ | | *os << "are a pair (x, y) where x " #op " y"; \ | |
| } \ | | } \ | |
| virtual void DescribeNegationTo(::std::ostream* os) const { \ | | virtual void DescribeNegationTo(::std::ostream* os) const { \ | |
| *os << "are a pair (x, y) where x " #op " y is false"; \ | | *os << "are a pair (x, y) where x " #op " y is false"; \ | |
| } \ | | } \ | |
| }; \ | | }; \ | |
| } | | } | |
| | | | |
| skipping to change at line 1018 | | skipping to change at line 1144 | |
| // Implements the Not(...) matcher for a particular argument type T. | | // Implements the Not(...) matcher for a particular argument type T. | |
| // We do not nest it inside the NotMatcher class template, as that | | // We do not nest it inside the NotMatcher class template, as that | |
| // will prevent different instantiations of NotMatcher from sharing | | // will prevent different instantiations of NotMatcher from sharing | |
| // the same NotMatcherImpl<T> class. | | // the same NotMatcherImpl<T> class. | |
| template <typename T> | | template <typename T> | |
| class NotMatcherImpl : public MatcherInterface<T> { | | class NotMatcherImpl : public MatcherInterface<T> { | |
| public: | | public: | |
| explicit NotMatcherImpl(const Matcher<T>& matcher) | | explicit NotMatcherImpl(const Matcher<T>& matcher) | |
| : matcher_(matcher) {} | | : matcher_(matcher) {} | |
| | | | |
|
| virtual bool Matches(T x) const { | | virtual bool MatchAndExplain(T x, MatchResultListener* listener) const { | |
| return !matcher_.Matches(x); | | return !matcher_.MatchAndExplain(x, listener); | |
| } | | } | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| matcher_.DescribeNegationTo(os); | | matcher_.DescribeNegationTo(os); | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| matcher_.DescribeTo(os); | | matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const { | | | |
| matcher_.ExplainMatchResultTo(x, os); | | | |
| } | | | |
| private: | | private: | |
| const Matcher<T> matcher_; | | const Matcher<T> matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(NotMatcherImpl); | |
| }; | | }; | |
| | | | |
| // Implements the Not(m) matcher, which matches a value that doesn't | | // Implements the Not(m) matcher, which matches a value that doesn't | |
| // match matcher m. | | // match matcher m. | |
| template <typename InnerMatcher> | | template <typename InnerMatcher> | |
| class NotMatcher { | | class NotMatcher { | |
| public: | | public: | |
| explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {} | | explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {} | |
| | | | |
| // This template type conversion operator allows Not(m) to be used | | // This template type conversion operator allows Not(m) to be used | |
| | | | |
| skipping to change at line 1050 | | skipping to change at line 1175 | |
| class NotMatcher { | | class NotMatcher { | |
| public: | | public: | |
| explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {} | | explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {} | |
| | | | |
| // This template type conversion operator allows Not(m) to be used | | // This template type conversion operator allows Not(m) to be used | |
| // to match any type m can match. | | // to match any type m can match. | |
| template <typename T> | | template <typename T> | |
| operator Matcher<T>() const { | | operator Matcher<T>() const { | |
| return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_))); | | return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_))); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| InnerMatcher matcher_; | | InnerMatcher matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(NotMatcher); | |
| }; | | }; | |
| | | | |
| // Implements the AllOf(m1, m2) matcher for a particular argument type | | // Implements the AllOf(m1, m2) matcher for a particular argument type | |
| // T. We do not nest it inside the BothOfMatcher class template, as | | // T. We do not nest it inside the BothOfMatcher class template, as | |
| // that will prevent different instantiations of BothOfMatcher from | | // that will prevent different instantiations of BothOfMatcher from | |
| // sharing the same BothOfMatcherImpl<T> class. | | // sharing the same BothOfMatcherImpl<T> class. | |
| template <typename T> | | template <typename T> | |
| class BothOfMatcherImpl : public MatcherInterface<T> { | | class BothOfMatcherImpl : public MatcherInterface<T> { | |
| public: | | public: | |
| BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2) | | BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2) | |
| : matcher1_(matcher1), matcher2_(matcher2) {} | | : matcher1_(matcher1), matcher2_(matcher2) {} | |
| | | | |
|
| virtual bool Matches(T x) const { | | | |
| return matcher1_.Matches(x) && matcher2_.Matches(x); | | | |
| } | | | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| *os << "("; | | *os << "("; | |
| matcher1_.DescribeTo(os); | | matcher1_.DescribeTo(os); | |
| *os << ") and ("; | | *os << ") and ("; | |
| matcher2_.DescribeTo(os); | | matcher2_.DescribeTo(os); | |
| *os << ")"; | | *os << ")"; | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
|
| *os << "not "; | | *os << "("; | |
| DescribeTo(os); | | matcher1_.DescribeNegationTo(os); | |
| | | *os << ") or ("; | |
| | | matcher2_.DescribeNegationTo(os); | |
| | | *os << ")"; | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const { | | virtual bool MatchAndExplain(T x, MatchResultListener* listener) const { | |
| if (Matches(x)) { | | // If either matcher1_ or matcher2_ doesn't match x, we only need | |
| // When both matcher1_ and matcher2_ match x, we need to | | // to explain why one of them fails. | |
| // explain why *both* of them match. | | StringMatchResultListener listener1; | |
| ::std::stringstream ss1; | | if (!matcher1_.MatchAndExplain(x, &listener1)) { | |
| matcher1_.ExplainMatchResultTo(x, &ss1); | | *listener << listener1.str(); | |
| const internal::string s1 = ss1.str(); | | return false; | |
| | | } | |
| | | | |
|
| ::std::stringstream ss2; | | StringMatchResultListener listener2; | |
| matcher2_.ExplainMatchResultTo(x, &ss2); | | if (!matcher2_.MatchAndExplain(x, &listener2)) { | |
| const internal::string s2 = ss2.str(); | | *listener << listener2.str(); | |
| | | return false; | |
| | | } | |
| | | | |
|
| if (s1 == "") { | | // Otherwise we need to explain why *both* of them match. | |
| *os << s2; | | const internal::string s1 = listener1.str(); | |
| } else { | | const internal::string s2 = listener2.str(); | |
| *os << s1; | | | |
| if (s2 != "") { | | if (s1 == "") { | |
| *os << "; " << s2; | | *listener << s2; | |
| } | | | |
| } | | | |
| } else { | | } else { | |
|
| // Otherwise we only need to explain why *one* of them fails | | *listener << s1; | |
| // to match. | | if (s2 != "") { | |
| if (!matcher1_.Matches(x)) { | | *listener << ", and " << s2; | |
| matcher1_.ExplainMatchResultTo(x, os); | | | |
| } else { | | | |
| matcher2_.ExplainMatchResultTo(x, os); | | | |
| } | | } | |
| } | | } | |
|
| | | return true; | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const Matcher<T> matcher1_; | | const Matcher<T> matcher1_; | |
| const Matcher<T> matcher2_; | | const Matcher<T> matcher2_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(BothOfMatcherImpl); | |
| }; | | }; | |
| | | | |
| // Used for implementing the AllOf(m_1, ..., m_n) matcher, which | | // Used for implementing the AllOf(m_1, ..., m_n) matcher, which | |
| // matches a value that matches all of the matchers m_1, ..., and m_n. | | // matches a value that matches all of the matchers m_1, ..., and m_n. | |
| template <typename Matcher1, typename Matcher2> | | template <typename Matcher1, typename Matcher2> | |
| class BothOfMatcher { | | class BothOfMatcher { | |
| public: | | public: | |
| BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2) | | BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2) | |
| : matcher1_(matcher1), matcher2_(matcher2) {} | | : matcher1_(matcher1), matcher2_(matcher2) {} | |
| | | | |
| | | | |
| skipping to change at line 1132 | | skipping to change at line 1261 | |
| : matcher1_(matcher1), matcher2_(matcher2) {} | | : matcher1_(matcher1), matcher2_(matcher2) {} | |
| | | | |
| // This template type conversion operator allows a | | // This template type conversion operator allows a | |
| // BothOfMatcher<Matcher1, Matcher2> object to match any type that | | // BothOfMatcher<Matcher1, Matcher2> object to match any type that | |
| // both Matcher1 and Matcher2 can match. | | // both Matcher1 and Matcher2 can match. | |
| template <typename T> | | template <typename T> | |
| operator Matcher<T>() const { | | operator Matcher<T>() const { | |
| return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_
), | | return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_
), | |
| SafeMatcherCast<T>(matcher2_
))); | | SafeMatcherCast<T>(matcher2_
))); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| Matcher1 matcher1_; | | Matcher1 matcher1_; | |
| Matcher2 matcher2_; | | Matcher2 matcher2_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(BothOfMatcher); | |
| }; | | }; | |
| | | | |
| // Implements the AnyOf(m1, m2) matcher for a particular argument type | | // Implements the AnyOf(m1, m2) matcher for a particular argument type | |
| // T. We do not nest it inside the AnyOfMatcher class template, as | | // T. We do not nest it inside the AnyOfMatcher class template, as | |
| // that will prevent different instantiations of AnyOfMatcher from | | // that will prevent different instantiations of AnyOfMatcher from | |
| // sharing the same EitherOfMatcherImpl<T> class. | | // sharing the same EitherOfMatcherImpl<T> class. | |
| template <typename T> | | template <typename T> | |
| class EitherOfMatcherImpl : public MatcherInterface<T> { | | class EitherOfMatcherImpl : public MatcherInterface<T> { | |
| public: | | public: | |
| EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher
2) | | EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher
2) | |
| : matcher1_(matcher1), matcher2_(matcher2) {} | | : matcher1_(matcher1), matcher2_(matcher2) {} | |
| | | | |
|
| virtual bool Matches(T x) const { | | | |
| return matcher1_.Matches(x) || matcher2_.Matches(x); | | | |
| } | | | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| *os << "("; | | *os << "("; | |
| matcher1_.DescribeTo(os); | | matcher1_.DescribeTo(os); | |
| *os << ") or ("; | | *os << ") or ("; | |
| matcher2_.DescribeTo(os); | | matcher2_.DescribeTo(os); | |
| *os << ")"; | | *os << ")"; | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
|
| *os << "not "; | | *os << "("; | |
| DescribeTo(os); | | matcher1_.DescribeNegationTo(os); | |
| | | *os << ") and ("; | |
| | | matcher2_.DescribeNegationTo(os); | |
| | | *os << ")"; | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const { | | virtual bool MatchAndExplain(T x, MatchResultListener* listener) const { | |
| if (Matches(x)) { | | // If either matcher1_ or matcher2_ matches x, we just need to | |
| // If either matcher1_ or matcher2_ matches x, we just need | | // explain why *one* of them matches. | |
| // to explain why *one* of them matches. | | StringMatchResultListener listener1; | |
| if (matcher1_.Matches(x)) { | | if (matcher1_.MatchAndExplain(x, &listener1)) { | |
| matcher1_.ExplainMatchResultTo(x, os); | | *listener << listener1.str(); | |
| } else { | | return true; | |
| matcher2_.ExplainMatchResultTo(x, os); | | } | |
| } | | | |
| } else { | | | |
| // Otherwise we need to explain why *neither* matches. | | | |
| ::std::stringstream ss1; | | | |
| matcher1_.ExplainMatchResultTo(x, &ss1); | | | |
| const internal::string s1 = ss1.str(); | | | |
| | | | |
|
| ::std::stringstream ss2; | | StringMatchResultListener listener2; | |
| matcher2_.ExplainMatchResultTo(x, &ss2); | | if (matcher2_.MatchAndExplain(x, &listener2)) { | |
| const internal::string s2 = ss2.str(); | | *listener << listener2.str(); | |
| | | return true; | |
| | | } | |
| | | | |
|
| if (s1 == "") { | | // Otherwise we need to explain why *both* of them fail. | |
| *os << s2; | | const internal::string s1 = listener1.str(); | |
| } else { | | const internal::string s2 = listener2.str(); | |
| *os << s1; | | | |
| if (s2 != "") { | | if (s1 == "") { | |
| *os << "; " << s2; | | *listener << s2; | |
| } | | } else { | |
| | | *listener << s1; | |
| | | if (s2 != "") { | |
| | | *listener << ", and " << s2; | |
| } | | } | |
| } | | } | |
|
| | | return false; | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const Matcher<T> matcher1_; | | const Matcher<T> matcher1_; | |
| const Matcher<T> matcher2_; | | const Matcher<T> matcher2_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(EitherOfMatcherImpl); | |
| }; | | }; | |
| | | | |
| // Used for implementing the AnyOf(m_1, ..., m_n) matcher, which | | // Used for implementing the AnyOf(m_1, ..., m_n) matcher, which | |
| // matches a value that matches at least one of the matchers m_1, ..., | | // matches a value that matches at least one of the matchers m_1, ..., | |
| // and m_n. | | // and m_n. | |
| template <typename Matcher1, typename Matcher2> | | template <typename Matcher1, typename Matcher2> | |
| class EitherOfMatcher { | | class EitherOfMatcher { | |
| public: | | public: | |
| EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2) | | EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2) | |
| : matcher1_(matcher1), matcher2_(matcher2) {} | | : matcher1_(matcher1), matcher2_(matcher2) {} | |
| | | | |
| skipping to change at line 1215 | | skipping to change at line 1349 | |
| : matcher1_(matcher1), matcher2_(matcher2) {} | | : matcher1_(matcher1), matcher2_(matcher2) {} | |
| | | | |
| // This template type conversion operator allows a | | // This template type conversion operator allows a | |
| // EitherOfMatcher<Matcher1, Matcher2> object to match any type that | | // EitherOfMatcher<Matcher1, Matcher2> object to match any type that | |
| // both Matcher1 and Matcher2 can match. | | // both Matcher1 and Matcher2 can match. | |
| template <typename T> | | template <typename T> | |
| operator Matcher<T>() const { | | operator Matcher<T>() const { | |
| return Matcher<T>(new EitherOfMatcherImpl<T>( | | return Matcher<T>(new EitherOfMatcherImpl<T>( | |
| SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_))); | | SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_))); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| Matcher1 matcher1_; | | Matcher1 matcher1_; | |
| Matcher2 matcher2_; | | Matcher2 matcher2_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(EitherOfMatcher); | |
| }; | | }; | |
| | | | |
| // Used for implementing Truly(pred), which turns a predicate into a | | // Used for implementing Truly(pred), which turns a predicate into a | |
| // matcher. | | // matcher. | |
| template <typename Predicate> | | template <typename Predicate> | |
| class TrulyMatcher { | | class TrulyMatcher { | |
| public: | | public: | |
| explicit TrulyMatcher(Predicate pred) : predicate_(pred) {} | | explicit TrulyMatcher(Predicate pred) : predicate_(pred) {} | |
| | | | |
| // This method template allows Truly(pred) to be used as a matcher | | // This method template allows Truly(pred) to be used as a matcher | |
| // for type T where T is the argument type of predicate 'pred'. The | | // for type T where T is the argument type of predicate 'pred'. The | |
| // argument is passed by reference as the predicate may be | | // argument is passed by reference as the predicate may be | |
| // interested in the address of the argument. | | // interested in the address of the argument. | |
| template <typename T> | | template <typename T> | |
|
| bool Matches(T& x) const { // NOLINT | | bool MatchAndExplain(T& x, // NOLINT | |
| | | MatchResultListener* /* listener */) const { | |
| #if GTEST_OS_WINDOWS | | #if GTEST_OS_WINDOWS | |
| // MSVC warns about converting a value into bool (warning 4800). | | // MSVC warns about converting a value into bool (warning 4800). | |
| #pragma warning(push) // Saves the current warning state. | | #pragma warning(push) // Saves the current warning state. | |
| #pragma warning(disable:4800) // Temporarily disables warning 4800. | | #pragma warning(disable:4800) // Temporarily disables warning 4800. | |
| #endif // GTEST_OS_WINDOWS | | #endif // GTEST_OS_WINDOWS | |
| return predicate_(x); | | return predicate_(x); | |
| #if GTEST_OS_WINDOWS | | #if GTEST_OS_WINDOWS | |
| #pragma warning(pop) // Restores the warning state. | | #pragma warning(pop) // Restores the warning state. | |
| #endif // GTEST_OS_WINDOWS | | #endif // GTEST_OS_WINDOWS | |
| } | | } | |
| | | | |
| skipping to change at line 1251 | | skipping to change at line 1389 | |
| #endif // GTEST_OS_WINDOWS | | #endif // GTEST_OS_WINDOWS | |
| } | | } | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << "satisfies the given predicate"; | | *os << "satisfies the given predicate"; | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "doesn't satisfy the given predicate"; | | *os << "doesn't satisfy the given predicate"; | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| Predicate predicate_; | | Predicate predicate_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(TrulyMatcher); | |
| }; | | }; | |
| | | | |
| // Used for implementing Matches(matcher), which turns a matcher into | | // Used for implementing Matches(matcher), which turns a matcher into | |
| // a predicate. | | // a predicate. | |
| template <typename M> | | template <typename M> | |
| class MatcherAsPredicate { | | class MatcherAsPredicate { | |
| public: | | public: | |
| explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {} | | explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {} | |
| | | | |
| // This template operator() allows Matches(m) to be used as a | | // This template operator() allows Matches(m) to be used as a | |
| | | | |
| skipping to change at line 1286 | | skipping to change at line 1427 | |
| // compile when matcher_ has type Matcher<const T&>; if we write | | // compile when matcher_ has type Matcher<const T&>; if we write | |
| // Matcher<const T&>(matcher_).Matches(x) here, it won't compile | | // Matcher<const T&>(matcher_).Matches(x) here, it won't compile | |
| // when matcher_ has type Matcher<T>; if we just write | | // when matcher_ has type Matcher<T>; if we just write | |
| // matcher_.Matches(x), it won't compile when matcher_ is | | // matcher_.Matches(x), it won't compile when matcher_ is | |
| // polymorphic, e.g. Eq(5). | | // polymorphic, e.g. Eq(5). | |
| // | | // | |
| // MatcherCast<const T&>() is necessary for making the code work | | // MatcherCast<const T&>() is necessary for making the code work | |
| // in all of the above situations. | | // in all of the above situations. | |
| return MatcherCast<const T&>(matcher_).Matches(x); | | return MatcherCast<const T&>(matcher_).Matches(x); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| M matcher_; | | M matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate); | |
| }; | | }; | |
| | | | |
| // For implementing ASSERT_THAT() and EXPECT_THAT(). The template | | // For implementing ASSERT_THAT() and EXPECT_THAT(). The template | |
| // argument M must be a type that can be converted to a matcher. | | // argument M must be a type that can be converted to a matcher. | |
| template <typename M> | | template <typename M> | |
| class PredicateFormatterFromMatcher { | | class PredicateFormatterFromMatcher { | |
| public: | | public: | |
| explicit PredicateFormatterFromMatcher(const M& m) : matcher_(m) {} | | explicit PredicateFormatterFromMatcher(const M& m) : matcher_(m) {} | |
| | | | |
| // This template () operator allows a PredicateFormatterFromMatcher | | // This template () operator allows a PredicateFormatterFromMatcher | |
| | | | |
| skipping to change at line 1312 | | skipping to change at line 1456 | |
| // We convert matcher_ to a Matcher<const T&> *now* instead of | | // We convert matcher_ to a Matcher<const T&> *now* instead of | |
| // when the PredicateFormatterFromMatcher object was constructed, | | // when the PredicateFormatterFromMatcher object was constructed, | |
| // as matcher_ may be polymorphic (e.g. NotNull()) and we won't | | // as matcher_ may be polymorphic (e.g. NotNull()) and we won't | |
| // know which type to instantiate it to until we actually see the | | // know which type to instantiate it to until we actually see the | |
| // type of x here. | | // type of x here. | |
| // | | // | |
| // We write MatcherCast<const T&>(matcher_) instead of | | // We write MatcherCast<const T&>(matcher_) instead of | |
| // Matcher<const T&>(matcher_), as the latter won't compile when | | // Matcher<const T&>(matcher_), as the latter won't compile when | |
| // matcher_ has type Matcher<T> (e.g. An<int>()). | | // matcher_ has type Matcher<T> (e.g. An<int>()). | |
| const Matcher<const T&> matcher = MatcherCast<const T&>(matcher_); | | const Matcher<const T&> matcher = MatcherCast<const T&>(matcher_); | |
|
| if (matcher.Matches(x)) { | | StringMatchResultListener listener; | |
| | | if (MatchPrintAndExplain(x, matcher, &listener)) | |
| return AssertionSuccess(); | | return AssertionSuccess(); | |
|
| } else { | | | |
| ::std::stringstream ss; | | ::std::stringstream ss; | |
| ss << "Value of: " << value_text << "\n" | | ss << "Value of: " << value_text << "\n" | |
| << "Expected: "; | | << "Expected: "; | |
| matcher.DescribeTo(&ss); | | matcher.DescribeTo(&ss); | |
| ss << "\n Actual: "; | | ss << "\n Actual: " << listener.str(); | |
| UniversalPrinter<T>::Print(x, &ss); | | return AssertionFailure() << ss.str(); | |
| ExplainMatchResultAsNeededTo<const T&>(matcher, x, &ss); | | | |
| return AssertionFailure(Message() << ss.str()); | | | |
| } | | | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const M matcher_; | | const M matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher); | |
| }; | | }; | |
| | | | |
| // A helper function for converting a matcher to a predicate-formatter | | // A helper function for converting a matcher to a predicate-formatter | |
| // without the user needing to explicitly write the type. This is | | // without the user needing to explicitly write the type. This is | |
| // used for implementing ASSERT_THAT() and EXPECT_THAT(). | | // used for implementing ASSERT_THAT() and EXPECT_THAT(). | |
| template <typename M> | | template <typename M> | |
| inline PredicateFormatterFromMatcher<M> | | inline PredicateFormatterFromMatcher<M> | |
| MakePredicateFormatterFromMatcher(const M& matcher) { | | MakePredicateFormatterFromMatcher(const M& matcher) { | |
| return PredicateFormatterFromMatcher<M>(matcher); | | return PredicateFormatterFromMatcher<M>(matcher); | |
| } | | } | |
| | | | |
| skipping to change at line 1359 | | skipping to change at line 1504 | |
| FloatingEqMatcher(FloatType rhs, bool nan_eq_nan) : | | FloatingEqMatcher(FloatType rhs, bool nan_eq_nan) : | |
| rhs_(rhs), nan_eq_nan_(nan_eq_nan) {} | | rhs_(rhs), nan_eq_nan_(nan_eq_nan) {} | |
| | | | |
| // Implements floating point equality matcher as a Matcher<T>. | | // Implements floating point equality matcher as a Matcher<T>. | |
| template <typename T> | | template <typename T> | |
| class Impl : public MatcherInterface<T> { | | class Impl : public MatcherInterface<T> { | |
| public: | | public: | |
| Impl(FloatType rhs, bool nan_eq_nan) : | | Impl(FloatType rhs, bool nan_eq_nan) : | |
| rhs_(rhs), nan_eq_nan_(nan_eq_nan) {} | | rhs_(rhs), nan_eq_nan_(nan_eq_nan) {} | |
| | | | |
|
| virtual bool Matches(T value) const { | | virtual bool MatchAndExplain(T value, | |
| | | MatchResultListener* /* listener */) const | |
| | | { | |
| const FloatingPoint<FloatType> lhs(value), rhs(rhs_); | | const FloatingPoint<FloatType> lhs(value), rhs(rhs_); | |
| | | | |
| // Compares NaNs first, if nan_eq_nan_ is true. | | // Compares NaNs first, if nan_eq_nan_ is true. | |
| if (nan_eq_nan_ && lhs.is_nan()) { | | if (nan_eq_nan_ && lhs.is_nan()) { | |
| return rhs.is_nan(); | | return rhs.is_nan(); | |
| } | | } | |
| | | | |
| return lhs.AlmostEquals(rhs); | | return lhs.AlmostEquals(rhs); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 1394 | | skipping to change at line 1540 | |
| } | | } | |
| os->precision(old_precision); | | os->precision(old_precision); | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| // As before, get original precision. | | // As before, get original precision. | |
| const ::std::streamsize old_precision = os->precision( | | const ::std::streamsize old_precision = os->precision( | |
| ::std::numeric_limits<FloatType>::digits10 + 2); | | ::std::numeric_limits<FloatType>::digits10 + 2); | |
| if (FloatingPoint<FloatType>(rhs_).is_nan()) { | | if (FloatingPoint<FloatType>(rhs_).is_nan()) { | |
| if (nan_eq_nan_) { | | if (nan_eq_nan_) { | |
|
| *os << "is not NaN"; | | *os << "isn't NaN"; | |
| } else { | | } else { | |
| *os << "is anything"; | | *os << "is anything"; | |
| } | | } | |
| } else { | | } else { | |
|
| *os << "is not approximately " << rhs_; | | *os << "isn't approximately " << rhs_; | |
| } | | } | |
| // Restore original precision. | | // Restore original precision. | |
| os->precision(old_precision); | | os->precision(old_precision); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const FloatType rhs_; | | const FloatType rhs_; | |
| const bool nan_eq_nan_; | | const bool nan_eq_nan_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(Impl); | |
| }; | | }; | |
| | | | |
| // The following 3 type conversion operators allow FloatEq(rhs) and | | // The following 3 type conversion operators allow FloatEq(rhs) and | |
| // NanSensitiveFloatEq(rhs) to be used as a Matcher<float>, a | | // NanSensitiveFloatEq(rhs) to be used as a Matcher<float>, a | |
| // Matcher<const float&>, or a Matcher<float&>, but nothing else. | | // Matcher<const float&>, or a Matcher<float&>, but nothing else. | |
| // (While Google's C++ coding style doesn't allow arguments passed | | // (While Google's C++ coding style doesn't allow arguments passed | |
| // by non-const reference, we may see them in code not conforming to | | // by non-const reference, we may see them in code not conforming to | |
| // the style. Therefore Google Mock needs to support them.) | | // the style. Therefore Google Mock needs to support them.) | |
| operator Matcher<FloatType>() const { | | operator Matcher<FloatType>() const { | |
| return MakeMatcher(new Impl<FloatType>(rhs_, nan_eq_nan_)); | | return MakeMatcher(new Impl<FloatType>(rhs_, nan_eq_nan_)); | |
| | | | |
| skipping to change at line 1430 | | skipping to change at line 1578 | |
| operator Matcher<const FloatType&>() const { | | operator Matcher<const FloatType&>() const { | |
| return MakeMatcher(new Impl<const FloatType&>(rhs_, nan_eq_nan_)); | | return MakeMatcher(new Impl<const FloatType&>(rhs_, nan_eq_nan_)); | |
| } | | } | |
| | | | |
| operator Matcher<FloatType&>() const { | | operator Matcher<FloatType&>() const { | |
| return MakeMatcher(new Impl<FloatType&>(rhs_, nan_eq_nan_)); | | return MakeMatcher(new Impl<FloatType&>(rhs_, nan_eq_nan_)); | |
| } | | } | |
| private: | | private: | |
| const FloatType rhs_; | | const FloatType rhs_; | |
| const bool nan_eq_nan_; | | const bool nan_eq_nan_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher); | |
| }; | | }; | |
| | | | |
| // Implements the Pointee(m) matcher for matching a pointer whose | | // Implements the Pointee(m) matcher for matching a pointer whose | |
| // pointee matches matcher m. The pointer can be either raw or smart. | | // pointee matches matcher m. The pointer can be either raw or smart. | |
| template <typename InnerMatcher> | | template <typename InnerMatcher> | |
| class PointeeMatcher { | | class PointeeMatcher { | |
| public: | | public: | |
| explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher)
{} | | explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher)
{} | |
| | | | |
| // This type conversion operator template allows Pointee(m) to be | | // This type conversion operator template allows Pointee(m) to be | |
| | | | |
| skipping to change at line 1462 | | skipping to change at line 1613 | |
| // The monomorphic implementation that works for a particular pointer typ
e. | | // The monomorphic implementation that works for a particular pointer typ
e. | |
| template <typename Pointer> | | template <typename Pointer> | |
| class Impl : public MatcherInterface<Pointer> { | | class Impl : public MatcherInterface<Pointer> { | |
| public: | | public: | |
| typedef typename PointeeOf<GMOCK_REMOVE_CONST_( // NOLINT | | typedef typename PointeeOf<GMOCK_REMOVE_CONST_( // NOLINT | |
| GMOCK_REMOVE_REFERENCE_(Pointer))>::type Pointee; | | GMOCK_REMOVE_REFERENCE_(Pointer))>::type Pointee; | |
| | | | |
| explicit Impl(const InnerMatcher& matcher) | | explicit Impl(const InnerMatcher& matcher) | |
| : matcher_(MatcherCast<const Pointee&>(matcher)) {} | | : matcher_(MatcherCast<const Pointee&>(matcher)) {} | |
| | | | |
|
| virtual bool Matches(Pointer p) const { | | | |
| return GetRawPointer(p) != NULL && matcher_.Matches(*p); | | | |
| } | | | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| *os << "points to a value that "; | | *os << "points to a value that "; | |
| matcher_.DescribeTo(os); | | matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "does not point to a value that "; | | *os << "does not point to a value that "; | |
| matcher_.DescribeTo(os); | | matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(Pointer pointer, | | virtual bool MatchAndExplain(Pointer pointer, | |
| ::std::ostream* os) const { | | MatchResultListener* listener) const { | |
| if (GetRawPointer(pointer) == NULL) | | if (GetRawPointer(pointer) == NULL) | |
|
| return; | | return false; | |
| | | | |
|
| ::std::stringstream ss; | | *listener << "which points to "; | |
| matcher_.ExplainMatchResultTo(*pointer, &ss); | | return MatchPrintAndExplain(*pointer, matcher_, listener); | |
| const internal::string s = ss.str(); | | | |
| if (s != "") { | | | |
| *os << "points to a value that " << s; | | | |
| } | | | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const Matcher<const Pointee&> matcher_; | | const Matcher<const Pointee&> matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(Impl); | |
| }; | | }; | |
| | | | |
| const InnerMatcher matcher_; | | const InnerMatcher matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(PointeeMatcher); | |
| }; | | }; | |
| | | | |
| // Implements the Field() matcher for matching a field (i.e. member | | // Implements the Field() matcher for matching a field (i.e. member | |
| // variable) of an object. | | // variable) of an object. | |
| template <typename Class, typename FieldType> | | template <typename Class, typename FieldType> | |
| class FieldMatcher { | | class FieldMatcher { | |
| public: | | public: | |
| FieldMatcher(FieldType Class::*field, | | FieldMatcher(FieldType Class::*field, | |
| const Matcher<const FieldType&>& matcher) | | const Matcher<const FieldType&>& matcher) | |
| : field_(field), matcher_(matcher) {} | | : field_(field), matcher_(matcher) {} | |
| | | | |
|
| // Returns true iff the inner matcher matches obj.field. | | | |
| bool Matches(const Class& obj) const { | | | |
| return matcher_.Matches(obj.*field_); | | | |
| } | | | |
| | | | |
| // Returns true iff the inner matcher matches obj->field. | | | |
| bool Matches(const Class* p) const { | | | |
| return (p != NULL) && matcher_.Matches(p->*field_); | | | |
| } | | | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
|
| *os << "the given field "; | | *os << "is an object whose given field "; | |
| matcher_.DescribeTo(os); | | matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
|
| *os << "the given field "; | | *os << "is an object whose given field "; | |
| matcher_.DescribeNegationTo(os); | | matcher_.DescribeNegationTo(os); | |
| } | | } | |
| | | | |
|
| // The first argument of ExplainMatchResultTo() is needed to help | | template <typename T> | |
| | | bool MatchAndExplain(const T& value, MatchResultListener* listener) const | |
| | | { | |
| | | return MatchAndExplainImpl( | |
| | | typename ::testing::internal:: | |
| | | is_pointer<GMOCK_REMOVE_CONST_(T)>::type(), | |
| | | value, listener); | |
| | | } | |
| | | | |
| | | private: | |
| | | // The first argument of MatchAndExplainImpl() is needed to help | |
| // Symbian's C++ compiler choose which overload to use. Its type is | | // Symbian's C++ compiler choose which overload to use. Its type is | |
| // true_type iff the Field() matcher is used to match a pointer. | | // true_type iff the Field() matcher is used to match a pointer. | |
|
| void ExplainMatchResultTo(false_type /* is_not_pointer */, const Class& o | | bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& ob | |
| bj, | | j, | |
| ::std::ostream* os) const { | | MatchResultListener* listener) const { | |
| ::std::stringstream ss; | | *listener << "whose given field is "; | |
| matcher_.ExplainMatchResultTo(obj.*field_, &ss); | | return MatchPrintAndExplain(obj.*field_, matcher_, listener); | |
| const internal::string s = ss.str(); | | | |
| if (s != "") { | | | |
| *os << "the given field " << s; | | | |
| } | | | |
| } | | } | |
| | | | |
|
| void ExplainMatchResultTo(true_type /* is_pointer */, const Class* p, | | bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p, | |
| ::std::ostream* os) const { | | MatchResultListener* listener) const { | |
| if (p != NULL) { | | if (p == NULL) | |
| // Since *p has a field, it must be a class/struct/union type | | return false; | |
| // and thus cannot be a pointer. Therefore we pass false_type() | | | |
| // as the first argument. | | *listener << "which points to an object "; | |
| ExplainMatchResultTo(false_type(), *p, os); | | // Since *p has a field, it must be a class/struct/union type and | |
| } | | // thus cannot be a pointer. Therefore we pass false_type() as | |
| | | // the first argument. | |
| | | return MatchAndExplainImpl(false_type(), *p, listener); | |
| } | | } | |
|
| private: | | | |
| const FieldType Class::*field_; | | const FieldType Class::*field_; | |
| const Matcher<const FieldType&> matcher_; | | const Matcher<const FieldType&> matcher_; | |
|
| }; | | | |
| | | | |
|
| // Explains the result of matching an object or pointer against a field mat | | GTEST_DISALLOW_ASSIGN_(FieldMatcher); | |
| cher. | | }; | |
| template <typename Class, typename FieldType, typename T> | | | |
| void ExplainMatchResultTo(const FieldMatcher<Class, FieldType>& matcher, | | | |
| const T& value, ::std::ostream* os) { | | | |
| matcher.ExplainMatchResultTo( | | | |
| typename ::testing::internal::is_pointer<T>::type(), value, os); | | | |
| } | | | |
| | | | |
| // Implements the Property() matcher for matching a property | | // Implements the Property() matcher for matching a property | |
| // (i.e. return value of a getter method) of an object. | | // (i.e. return value of a getter method) of an object. | |
| template <typename Class, typename PropertyType> | | template <typename Class, typename PropertyType> | |
| class PropertyMatcher { | | class PropertyMatcher { | |
| public: | | public: | |
| // The property may have a reference type, so 'const PropertyType&' | | // The property may have a reference type, so 'const PropertyType&' | |
| // may cause double references and fail to compile. That's why we | | // may cause double references and fail to compile. That's why we | |
| // need GMOCK_REFERENCE_TO_CONST, which works regardless of | | // need GMOCK_REFERENCE_TO_CONST, which works regardless of | |
| // PropertyType being a reference or not. | | // PropertyType being a reference or not. | |
| typedef GMOCK_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty; | | typedef GMOCK_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty; | |
| | | | |
| PropertyMatcher(PropertyType (Class::*property)() const, | | PropertyMatcher(PropertyType (Class::*property)() const, | |
| const Matcher<RefToConstProperty>& matcher) | | const Matcher<RefToConstProperty>& matcher) | |
| : property_(property), matcher_(matcher) {} | | : property_(property), matcher_(matcher) {} | |
| | | | |
|
| // Returns true iff obj.property() matches the inner matcher. | | | |
| bool Matches(const Class& obj) const { | | | |
| return matcher_.Matches((obj.*property_)()); | | | |
| } | | | |
| | | | |
| // Returns true iff p->property() matches the inner matcher. | | | |
| bool Matches(const Class* p) const { | | | |
| return (p != NULL) && matcher_.Matches((p->*property_)()); | | | |
| } | | | |
| | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
|
| *os << "the given property "; | | *os << "is an object whose given property "; | |
| matcher_.DescribeTo(os); | | matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
|
| *os << "the given property "; | | *os << "is an object whose given property "; | |
| matcher_.DescribeNegationTo(os); | | matcher_.DescribeNegationTo(os); | |
| } | | } | |
| | | | |
|
| // The first argument of ExplainMatchResultTo() is needed to help | | template <typename T> | |
| | | bool MatchAndExplain(const T&value, MatchResultListener* listener) const | |
| | | { | |
| | | return MatchAndExplainImpl( | |
| | | typename ::testing::internal:: | |
| | | is_pointer<GMOCK_REMOVE_CONST_(T)>::type(), | |
| | | value, listener); | |
| | | } | |
| | | | |
| | | private: | |
| | | // The first argument of MatchAndExplainImpl() is needed to help | |
| // Symbian's C++ compiler choose which overload to use. Its type is | | // Symbian's C++ compiler choose which overload to use. Its type is | |
| // true_type iff the Property() matcher is used to match a pointer. | | // true_type iff the Property() matcher is used to match a pointer. | |
|
| void ExplainMatchResultTo(false_type /* is_not_pointer */, const Class& o | | bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& ob | |
| bj, | | j, | |
| ::std::ostream* os) const { | | MatchResultListener* listener) const { | |
| ::std::stringstream ss; | | *listener << "whose given property is "; | |
| matcher_.ExplainMatchResultTo((obj.*property_)(), &ss); | | // Cannot pass the return value (for example, int) to MatchPrintAndExpl | |
| const internal::string s = ss.str(); | | ain, | |
| if (s != "") { | | // which takes a non-const reference as argument. | |
| *os << "the given property " << s; | | RefToConstProperty result = (obj.*property_)(); | |
| } | | return MatchPrintAndExplain(result, matcher_, listener); | |
| } | | } | |
| | | | |
|
| void ExplainMatchResultTo(true_type /* is_pointer */, const Class* p, | | bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p, | |
| ::std::ostream* os) const { | | MatchResultListener* listener) const { | |
| if (p != NULL) { | | if (p == NULL) | |
| // Since *p has a property method, it must be a | | return false; | |
| // class/struct/union type and thus cannot be a pointer. | | | |
| // Therefore we pass false_type() as the first argument. | | *listener << "which points to an object "; | |
| ExplainMatchResultTo(false_type(), *p, os); | | // Since *p has a property method, it must be a class/struct/union | |
| } | | // type and thus cannot be a pointer. Therefore we pass | |
| | | // false_type() as the first argument. | |
| | | return MatchAndExplainImpl(false_type(), *p, listener); | |
| } | | } | |
|
| private: | | | |
| PropertyType (Class::*property_)() const; | | PropertyType (Class::*property_)() const; | |
| const Matcher<RefToConstProperty> matcher_; | | const Matcher<RefToConstProperty> matcher_; | |
|
| }; | | | |
| | | | |
|
| // Explains the result of matching an object or pointer against a | | GTEST_DISALLOW_ASSIGN_(PropertyMatcher); | |
| // property matcher. | | }; | |
| template <typename Class, typename PropertyType, typename T> | | | |
| void ExplainMatchResultTo(const PropertyMatcher<Class, PropertyType>& match | | | |
| er, | | | |
| const T& value, ::std::ostream* os) { | | | |
| matcher.ExplainMatchResultTo( | | | |
| typename ::testing::internal::is_pointer<T>::type(), value, os); | | | |
| } | | | |
| | | | |
| // Type traits specifying various features of different functors for Result
Of. | | // Type traits specifying various features of different functors for Result
Of. | |
| // The default template specifies features for functor objects. | | // The default template specifies features for functor objects. | |
| // Functor classes have to typedef argument_type and result_type | | // Functor classes have to typedef argument_type and result_type | |
| // to be compatible with ResultOf. | | // to be compatible with ResultOf. | |
| template <typename Functor> | | template <typename Functor> | |
| struct CallableTraits { | | struct CallableTraits { | |
| typedef typename Functor::result_type ResultType; | | typedef typename Functor::result_type ResultType; | |
| typedef Functor StorageType; | | typedef Functor StorageType; | |
| | | | |
|
| static void CheckIsValid(Functor functor) {} | | static void CheckIsValid(Functor /* functor */) {} | |
| template <typename T> | | template <typename T> | |
| static ResultType Invoke(Functor f, T arg) { return f(arg); } | | static ResultType Invoke(Functor f, T arg) { return f(arg); } | |
| }; | | }; | |
| | | | |
| // Specialization for function pointers. | | // Specialization for function pointers. | |
| template <typename ArgType, typename ResType> | | template <typename ArgType, typename ResType> | |
| struct CallableTraits<ResType(*)(ArgType)> { | | struct CallableTraits<ResType(*)(ArgType)> { | |
| typedef ResType ResultType; | | typedef ResType ResultType; | |
| typedef ResType(*StorageType)(ArgType); | | typedef ResType(*StorageType)(ArgType); | |
| | | | |
| | | | |
| skipping to change at line 1685 | | skipping to change at line 1817 | |
| } | | } | |
| | | | |
| private: | | private: | |
| typedef typename CallableTraits<Callable>::StorageType CallableStorageTyp
e; | | typedef typename CallableTraits<Callable>::StorageType CallableStorageTyp
e; | |
| | | | |
| template <typename T> | | template <typename T> | |
| class Impl : public MatcherInterface<T> { | | class Impl : public MatcherInterface<T> { | |
| public: | | public: | |
| Impl(CallableStorageType callable, const Matcher<ResultType>& matcher) | | Impl(CallableStorageType callable, const Matcher<ResultType>& matcher) | |
| : callable_(callable), matcher_(matcher) {} | | : callable_(callable), matcher_(matcher) {} | |
|
| // Returns true iff callable_(obj) matches the inner matcher. | | | |
| // The calling syntax is different for different types of callables | | | |
| // so we abstract it in CallableTraits<Callable>::Invoke(). | | | |
| virtual bool Matches(T obj) const { | | | |
| return matcher_.Matches( | | | |
| CallableTraits<Callable>::template Invoke<T>(callable_, obj)); | | | |
| } | | | |
| | | | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
|
| *os << "result of the given callable "; | | *os << "is mapped by the given callable to a value that "; | |
| matcher_.DescribeTo(os); | | matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
|
| *os << "result of the given callable "; | | *os << "is mapped by the given callable to a value that "; | |
| matcher_.DescribeNegationTo(os); | | matcher_.DescribeNegationTo(os); | |
| } | | } | |
| | | | |
|
| virtual void ExplainMatchResultTo(T obj, ::std::ostream* os) const { | | virtual bool MatchAndExplain(T obj, MatchResultListener* listener) cons | |
| ::std::stringstream ss; | | t { | |
| matcher_.ExplainMatchResultTo( | | *listener << "which is mapped by the given callable to "; | |
| CallableTraits<Callable>::template Invoke<T>(callable_, obj), | | // Cannot pass the return value (for example, int) to | |
| &ss); | | // MatchPrintAndExplain, which takes a non-const reference as argumen | |
| const internal::string s = ss.str(); | | t. | |
| if (s != "") | | ResultType result = | |
| *os << "result of the given callable " << s; | | CallableTraits<Callable>::template Invoke<T>(callable_, obj); | |
| | | return MatchPrintAndExplain(result, matcher_, listener); | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| // Functors often define operator() as non-const method even though | | // Functors often define operator() as non-const method even though | |
| // they are actualy stateless. But we need to use them even when | | // they are actualy stateless. But we need to use them even when | |
| // 'this' is a const pointer. It's the user's responsibility not to | | // 'this' is a const pointer. It's the user's responsibility not to | |
| // use stateful callables with ResultOf(), which does't guarantee | | // use stateful callables with ResultOf(), which does't guarantee | |
| // how many times the callable will be invoked. | | // how many times the callable will be invoked. | |
| mutable CallableStorageType callable_; | | mutable CallableStorageType callable_; | |
| const Matcher<ResultType> matcher_; | | const Matcher<ResultType> matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(Impl); | |
| }; // class Impl | | }; // class Impl | |
| | | | |
| const CallableStorageType callable_; | | const CallableStorageType callable_; | |
| const Matcher<ResultType> matcher_; | | const Matcher<ResultType> matcher_; | |
|
| }; | | | |
| | | | |
|
| // Explains the result of matching a value against a functor matcher. | | GTEST_DISALLOW_ASSIGN_(ResultOfMatcher); | |
| template <typename T, typename Callable> | | }; | |
| void ExplainMatchResultTo(const ResultOfMatcher<Callable>& matcher, | | | |
| T obj, ::std::ostream* os) { | | | |
| matcher.ExplainMatchResultTo(obj, os); | | | |
| } | | | |
| | | | |
| // Implements an equality matcher for any STL-style container whose element
s | | // Implements an equality matcher for any STL-style container whose element
s | |
| // support ==. This matcher is like Eq(), but its failure explanations prov
ide | | // support ==. This matcher is like Eq(), but its failure explanations prov
ide | |
| // more detailed information that is useful when the container is used as a
set. | | // more detailed information that is useful when the container is used as a
set. | |
| // The failure message reports elements that are in one of the operands but
not | | // The failure message reports elements that are in one of the operands but
not | |
| // the other. The failure messages do not report duplicate or out-of-order | | // the other. The failure messages do not report duplicate or out-of-order | |
| // elements in the containers (which don't properly matter to sets, but can | | // elements in the containers (which don't properly matter to sets, but can | |
| // occur if the containers are vectors or lists, for example). | | // occur if the containers are vectors or lists, for example). | |
| // | | // | |
| // Uses the container's const_iterator, value_type, operator ==, | | // Uses the container's const_iterator, value_type, operator ==, | |
| | | | |
| skipping to change at line 1759 | | skipping to change at line 1881 | |
| | | | |
| // We make a copy of rhs in case the elements in it are modified | | // We make a copy of rhs in case the elements in it are modified | |
| // after this matcher is created. | | // after this matcher is created. | |
| explicit ContainerEqMatcher(const Container& rhs) : rhs_(View::Copy(rhs))
{ | | explicit ContainerEqMatcher(const Container& rhs) : rhs_(View::Copy(rhs))
{ | |
| // Makes sure the user doesn't instantiate this class template | | // Makes sure the user doesn't instantiate this class template | |
| // with a const or reference type. | | // with a const or reference type. | |
| testing::StaticAssertTypeEq<Container, | | testing::StaticAssertTypeEq<Container, | |
| GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))>(); | | GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container))>(); | |
| } | | } | |
| | | | |
|
| template <typename LhsContainer> | | | |
| bool Matches(const LhsContainer& lhs) const { | | | |
| // GMOCK_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug | | | |
| // that causes LhsContainer to be a const type sometimes. | | | |
| typedef internal::StlContainerView<GMOCK_REMOVE_CONST_(LhsContainer)> | | | |
| LhsView; | | | |
| StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs); | | | |
| return lhs_stl_container == rhs_; | | | |
| } | | | |
| void DescribeTo(::std::ostream* os) const { | | void DescribeTo(::std::ostream* os) const { | |
| *os << "equals "; | | *os << "equals "; | |
| UniversalPrinter<StlContainer>::Print(rhs_, os); | | UniversalPrinter<StlContainer>::Print(rhs_, os); | |
| } | | } | |
| void DescribeNegationTo(::std::ostream* os) const { | | void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "does not equal "; | | *os << "does not equal "; | |
| UniversalPrinter<StlContainer>::Print(rhs_, os); | | UniversalPrinter<StlContainer>::Print(rhs_, os); | |
| } | | } | |
| | | | |
| template <typename LhsContainer> | | template <typename LhsContainer> | |
|
| void ExplainMatchResultTo(const LhsContainer& lhs, | | bool MatchAndExplain(const LhsContainer& lhs, | |
| ::std::ostream* os) const { | | MatchResultListener* listener) const { | |
| // GMOCK_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug | | // GMOCK_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug | |
| // that causes LhsContainer to be a const type sometimes. | | // that causes LhsContainer to be a const type sometimes. | |
| typedef internal::StlContainerView<GMOCK_REMOVE_CONST_(LhsContainer)> | | typedef internal::StlContainerView<GMOCK_REMOVE_CONST_(LhsContainer)> | |
| LhsView; | | LhsView; | |
| typedef typename LhsView::type LhsStlContainer; | | typedef typename LhsView::type LhsStlContainer; | |
| StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs); | | StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs); | |
|
| | | if (lhs_stl_container == rhs_) | |
| | | return true; | |
| | | | |
|
| // Something is different. Check for missing values first. | | ::std::ostream* const os = listener->stream(); | |
| bool printed_header = false; | | if (os != NULL) { | |
| for (typename LhsStlContainer::const_iterator it = | | // Something is different. Check for extra values first. | |
| lhs_stl_container.begin(); | | bool printed_header = false; | |
| it != lhs_stl_container.end(); ++it) { | | for (typename LhsStlContainer::const_iterator it = | |
| if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) == | | lhs_stl_container.begin(); | |
| rhs_.end()) { | | it != lhs_stl_container.end(); ++it) { | |
| if (printed_header) { | | if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) == | |
| *os << ", "; | | rhs_.end()) { | |
| } else { | | if (printed_header) { | |
| *os << "Only in actual: "; | | *os << ", "; | |
| printed_header = true; | | } else { | |
| | | *os << "which has these unexpected elements: "; | |
| | | printed_header = true; | |
| | | } | |
| | | UniversalPrinter<typename LhsStlContainer::value_type>:: | |
| | | Print(*it, os); | |
| } | | } | |
|
| UniversalPrinter<typename LhsStlContainer::value_type>::Print(*it,
os); | | | |
| } | | } | |
|
| } | | | |
| | | | |
|
| // Now check for extra values. | | // Now check for missing values. | |
| bool printed_header2 = false; | | bool printed_header2 = false; | |
| for (typename StlContainer::const_iterator it = rhs_.begin(); | | for (typename StlContainer::const_iterator it = rhs_.begin(); | |
| it != rhs_.end(); ++it) { | | it != rhs_.end(); ++it) { | |
| if (internal::ArrayAwareFind( | | if (internal::ArrayAwareFind( | |
| lhs_stl_container.begin(), lhs_stl_container.end(), *it) == | | lhs_stl_container.begin(), lhs_stl_container.end(), *it) == | |
| lhs_stl_container.end()) { | | lhs_stl_container.end()) { | |
| if (printed_header2) { | | if (printed_header2) { | |
| *os << ", "; | | *os << ", "; | |
| } else { | | } else { | |
| *os << (printed_header ? "; not" : "Not") << " in actual: "; | | *os << (printed_header ? ",\nand" : "which") | |
| printed_header2 = true; | | << " doesn't have these expected elements: "; | |
| | | printed_header2 = true; | |
| | | } | |
| | | UniversalPrinter<typename StlContainer::value_type>::Print(*it, o | |
| | | s); | |
| } | | } | |
|
| UniversalPrinter<typename StlContainer::value_type>::Print(*it, os)
; | | | |
| } | | } | |
| } | | } | |
|
| | | | |
| | | return false; | |
| } | | } | |
|
| | | | |
| private: | | private: | |
| const StlContainer rhs_; | | const StlContainer rhs_; | |
|
| }; | | | |
| | | | |
|
| template <typename LhsContainer, typename Container> | | GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher); | |
| void ExplainMatchResultTo(const ContainerEqMatcher<Container>& matcher, | | }; | |
| const LhsContainer& lhs, | | | |
| ::std::ostream* os) { | | | |
| matcher.ExplainMatchResultTo(lhs, os); | | | |
| } | | | |
| | | | |
| // Implements Contains(element_matcher) for the given argument type Contain
er. | | // Implements Contains(element_matcher) for the given argument type Contain
er. | |
| template <typename Container> | | template <typename Container> | |
| class ContainsMatcherImpl : public MatcherInterface<Container> { | | class ContainsMatcherImpl : public MatcherInterface<Container> { | |
| public: | | public: | |
| typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) RawContai
ner; | | typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) RawContai
ner; | |
| typedef StlContainerView<RawContainer> View; | | typedef StlContainerView<RawContainer> View; | |
| typedef typename View::type StlContainer; | | typedef typename View::type StlContainer; | |
| typedef typename View::const_reference StlContainerReference; | | typedef typename View::const_reference StlContainerReference; | |
| typedef typename StlContainer::value_type Element; | | typedef typename StlContainer::value_type Element; | |
| | | | |
| template <typename InnerMatcher> | | template <typename InnerMatcher> | |
| explicit ContainsMatcherImpl(InnerMatcher inner_matcher) | | explicit ContainsMatcherImpl(InnerMatcher inner_matcher) | |
| : inner_matcher_( | | : inner_matcher_( | |
| testing::SafeMatcherCast<const Element&>(inner_matcher)) {} | | testing::SafeMatcherCast<const Element&>(inner_matcher)) {} | |
| | | | |
|
| // Returns true iff 'container' matches. | | | |
| virtual bool Matches(Container container) const { | | | |
| StlContainerReference stl_container = View::ConstReference(container); | | | |
| for (typename StlContainer::const_iterator it = stl_container.begin(); | | | |
| it != stl_container.end(); ++it) { | | | |
| if (inner_matcher_.Matches(*it)) | | | |
| return true; | | | |
| } | | | |
| return false; | | | |
| } | | | |
| | | | |
| // Describes what this matcher does. | | // Describes what this matcher does. | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| *os << "contains at least one element that "; | | *os << "contains at least one element that "; | |
| inner_matcher_.DescribeTo(os); | | inner_matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| // Describes what the negation of this matcher does. | | // Describes what the negation of this matcher does. | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "doesn't contain any element that "; | | *os << "doesn't contain any element that "; | |
| inner_matcher_.DescribeTo(os); | | inner_matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
|
| // Explains why 'container' matches, or doesn't match, this matcher. | | virtual bool MatchAndExplain(Container container, | |
| virtual void ExplainMatchResultTo(Container container, | | MatchResultListener* listener) const { | |
| ::std::ostream* os) const { | | | |
| StlContainerReference stl_container = View::ConstReference(container); | | StlContainerReference stl_container = View::ConstReference(container); | |
|
| | | size_t i = 0; | |
| // We need to explain which (if any) element matches inner_matcher_. | | for (typename StlContainer::const_iterator it = stl_container.begin(); | |
| typename StlContainer::const_iterator it = stl_container.begin(); | | it != stl_container.end(); ++it, ++i) { | |
| for (size_t i = 0; it != stl_container.end(); ++it, ++i) { | | StringMatchResultListener inner_listener; | |
| if (inner_matcher_.Matches(*it)) { | | if (inner_matcher_.MatchAndExplain(*it, &inner_listener)) { | |
| *os << "element " << i << " matches"; | | *listener << "whose element #" << i << " matches"; | |
| return; | | PrintIfNotEmpty(inner_listener.str(), listener->stream()); | |
| | | return true; | |
| } | | } | |
| } | | } | |
|
| | | return false; | |
| } | | } | |
| | | | |
| private: | | private: | |
| const Matcher<const Element&> inner_matcher_; | | const Matcher<const Element&> inner_matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl); | |
| }; | | }; | |
| | | | |
| // Implements polymorphic Contains(element_matcher). | | // Implements polymorphic Contains(element_matcher). | |
| template <typename M> | | template <typename M> | |
| class ContainsMatcher { | | class ContainsMatcher { | |
| public: | | public: | |
| explicit ContainsMatcher(M m) : inner_matcher_(m) {} | | explicit ContainsMatcher(M m) : inner_matcher_(m) {} | |
| | | | |
| template <typename Container> | | template <typename Container> | |
| operator Matcher<Container>() const { | | operator Matcher<Container>() const { | |
| return MakeMatcher(new ContainsMatcherImpl<Container>(inner_matcher_)); | | return MakeMatcher(new ContainsMatcherImpl<Container>(inner_matcher_)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const M inner_matcher_; | | const M inner_matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ContainsMatcher); | |
| }; | | }; | |
| | | | |
| // Implements Key(inner_matcher) for the given argument pair type. | | // Implements Key(inner_matcher) for the given argument pair type. | |
| // Key(inner_matcher) matches an std::pair whose 'first' field matches | | // Key(inner_matcher) matches an std::pair whose 'first' field matches | |
| // inner_matcher. For example, Contains(Key(Ge(5))) can be used to match a
n | | // inner_matcher. For example, Contains(Key(Ge(5))) can be used to match a
n | |
| // std::map that contains at least one element whose key is >= 5. | | // std::map that contains at least one element whose key is >= 5. | |
| template <typename PairType> | | template <typename PairType> | |
| class KeyMatcherImpl : public MatcherInterface<PairType> { | | class KeyMatcherImpl : public MatcherInterface<PairType> { | |
| public: | | public: | |
| typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(PairType)) RawPairTyp
e; | | typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(PairType)) RawPairTyp
e; | |
| typedef typename RawPairType::first_type KeyType; | | typedef typename RawPairType::first_type KeyType; | |
| | | | |
| template <typename InnerMatcher> | | template <typename InnerMatcher> | |
| explicit KeyMatcherImpl(InnerMatcher inner_matcher) | | explicit KeyMatcherImpl(InnerMatcher inner_matcher) | |
| : inner_matcher_( | | : inner_matcher_( | |
| testing::SafeMatcherCast<const KeyType&>(inner_matcher)) { | | testing::SafeMatcherCast<const KeyType&>(inner_matcher)) { | |
| } | | } | |
| | | | |
| // Returns true iff 'key_value.first' (the key) matches the inner matcher
. | | // Returns true iff 'key_value.first' (the key) matches the inner matcher
. | |
|
| virtual bool Matches(PairType key_value) const { | | virtual bool MatchAndExplain(PairType key_value, | |
| return inner_matcher_.Matches(key_value.first); | | MatchResultListener* listener) const { | |
| | | StringMatchResultListener inner_listener; | |
| | | const bool match = inner_matcher_.MatchAndExplain(key_value.first, | |
| | | &inner_listener); | |
| | | const internal::string explanation = inner_listener.str(); | |
| | | if (explanation != "") { | |
| | | *listener << "whose first field is a value " << explanation; | |
| | | } | |
| | | return match; | |
| } | | } | |
| | | | |
| // Describes what this matcher does. | | // Describes what this matcher does. | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| *os << "has a key that "; | | *os << "has a key that "; | |
| inner_matcher_.DescribeTo(os); | | inner_matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| // Describes what the negation of this matcher does. | | // Describes what the negation of this matcher does. | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "doesn't have a key that "; | | *os << "doesn't have a key that "; | |
| inner_matcher_.DescribeTo(os); | | inner_matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
|
| // Explains why 'key_value' matches, or doesn't match, this matcher. | | | |
| virtual void ExplainMatchResultTo(PairType key_value, | | | |
| ::std::ostream* os) const { | | | |
| inner_matcher_.ExplainMatchResultTo(key_value.first, os); | | | |
| } | | | |
| | | | |
| private: | | private: | |
| const Matcher<const KeyType&> inner_matcher_; | | const Matcher<const KeyType&> inner_matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl); | |
| }; | | }; | |
| | | | |
| // Implements polymorphic Key(matcher_for_key). | | // Implements polymorphic Key(matcher_for_key). | |
| template <typename M> | | template <typename M> | |
| class KeyMatcher { | | class KeyMatcher { | |
| public: | | public: | |
| explicit KeyMatcher(M m) : matcher_for_key_(m) {} | | explicit KeyMatcher(M m) : matcher_for_key_(m) {} | |
| | | | |
| template <typename PairType> | | template <typename PairType> | |
| operator Matcher<PairType>() const { | | operator Matcher<PairType>() const { | |
| return MakeMatcher(new KeyMatcherImpl<PairType>(matcher_for_key_)); | | return MakeMatcher(new KeyMatcherImpl<PairType>(matcher_for_key_)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const M matcher_for_key_; | | const M matcher_for_key_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(KeyMatcher); | |
| }; | | }; | |
| | | | |
| // Implements Pair(first_matcher, second_matcher) for the given argument pa
ir | | // Implements Pair(first_matcher, second_matcher) for the given argument pa
ir | |
| // type with its two matchers. See Pair() function below. | | // type with its two matchers. See Pair() function below. | |
| template <typename PairType> | | template <typename PairType> | |
| class PairMatcherImpl : public MatcherInterface<PairType> { | | class PairMatcherImpl : public MatcherInterface<PairType> { | |
| public: | | public: | |
| typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(PairType)) RawPairTyp
e; | | typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(PairType)) RawPairTyp
e; | |
| typedef typename RawPairType::first_type FirstType; | | typedef typename RawPairType::first_type FirstType; | |
| typedef typename RawPairType::second_type SecondType; | | typedef typename RawPairType::second_type SecondType; | |
| | | | |
| template <typename FirstMatcher, typename SecondMatcher> | | template <typename FirstMatcher, typename SecondMatcher> | |
| PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher) | | PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher) | |
| : first_matcher_( | | : first_matcher_( | |
| testing::SafeMatcherCast<const FirstType&>(first_matcher)), | | testing::SafeMatcherCast<const FirstType&>(first_matcher)), | |
| second_matcher_( | | second_matcher_( | |
| testing::SafeMatcherCast<const SecondType&>(second_matcher)) { | | testing::SafeMatcherCast<const SecondType&>(second_matcher)) { | |
| } | | } | |
| | | | |
|
| // Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.seco | | | |
| nd' | | | |
| // matches second_matcher. | | | |
| virtual bool Matches(PairType a_pair) const { | | | |
| return first_matcher_.Matches(a_pair.first) && | | | |
| second_matcher_.Matches(a_pair.second); | | | |
| } | | | |
| | | | |
| // Describes what this matcher does. | | // Describes what this matcher does. | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| *os << "has a first field that "; | | *os << "has a first field that "; | |
| first_matcher_.DescribeTo(os); | | first_matcher_.DescribeTo(os); | |
| *os << ", and has a second field that "; | | *os << ", and has a second field that "; | |
| second_matcher_.DescribeTo(os); | | second_matcher_.DescribeTo(os); | |
| } | | } | |
| | | | |
| // Describes what the negation of this matcher does. | | // Describes what the negation of this matcher does. | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| *os << "has a first field that "; | | *os << "has a first field that "; | |
| first_matcher_.DescribeNegationTo(os); | | first_matcher_.DescribeNegationTo(os); | |
| *os << ", or has a second field that "; | | *os << ", or has a second field that "; | |
| second_matcher_.DescribeNegationTo(os); | | second_matcher_.DescribeNegationTo(os); | |
| } | | } | |
| | | | |
|
| // Explains why 'a_pair' matches, or doesn't match, this matcher. | | // Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.seco | |
| virtual void ExplainMatchResultTo(PairType a_pair, | | nd' | |
| ::std::ostream* os) const { | | // matches second_matcher. | |
| ::std::stringstream ss1; | | virtual bool MatchAndExplain(PairType a_pair, | |
| first_matcher_.ExplainMatchResultTo(a_pair.first, &ss1); | | MatchResultListener* listener) const { | |
| internal::string s1 = ss1.str(); | | if (!listener->IsInterested()) { | |
| if (s1 != "") { | | // If the listener is not interested, we don't need to construct the | |
| s1 = "the first field " + s1; | | // explanation. | |
| | | return first_matcher_.Matches(a_pair.first) && | |
| | | second_matcher_.Matches(a_pair.second); | |
| } | | } | |
|
| | | StringMatchResultListener first_inner_listener; | |
| ::std::stringstream ss2; | | if (!first_matcher_.MatchAndExplain(a_pair.first, | |
| second_matcher_.ExplainMatchResultTo(a_pair.second, &ss2); | | &first_inner_listener)) { | |
| internal::string s2 = ss2.str(); | | *listener << "whose first field does not match"; | |
| if (s2 != "") { | | PrintIfNotEmpty(first_inner_listener.str(), listener->stream()); | |
| s2 = "the second field " + s2; | | return false; | |
| } | | } | |
|
| | | StringMatchResultListener second_inner_listener; | |
| *os << s1; | | if (!second_matcher_.MatchAndExplain(a_pair.second, | |
| if (s1 != "" && s2 != "") { | | &second_inner_listener)) { | |
| *os << ", and "; | | *listener << "whose second field does not match"; | |
| | | PrintIfNotEmpty(second_inner_listener.str(), listener->stream()); | |
| | | return false; | |
| } | | } | |
|
| *os << s2; | | ExplainSuccess(first_inner_listener.str(), second_inner_listener.str(), | |
| | | listener); | |
| | | return true; | |
| } | | } | |
| | | | |
| private: | | private: | |
|
| | | void ExplainSuccess(const internal::string& first_explanation, | |
| | | const internal::string& second_explanation, | |
| | | MatchResultListener* listener) const { | |
| | | *listener << "whose both fields match"; | |
| | | if (first_explanation != "") { | |
| | | *listener << ", where the first field is a value " << first_explanati | |
| | | on; | |
| | | } | |
| | | if (second_explanation != "") { | |
| | | *listener << ", "; | |
| | | if (first_explanation != "") { | |
| | | *listener << "and "; | |
| | | } else { | |
| | | *listener << "where "; | |
| | | } | |
| | | *listener << "the second field is a value " << second_explanation; | |
| | | } | |
| | | } | |
| | | | |
| const Matcher<const FirstType&> first_matcher_; | | const Matcher<const FirstType&> first_matcher_; | |
| const Matcher<const SecondType&> second_matcher_; | | const Matcher<const SecondType&> second_matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(PairMatcherImpl); | |
| }; | | }; | |
| | | | |
| // Implements polymorphic Pair(first_matcher, second_matcher). | | // Implements polymorphic Pair(first_matcher, second_matcher). | |
| template <typename FirstMatcher, typename SecondMatcher> | | template <typename FirstMatcher, typename SecondMatcher> | |
| class PairMatcher { | | class PairMatcher { | |
| public: | | public: | |
| PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher) | | PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher) | |
| : first_matcher_(first_matcher), second_matcher_(second_matcher) {} | | : first_matcher_(first_matcher), second_matcher_(second_matcher) {} | |
| | | | |
| template <typename PairType> | | template <typename PairType> | |
| operator Matcher<PairType> () const { | | operator Matcher<PairType> () const { | |
| return MakeMatcher( | | return MakeMatcher( | |
| new PairMatcherImpl<PairType>( | | new PairMatcherImpl<PairType>( | |
| first_matcher_, second_matcher_)); | | first_matcher_, second_matcher_)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const FirstMatcher first_matcher_; | | const FirstMatcher first_matcher_; | |
| const SecondMatcher second_matcher_; | | const SecondMatcher second_matcher_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(PairMatcher); | |
| }; | | }; | |
| | | | |
| // Implements ElementsAre() and ElementsAreArray(). | | // Implements ElementsAre() and ElementsAreArray(). | |
| template <typename Container> | | template <typename Container> | |
| class ElementsAreMatcherImpl : public MatcherInterface<Container> { | | class ElementsAreMatcherImpl : public MatcherInterface<Container> { | |
| public: | | public: | |
| typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) RawContai
ner; | | typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) RawContai
ner; | |
| typedef internal::StlContainerView<RawContainer> View; | | typedef internal::StlContainerView<RawContainer> View; | |
| typedef typename View::type StlContainer; | | typedef typename View::type StlContainer; | |
| typedef typename View::const_reference StlContainerReference; | | typedef typename View::const_reference StlContainerReference; | |
| typedef typename StlContainer::value_type Element; | | typedef typename StlContainer::value_type Element; | |
| | | | |
| // Constructs the matcher from a sequence of element values or | | // Constructs the matcher from a sequence of element values or | |
| // element matchers. | | // element matchers. | |
| template <typename InputIter> | | template <typename InputIter> | |
|
| ElementsAreMatcherImpl(InputIter first, size_t count) { | | ElementsAreMatcherImpl(InputIter first, size_t a_count) { | |
| matchers_.reserve(count); | | matchers_.reserve(a_count); | |
| InputIter it = first; | | InputIter it = first; | |
|
| for (size_t i = 0; i != count; ++i, ++it) { | | for (size_t i = 0; i != a_count; ++i, ++it) { | |
| matchers_.push_back(MatcherCast<const Element&>(*it)); | | matchers_.push_back(MatcherCast<const Element&>(*it)); | |
| } | | } | |
| } | | } | |
| | | | |
|
| // Returns true iff 'container' matches. | | | |
| virtual bool Matches(Container container) const { | | | |
| StlContainerReference stl_container = View::ConstReference(container); | | | |
| if (stl_container.size() != count()) | | | |
| return false; | | | |
| | | | |
| typename StlContainer::const_iterator it = stl_container.begin(); | | | |
| for (size_t i = 0; i != count(); ++it, ++i) { | | | |
| if (!matchers_[i].Matches(*it)) | | | |
| return false; | | | |
| } | | | |
| | | | |
| return true; | | | |
| } | | | |
| | | | |
| // Describes what this matcher does. | | // Describes what this matcher does. | |
| virtual void DescribeTo(::std::ostream* os) const { | | virtual void DescribeTo(::std::ostream* os) const { | |
| if (count() == 0) { | | if (count() == 0) { | |
| *os << "is empty"; | | *os << "is empty"; | |
| } else if (count() == 1) { | | } else if (count() == 1) { | |
| *os << "has 1 element that "; | | *os << "has 1 element that "; | |
| matchers_[0].DescribeTo(os); | | matchers_[0].DescribeTo(os); | |
| } else { | | } else { | |
| *os << "has " << Elements(count()) << " where\n"; | | *os << "has " << Elements(count()) << " where\n"; | |
| for (size_t i = 0; i != count(); ++i) { | | for (size_t i = 0; i != count(); ++i) { | |
|
| *os << "element " << i << " "; | | *os << "element #" << i << " "; | |
| matchers_[i].DescribeTo(os); | | matchers_[i].DescribeTo(os); | |
| if (i + 1 < count()) { | | if (i + 1 < count()) { | |
| *os << ",\n"; | | *os << ",\n"; | |
| } | | } | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
| // Describes what the negation of this matcher does. | | // Describes what the negation of this matcher does. | |
| virtual void DescribeNegationTo(::std::ostream* os) const { | | virtual void DescribeNegationTo(::std::ostream* os) const { | |
| if (count() == 0) { | | if (count() == 0) { | |
|
| *os << "is not empty"; | | *os << "isn't empty"; | |
| return; | | return; | |
| } | | } | |
| | | | |
|
| *os << "does not have " << Elements(count()) << ", or\n"; | | *os << "doesn't have " << Elements(count()) << ", or\n"; | |
| for (size_t i = 0; i != count(); ++i) { | | for (size_t i = 0; i != count(); ++i) { | |
|
| *os << "element " << i << " "; | | *os << "element #" << i << " "; | |
| matchers_[i].DescribeNegationTo(os); | | matchers_[i].DescribeNegationTo(os); | |
| if (i + 1 < count()) { | | if (i + 1 < count()) { | |
| *os << ", or\n"; | | *os << ", or\n"; | |
| } | | } | |
| } | | } | |
| } | | } | |
| | | | |
|
| // Explains why 'container' matches, or doesn't match, this matcher. | | virtual bool MatchAndExplain(Container container, | |
| virtual void ExplainMatchResultTo(Container container, | | MatchResultListener* listener) const { | |
| ::std::ostream* os) const { | | | |
| StlContainerReference stl_container = View::ConstReference(container); | | StlContainerReference stl_container = View::ConstReference(container); | |
|
| if (Matches(container)) { | | const size_t actual_count = stl_container.size(); | |
| // We need to explain why *each* element matches (the obvious | | if (actual_count != count()) { | |
| // ones can be skipped). | | // The element count doesn't match. If the container is empty, | |
| | | // there's no need to explain anything as Google Mock already | |
| bool reason_printed = false; | | // prints the empty container. Otherwise we just need to show | |
| typename StlContainer::const_iterator it = stl_container.begin(); | | // how many elements there actually are. | |
| for (size_t i = 0; i != count(); ++it, ++i) { | | if (actual_count != 0) { | |
| ::std::stringstream ss; | | *listener << "which has " << Elements(actual_count); | |
| matchers_[i].ExplainMatchResultTo(*it, &ss); | | | |
| | | | |
| const string s = ss.str(); | | | |
| if (!s.empty()) { | | | |
| if (reason_printed) { | | | |
| *os << ",\n"; | | | |
| } | | | |
| *os << "element " << i << " " << s; | | | |
| reason_printed = true; | | | |
| } | | | |
| } | | | |
| } else { | | | |
| // We need to explain why the container doesn't match. | | | |
| const size_t actual_count = stl_container.size(); | | | |
| if (actual_count != count()) { | | | |
| // The element count doesn't match. If the container is | | | |
| // empty, there's no need to explain anything as Google Mock | | | |
| // already prints the empty container. Otherwise we just need | | | |
| // to show how many elements there actually are. | | | |
| if (actual_count != 0) { | | | |
| *os << "has " << Elements(actual_count); | | | |
| } | | | |
| return; | | | |
| } | | } | |
|
| | | return false; | |
| | | } | |
| | | | |
|
| // The container has the right size but at least one element | | typename StlContainer::const_iterator it = stl_container.begin(); | |
| // doesn't match expectation. We need to find this element and | | // explanations[i] is the explanation of the element at index i. | |
| // explain why it doesn't match. | | std::vector<internal::string> explanations(count()); | |
| typename StlContainer::const_iterator it = stl_container.begin(); | | for (size_t i = 0; i != count(); ++it, ++i) { | |
| for (size_t i = 0; i != count(); ++it, ++i) { | | StringMatchResultListener s; | |
| if (matchers_[i].Matches(*it)) { | | if (matchers_[i].MatchAndExplain(*it, &s)) { | |
| continue; | | explanations[i] = s.str(); | |
| } | | } else { | |
| | | // The container has the right size but the i-th element | |
| *os << "element " << i << " doesn't match"; | | // doesn't match its expectation. | |
| | | *listener << "whose element #" << i << " doesn't match"; | |
| | | PrintIfNotEmpty(s.str(), listener->stream()); | |
| | | return false; | |
| | | } | |
| | | } | |
| | | | |
|
| ::std::stringstream ss; | | // Every element matches its expectation. We need to explain why | |
| matchers_[i].ExplainMatchResultTo(*it, &ss); | | // (the obvious ones can be skipped). | |
| const string s = ss.str(); | | bool reason_printed = false; | |
| if (!s.empty()) { | | for (size_t i = 0; i != count(); ++i) { | |
| *os << " (" << s << ")"; | | const internal::string& s = explanations[i]; | |
| | | if (!s.empty()) { | |
| | | if (reason_printed) { | |
| | | *listener << ",\nand "; | |
| } | | } | |
|
| return; | | *listener << "whose element #" << i << " matches, " << s; | |
| | | reason_printed = true; | |
| } | | } | |
| } | | } | |
|
| | | | |
| | | return true; | |
| } | | } | |
| | | | |
| private: | | private: | |
| static Message Elements(size_t count) { | | static Message Elements(size_t count) { | |
| return Message() << count << (count == 1 ? " element" : " elements"); | | return Message() << count << (count == 1 ? " element" : " elements"); | |
| } | | } | |
| | | | |
| size_t count() const { return matchers_.size(); } | | size_t count() const { return matchers_.size(); } | |
| std::vector<Matcher<const Element&> > matchers_; | | std::vector<Matcher<const Element&> > matchers_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl); | |
| }; | | }; | |
| | | | |
| // Implements ElementsAre() of 0 arguments. | | // Implements ElementsAre() of 0 arguments. | |
| class ElementsAreMatcher0 { | | class ElementsAreMatcher0 { | |
| public: | | public: | |
| ElementsAreMatcher0() {} | | ElementsAreMatcher0() {} | |
| | | | |
| template <typename Container> | | template <typename Container> | |
| operator Matcher<Container>() const { | | operator Matcher<Container>() const { | |
| typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) | | typedef GMOCK_REMOVE_CONST_(GMOCK_REMOVE_REFERENCE_(Container)) | |
| | | | |
| skipping to change at line 2227 | | skipping to change at line 2341 | |
| RawContainer; | | RawContainer; | |
| typedef typename internal::StlContainerView<RawContainer>::type::value_
type | | typedef typename internal::StlContainerView<RawContainer>::type::value_
type | |
| Element; | | Element; | |
| | | | |
| return MakeMatcher(new ElementsAreMatcherImpl<Container>(first_, count_
)); | | return MakeMatcher(new ElementsAreMatcherImpl<Container>(first_, count_
)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| const T* const first_; | | const T* const first_; | |
| const size_t count_; | | const size_t count_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher); | |
| }; | | }; | |
| | | | |
| // Constants denoting interpolations in a matcher description string. | | // Constants denoting interpolations in a matcher description string. | |
| const int kTupleInterpolation = -1; // "%(*)s" | | const int kTupleInterpolation = -1; // "%(*)s" | |
| const int kPercentInterpolation = -2; // "%%" | | const int kPercentInterpolation = -2; // "%%" | |
| const int kInvalidInterpolation = -3; // "%" followed by invalid text | | const int kInvalidInterpolation = -3; // "%" followed by invalid text | |
| | | | |
| // Records the location and content of an interpolation. | | // Records the location and content of an interpolation. | |
| struct Interpolation { | | struct Interpolation { | |
| Interpolation(const char* start, const char* end, int param) | | Interpolation(const char* start, const char* end, int param) | |
| | | | |
| skipping to change at line 2511 | | skipping to change at line 2627 | |
| prefix)); | | prefix)); | |
| } | | } | |
| | | | |
| // Matches a string that ends with 'suffix' (case-sensitive). | | // Matches a string that ends with 'suffix' (case-sensitive). | |
| inline PolymorphicMatcher<internal::EndsWithMatcher<internal::string> > | | inline PolymorphicMatcher<internal::EndsWithMatcher<internal::string> > | |
| EndsWith(const internal::string& suffix) { | | EndsWith(const internal::string& suffix) { | |
| return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::string>
( | | return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::string>
( | |
| suffix)); | | suffix)); | |
| } | | } | |
| | | | |
|
| #ifdef GMOCK_HAS_REGEX | | | |
| | | | |
| // Matches a string that fully matches regular expression 'regex'. | | // Matches a string that fully matches regular expression 'regex'. | |
| // The matcher takes ownership of 'regex'. | | // The matcher takes ownership of 'regex'. | |
| inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex( | | inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex( | |
| const internal::RE* regex) { | | const internal::RE* regex) { | |
| return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true))
; | | return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true))
; | |
| } | | } | |
| inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex( | | inline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex( | |
| const internal::string& regex) { | | const internal::string& regex) { | |
| return MatchesRegex(new internal::RE(regex)); | | return MatchesRegex(new internal::RE(regex)); | |
| } | | } | |
| | | | |
| skipping to change at line 2535 | | skipping to change at line 2649 | |
| // The matcher takes ownership of 'regex'. | | // The matcher takes ownership of 'regex'. | |
| inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex( | | inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex( | |
| const internal::RE* regex) { | | const internal::RE* regex) { | |
| return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false)
); | | return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false)
); | |
| } | | } | |
| inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex( | | inline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex( | |
| const internal::string& regex) { | | const internal::string& regex) { | |
| return ContainsRegex(new internal::RE(regex)); | | return ContainsRegex(new internal::RE(regex)); | |
| } | | } | |
| | | | |
|
| #endif // GMOCK_HAS_REGEX | | | |
| | | | |
| #if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING | | #if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING | |
| // Wide string matchers. | | // Wide string matchers. | |
| | | | |
| // Matches a string equal to str. | | // Matches a string equal to str. | |
| inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> > | | inline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> > | |
| StrEq(const internal::wstring& str) { | | StrEq(const internal::wstring& str) { | |
| return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstr
ing>( | | return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstr
ing>( | |
| str, true, true)); | | str, true, true)); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 2713 | | skipping to change at line 2825 | |
| inline PolymorphicMatcher<internal::TrulyMatcher<Predicate> > | | inline PolymorphicMatcher<internal::TrulyMatcher<Predicate> > | |
| Truly(Predicate pred) { | | Truly(Predicate pred) { | |
| return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred)); | | return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred)); | |
| } | | } | |
| | | | |
| // Returns a matcher that matches an equal container. | | // Returns a matcher that matches an equal container. | |
| // This matcher behaves like Eq(), but in the event of mismatch lists the | | // This matcher behaves like Eq(), but in the event of mismatch lists the | |
| // values that are included in one container but not the other. (Duplicate | | // values that are included in one container but not the other. (Duplicate | |
| // values and order differences are not explained.) | | // values and order differences are not explained.) | |
| template <typename Container> | | template <typename Container> | |
|
| inline PolymorphicMatcher<internal::ContainerEqMatcher< | | inline PolymorphicMatcher<internal::ContainerEqMatcher< // NOLINT | |
| GMOCK_REMOVE_CONST_(Container)> > | | GMOCK_REMOVE_CONST_(Container)> > | |
| ContainerEq(const Container& rhs) { | | ContainerEq(const Container& rhs) { | |
| // This following line is for working around a bug in MSVC 8.0, | | // This following line is for working around a bug in MSVC 8.0, | |
| // which causes Container to be a const type sometimes. | | // which causes Container to be a const type sometimes. | |
| typedef GMOCK_REMOVE_CONST_(Container) RawContainer; | | typedef GMOCK_REMOVE_CONST_(Container) RawContainer; | |
|
| return MakePolymorphicMatcher(internal::ContainerEqMatcher<RawContainer>( | | return MakePolymorphicMatcher( | |
| rhs)); | | internal::ContainerEqMatcher<RawContainer>(rhs)); | |
| } | | } | |
| | | | |
| // Matches an STL-style container or a native array that contains at | | // Matches an STL-style container or a native array that contains at | |
| // least one element matching the given value or matcher. | | // least one element matching the given value or matcher. | |
| // | | // | |
| // Examples: | | // Examples: | |
| // ::std::set<int> page_ids; | | // ::std::set<int> page_ids; | |
| // page_ids.insert(3); | | // page_ids.insert(3); | |
| // page_ids.insert(1); | | // page_ids.insert(1); | |
| // EXPECT_THAT(page_ids, Contains(1)); | | // EXPECT_THAT(page_ids, Contains(1)); | |
| | | | |
| skipping to change at line 2778 | | skipping to change at line 2891 | |
| inline internal::MatcherAsPredicate<M> Matches(M matcher) { | | inline internal::MatcherAsPredicate<M> Matches(M matcher) { | |
| return internal::MatcherAsPredicate<M>(matcher); | | return internal::MatcherAsPredicate<M>(matcher); | |
| } | | } | |
| | | | |
| // Returns true iff the value matches the matcher. | | // Returns true iff the value matches the matcher. | |
| template <typename T, typename M> | | template <typename T, typename M> | |
| inline bool Value(const T& value, M matcher) { | | inline bool Value(const T& value, M matcher) { | |
| return testing::Matches(matcher)(value); | | return testing::Matches(matcher)(value); | |
| } | | } | |
| | | | |
|
| | | // Matches the value against the given matcher and explains the match | |
| | | // result to listener. | |
| | | template <typename T, typename M> | |
| | | inline bool ExplainMatchResult( | |
| | | M matcher, const T& value, MatchResultListener* listener) { | |
| | | return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener | |
| | | ); | |
| | | } | |
| | | | |
| // AllArgs(m) is a synonym of m. This is useful in | | // AllArgs(m) is a synonym of m. This is useful in | |
| // | | // | |
| // EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq())); | | // EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq())); | |
| // | | // | |
| // which is easier to read than | | // which is easier to read than | |
| // | | // | |
| // EXPECT_CALL(foo, Bar(_, _)).With(Eq()); | | // EXPECT_CALL(foo, Bar(_, _)).With(Eq()); | |
| template <typename InnerMatcher> | | template <typename InnerMatcher> | |
| inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher;
} | | inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher;
} | |
| | | | |
| | | | |
End of changes. 204 change blocks. |
| 517 lines changed or deleted | | 648 lines changed or added | |
|
| gmock-spec-builders.h | | gmock-spec-builders.h | |
| | | | |
| skipping to change at line 115 | | skipping to change at line 115 | |
| // mockers, and all expectations. | | // mockers, and all expectations. | |
| // | | // | |
| // The reason we don't use more fine-grained protection is: when a | | // The reason we don't use more fine-grained protection is: when a | |
| // mock function Foo() is called, it needs to consult its expectations | | // mock function Foo() is called, it needs to consult its expectations | |
| // to see which one should be picked. If another thread is allowed to | | // to see which one should be picked. If another thread is allowed to | |
| // call a mock function (either Foo() or a different one) at the same | | // call a mock function (either Foo() or a different one) at the same | |
| // time, it could affect the "retired" attributes of Foo()'s | | // time, it could affect the "retired" attributes of Foo()'s | |
| // expectations when InSequence() is used, and thus affect which | | // expectations when InSequence() is used, and thus affect which | |
| // expectation gets picked. Therefore, we sequence all mock function | | // expectation gets picked. Therefore, we sequence all mock function | |
| // calls to ensure the integrity of the mock objects' states. | | // calls to ensure the integrity of the mock objects' states. | |
|
| extern Mutex g_gmock_mutex; | | GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex); | |
| | | | |
| // Abstract base class of FunctionMockerBase. This is the | | // Abstract base class of FunctionMockerBase. This is the | |
| // type-agnostic part of the function mocker interface. Its pure | | // type-agnostic part of the function mocker interface. Its pure | |
| // virtual methods are implemented by FunctionMockerBase. | | // virtual methods are implemented by FunctionMockerBase. | |
| class UntypedFunctionMockerBase { | | class UntypedFunctionMockerBase { | |
| public: | | public: | |
| virtual ~UntypedFunctionMockerBase() {} | | virtual ~UntypedFunctionMockerBase() {} | |
| | | | |
| // Verifies that all expectations on this mock function have been | | // Verifies that all expectations on this mock function have been | |
| // satisfied. Reports one or more Google Test non-fatal failures | | // satisfied. Reports one or more Google Test non-fatal failures | |
| | | | |
| skipping to change at line 145 | | skipping to change at line 145 | |
| // This template class implements a default action spec (i.e. an | | // This template class implements a default action spec (i.e. an | |
| // ON_CALL() statement). | | // ON_CALL() statement). | |
| template <typename F> | | template <typename F> | |
| class DefaultActionSpec { | | class DefaultActionSpec { | |
| public: | | public: | |
| typedef typename Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename Function<F>::ArgumentTuple ArgumentTuple; | |
| typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; | | typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; | |
| | | | |
| // Constructs a DefaultActionSpec object from the information inside | | // Constructs a DefaultActionSpec object from the information inside | |
| // the parenthesis of an ON_CALL() statement. | | // the parenthesis of an ON_CALL() statement. | |
|
| DefaultActionSpec(const char* file, int line, | | DefaultActionSpec(const char* a_file, int a_line, | |
| const ArgumentMatcherTuple& matchers) | | const ArgumentMatcherTuple& matchers) | |
|
| : file_(file), | | : file_(a_file), | |
| line_(line), | | line_(a_line), | |
| matchers_(matchers), | | matchers_(matchers), | |
| // By default, extra_matcher_ should match anything. However, | | // By default, extra_matcher_ should match anything. However, | |
| // we cannot initialize it with _ as that triggers a compiler | | // we cannot initialize it with _ as that triggers a compiler | |
| // bug in Symbian's C++ compiler (cannot decide between two | | // bug in Symbian's C++ compiler (cannot decide between two | |
| // overloaded constructors of Matcher<const ArgumentTuple&>). | | // overloaded constructors of Matcher<const ArgumentTuple&>). | |
| extra_matcher_(A<const ArgumentTuple&>()), | | extra_matcher_(A<const ArgumentTuple&>()), | |
| last_clause_(kNone) { | | last_clause_(kNone) { | |
| } | | } | |
| | | | |
| // Where in the source file was the default action spec defined? | | // Where in the source file was the default action spec defined? | |
| | | | |
| skipping to change at line 563 | | skipping to change at line 564 | |
| // types (e.g. all pre-requisites of a particular expectation, all | | // types (e.g. all pre-requisites of a particular expectation, all | |
| // expectations in a sequence). Therefore these expectation objects | | // expectations in a sequence). Therefore these expectation objects | |
| // must share a common base class. | | // must share a common base class. | |
| // | | // | |
| // 2. We can avoid binary code bloat by moving methods not depending | | // 2. We can avoid binary code bloat by moving methods not depending | |
| // on the template argument of Expectation to the base class. | | // on the template argument of Expectation to the base class. | |
| // | | // | |
| // This class is internal and mustn't be used by user code directly. | | // This class is internal and mustn't be used by user code directly. | |
| class ExpectationBase { | | class ExpectationBase { | |
| public: | | public: | |
|
| ExpectationBase(const char* file, int line); | | // source_text is the EXPECT_CALL(...) source that created this Expectati | |
| | | on. | |
| | | ExpectationBase(const char* file, int line, const string& source_text); | |
| | | | |
| virtual ~ExpectationBase(); | | virtual ~ExpectationBase(); | |
| | | | |
| // Where in the source file was the expectation spec defined? | | // Where in the source file was the expectation spec defined? | |
| const char* file() const { return file_; } | | const char* file() const { return file_; } | |
| int line() const { return line_; } | | int line() const { return line_; } | |
|
| | | const char* source_text() const { return source_text_.c_str(); } | |
| // Returns the cardinality specified in the expectation spec. | | // Returns the cardinality specified in the expectation spec. | |
| const Cardinality& cardinality() const { return cardinality_; } | | const Cardinality& cardinality() const { return cardinality_; } | |
| | | | |
| // Describes the source file location of this expectation. | | // Describes the source file location of this expectation. | |
| void DescribeLocationTo(::std::ostream* os) const { | | void DescribeLocationTo(::std::ostream* os) const { | |
| *os << file() << ":" << line() << ": "; | | *os << file() << ":" << line() << ": "; | |
| } | | } | |
| | | | |
| // Describes how many times a function call matching this | | // Describes how many times a function call matching this | |
| // expectation has occurred. | | // expectation has occurred. | |
| | | | |
| skipping to change at line 621 | | skipping to change at line 624 | |
| | | | |
| // Explicitly specifies the cardinality of this expectation. Used | | // Explicitly specifies the cardinality of this expectation. Used | |
| // by the subclasses to implement the .Times() clause. | | // by the subclasses to implement the .Times() clause. | |
| void SpecifyCardinality(const Cardinality& cardinality); | | void SpecifyCardinality(const Cardinality& cardinality); | |
| | | | |
| // Returns true iff the user specified the cardinality explicitly | | // Returns true iff the user specified the cardinality explicitly | |
| // using a .Times(). | | // using a .Times(). | |
| bool cardinality_specified() const { return cardinality_specified_; } | | bool cardinality_specified() const { return cardinality_specified_; } | |
| | | | |
| // Sets the cardinality of this expectation spec. | | // Sets the cardinality of this expectation spec. | |
|
| void set_cardinality(const Cardinality& cardinality) { | | void set_cardinality(const Cardinality& a_cardinality) { | |
| cardinality_ = cardinality; | | cardinality_ = a_cardinality; | |
| } | | } | |
| | | | |
| // The following group of methods should only be called after the | | // The following group of methods should only be called after the | |
| // EXPECT_CALL() statement, and only when g_gmock_mutex is held by | | // EXPECT_CALL() statement, and only when g_gmock_mutex is held by | |
| // the current thread. | | // the current thread. | |
| | | | |
| // Retires all pre-requisites of this expectation. | | // Retires all pre-requisites of this expectation. | |
| // L >= g_gmock_mutex | | // L >= g_gmock_mutex | |
| void RetireAllPreRequisites(); | | void RetireAllPreRequisites(); | |
| | | | |
| | | | |
| skipping to change at line 699 | | skipping to change at line 702 | |
| | | | |
| private: | | private: | |
| friend class ::testing::Sequence; | | friend class ::testing::Sequence; | |
| friend class ::testing::internal::ExpectationTester; | | friend class ::testing::internal::ExpectationTester; | |
| | | | |
| template <typename Function> | | template <typename Function> | |
| friend class TypedExpectation; | | friend class TypedExpectation; | |
| | | | |
| // This group of fields are part of the spec and won't change after | | // This group of fields are part of the spec and won't change after | |
| // an EXPECT_CALL() statement finishes. | | // an EXPECT_CALL() statement finishes. | |
|
| const char* file_; // The file that contains the expectation. | | const char* file_; // The file that contains the expectation. | |
| int line_; // The line number of the expectation. | | int line_; // The line number of the expectation. | |
| | | const string source_text_; // The EXPECT_CALL(...) source text. | |
| // True iff the cardinality is specified explicitly. | | // True iff the cardinality is specified explicitly. | |
| bool cardinality_specified_; | | bool cardinality_specified_; | |
| Cardinality cardinality_; // The cardinality of the expectatio
n. | | Cardinality cardinality_; // The cardinality of the expectatio
n. | |
| // The immediate pre-requisites (i.e. expectations that must be | | // The immediate pre-requisites (i.e. expectations that must be | |
| // satisfied before this expectation can be matched) of this | | // satisfied before this expectation can be matched) of this | |
| // expectation. We use linked_ptr in the set because we want an | | // expectation. We use linked_ptr in the set because we want an | |
| // Expectation object to be co-owned by its FunctionMocker and its | | // Expectation object to be co-owned by its FunctionMocker and its | |
| // successors. This allows multiple mock objects to be deleted at | | // successors. This allows multiple mock objects to be deleted at | |
| // different times. | | // different times. | |
| ExpectationSet immediate_prerequisites_; | | ExpectationSet immediate_prerequisites_; | |
| | | | |
| // This group of fields are the current state of the expectation, | | // This group of fields are the current state of the expectation, | |
| // and can change as the mock function is called. | | // and can change as the mock function is called. | |
| int call_count_; // How many times this expectation has been invoked. | | int call_count_; // How many times this expectation has been invoked. | |
| bool retired_; // True iff this expectation has retired. | | bool retired_; // True iff this expectation has retired. | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(ExpectationBase); | |
| }; // class ExpectationBase | | }; // class ExpectationBase | |
| | | | |
| // Impements an expectation for the given function type. | | // Impements an expectation for the given function type. | |
| template <typename F> | | template <typename F> | |
| class TypedExpectation : public ExpectationBase { | | class TypedExpectation : public ExpectationBase { | |
| public: | | public: | |
| typedef typename Function<F>::ArgumentTuple ArgumentTuple; | | typedef typename Function<F>::ArgumentTuple ArgumentTuple; | |
| typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; | | typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple; | |
| typedef typename Function<F>::Result Result; | | typedef typename Function<F>::Result Result; | |
| | | | |
|
| TypedExpectation(FunctionMockerBase<F>* owner, const char* file, int line | | TypedExpectation(FunctionMockerBase<F>* owner, | |
| , | | const char* a_file, int a_line, const string& a_source_t | |
| | | ext, | |
| const ArgumentMatcherTuple& m) | | const ArgumentMatcherTuple& m) | |
|
| : ExpectationBase(file, line), | | : ExpectationBase(a_file, a_line, a_source_text), | |
| owner_(owner), | | owner_(owner), | |
| matchers_(m), | | matchers_(m), | |
|
| | | extra_matcher_specified_(false), | |
| // By default, extra_matcher_ should match anything. However, | | // By default, extra_matcher_ should match anything. However, | |
| // we cannot initialize it with _ as that triggers a compiler | | // we cannot initialize it with _ as that triggers a compiler | |
| // bug in Symbian's C++ compiler (cannot decide between two | | // bug in Symbian's C++ compiler (cannot decide between two | |
| // overloaded constructors of Matcher<const ArgumentTuple&>). | | // overloaded constructors of Matcher<const ArgumentTuple&>). | |
| extra_matcher_(A<const ArgumentTuple&>()), | | extra_matcher_(A<const ArgumentTuple&>()), | |
| repeated_action_specified_(false), | | repeated_action_specified_(false), | |
| repeated_action_(DoDefault()), | | repeated_action_(DoDefault()), | |
| retires_on_saturation_(false), | | retires_on_saturation_(false), | |
| last_clause_(kNone), | | last_clause_(kNone), | |
| action_count_checked_(false) {} | | action_count_checked_(false) {} | |
| | | | |
| skipping to change at line 762 | | skipping to change at line 770 | |
| ".With() cannot appear " | | ".With() cannot appear " | |
| "more than once in an EXPECT_CALL()."); | | "more than once in an EXPECT_CALL()."); | |
| } else { | | } else { | |
| ExpectSpecProperty(last_clause_ < kWith, | | ExpectSpecProperty(last_clause_ < kWith, | |
| ".With() must be the first " | | ".With() must be the first " | |
| "clause in an EXPECT_CALL()."); | | "clause in an EXPECT_CALL()."); | |
| } | | } | |
| last_clause_ = kWith; | | last_clause_ = kWith; | |
| | | | |
| extra_matcher_ = m; | | extra_matcher_ = m; | |
|
| | | extra_matcher_specified_ = true; | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| // Implements the .Times() clause. | | // Implements the .Times() clause. | |
|
| TypedExpectation& Times(const Cardinality& cardinality) { | | TypedExpectation& Times(const Cardinality& a_cardinality) { | |
| if (last_clause_ ==kTimes) { | | if (last_clause_ ==kTimes) { | |
| ExpectSpecProperty(false, | | ExpectSpecProperty(false, | |
| ".Times() cannot appear " | | ".Times() cannot appear " | |
| "more than once in an EXPECT_CALL()."); | | "more than once in an EXPECT_CALL()."); | |
| } else { | | } else { | |
| ExpectSpecProperty(last_clause_ < kTimes, | | ExpectSpecProperty(last_clause_ < kTimes, | |
| ".Times() cannot appear after " | | ".Times() cannot appear after " | |
| ".InSequence(), .WillOnce(), .WillRepeatedly(), " | | ".InSequence(), .WillOnce(), .WillRepeatedly(), " | |
| "or .RetiresOnSaturation()."); | | "or .RetiresOnSaturation()."); | |
| } | | } | |
| last_clause_ = kTimes; | | last_clause_ = kTimes; | |
| | | | |
|
| ExpectationBase::SpecifyCardinality(cardinality); | | ExpectationBase::SpecifyCardinality(a_cardinality); | |
| return *this; | | return *this; | |
| } | | } | |
| | | | |
| // Implements the .Times() clause. | | // Implements the .Times() clause. | |
| TypedExpectation& Times(int n) { | | TypedExpectation& Times(int n) { | |
| return Times(Exactly(n)); | | return Times(Exactly(n)); | |
| } | | } | |
| | | | |
| // Implements the .InSequence() clause. | | // Implements the .InSequence() clause. | |
| TypedExpectation& InSequence(const Sequence& s) { | | TypedExpectation& InSequence(const Sequence& s) { | |
| | | | |
| skipping to change at line 940 | | skipping to change at line 949 | |
| Cardinality::DescribeActualCallCountTo(call_count(), os); | | Cardinality::DescribeActualCallCountTo(call_count(), os); | |
| | | | |
| // Describes the state of the expectation (e.g. is it satisfied? | | // Describes the state of the expectation (e.g. is it satisfied? | |
| // is it active?). | | // is it active?). | |
| *os << " - " << (IsOverSaturated() ? "over-saturated" : | | *os << " - " << (IsOverSaturated() ? "over-saturated" : | |
| IsSaturated() ? "saturated" : | | IsSaturated() ? "saturated" : | |
| IsSatisfied() ? "satisfied" : "unsatisfied") | | IsSatisfied() ? "satisfied" : "unsatisfied") | |
| << " and " | | << " and " | |
| << (is_retired() ? "retired" : "active"); | | << (is_retired() ? "retired" : "active"); | |
| } | | } | |
|
| | | | |
| | | void MaybeDescribeExtraMatcherTo(::std::ostream* os) { | |
| | | if (extra_matcher_specified_) { | |
| | | *os << " Expected args: "; | |
| | | extra_matcher_.DescribeTo(os); | |
| | | *os << "\n"; | |
| | | } | |
| | | } | |
| | | | |
| private: | | private: | |
| template <typename Function> | | template <typename Function> | |
| friend class FunctionMockerBase; | | friend class FunctionMockerBase; | |
| | | | |
| // Returns an Expectation object that references and co-owns this | | // Returns an Expectation object that references and co-owns this | |
| // expectation. | | // expectation. | |
| virtual Expectation GetHandle() { | | virtual Expectation GetHandle() { | |
| return owner_->GetHandleOf(this); | | return owner_->GetHandleOf(this); | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 977 | | skipping to change at line 995 | |
| // was defined (e.g. if this expectation has no WillRepeatedly() | | // was defined (e.g. if this expectation has no WillRepeatedly() | |
| // or RetiresOnSaturation() clause), we check it when the | | // or RetiresOnSaturation() clause), we check it when the | |
| // expectation is used for the first time. | | // expectation is used for the first time. | |
| CheckActionCountIfNotDone(); | | CheckActionCountIfNotDone(); | |
| return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args)
; | | return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args)
; | |
| } | | } | |
| | | | |
| // Describes the result of matching the arguments against this | | // Describes the result of matching the arguments against this | |
| // expectation to the given ostream. | | // expectation to the given ostream. | |
| // L >= g_gmock_mutex | | // L >= g_gmock_mutex | |
|
| void DescribeMatchResultTo(const ArgumentTuple& args, | | void ExplainMatchResultTo(const ArgumentTuple& args, | |
| ::std::ostream* os) const { | | ::std::ostream* os) const { | |
| g_gmock_mutex.AssertHeld(); | | g_gmock_mutex.AssertHeld(); | |
| | | | |
| if (is_retired()) { | | if (is_retired()) { | |
| *os << " Expected: the expectation is active\n" | | *os << " Expected: the expectation is active\n" | |
| << " Actual: it is retired\n"; | | << " Actual: it is retired\n"; | |
| } else if (!Matches(args)) { | | } else if (!Matches(args)) { | |
| if (!TupleMatches(matchers_, args)) { | | if (!TupleMatches(matchers_, args)) { | |
|
| DescribeMatchFailureTupleTo(matchers_, args, os); | | ExplainMatchFailureTupleTo(matchers_, args, os); | |
| } | | } | |
|
| if (!extra_matcher_.Matches(args)) { | | StringMatchResultListener listener; | |
| | | if (!extra_matcher_.MatchAndExplain(args, &listener)) { | |
| *os << " Expected args: "; | | *os << " Expected args: "; | |
| extra_matcher_.DescribeTo(os); | | extra_matcher_.DescribeTo(os); | |
| *os << "\n Actual: don't match"; | | *os << "\n Actual: don't match"; | |
| | | | |
|
| internal::ExplainMatchResultAsNeededTo<const ArgumentTuple&>( | | internal::PrintIfNotEmpty(listener.str(), os); | |
| extra_matcher_, args, os); | | | |
| *os << "\n"; | | *os << "\n"; | |
| } | | } | |
| } else if (!AllPrerequisitesAreSatisfied()) { | | } else if (!AllPrerequisitesAreSatisfied()) { | |
| *os << " Expected: all pre-requisites are satisfied\n" | | *os << " Expected: all pre-requisites are satisfied\n" | |
| << " Actual: the following immediate pre-requisites " | | << " Actual: the following immediate pre-requisites " | |
| << "are not satisfied:\n"; | | << "are not satisfied:\n"; | |
| ExpectationSet unsatisfied_prereqs; | | ExpectationSet unsatisfied_prereqs; | |
| FindUnsatisfiedPrerequisites(&unsatisfied_prereqs); | | FindUnsatisfiedPrerequisites(&unsatisfied_prereqs); | |
| int i = 0; | | int i = 0; | |
| for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin(); | | for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin(); | |
| it != unsatisfied_prereqs.end(); ++it) { | | it != unsatisfied_prereqs.end(); ++it) { | |
| it->expectation_base()->DescribeLocationTo(os); | | it->expectation_base()->DescribeLocationTo(os); | |
| *os << "pre-requisite #" << i++ << "\n"; | | *os << "pre-requisite #" << i++ << "\n"; | |
| } | | } | |
| *os << " (end of pre-requisites)\n"; | | *os << " (end of pre-requisites)\n"; | |
| } else { | | } else { | |
| // This line is here just for completeness' sake. It will never | | // This line is here just for completeness' sake. It will never | |
|
| // be executed as currently the DescribeMatchResultTo() function | | // be executed as currently the ExplainMatchResultTo() function | |
| // is called only when the mock function call does NOT match the | | // is called only when the mock function call does NOT match the | |
| // expectation. | | // expectation. | |
| *os << "The call matches the expectation.\n"; | | *os << "The call matches the expectation.\n"; | |
| } | | } | |
| } | | } | |
| | | | |
| // Returns the action that should be taken for the current invocation. | | // Returns the action that should be taken for the current invocation. | |
| // L >= g_gmock_mutex | | // L >= g_gmock_mutex | |
| const Action<F>& GetCurrentAction(const FunctionMockerBase<F>* mocker, | | const Action<F>& GetCurrentAction(const FunctionMockerBase<F>* mocker, | |
| const ArgumentTuple& args) const { | | const ArgumentTuple& args) const { | |
| | | | |
| skipping to change at line 1036 | | skipping to change at line 1054 | |
| "call_count() is <= 0 when GetCurrentAction() is " | | "call_count() is <= 0 when GetCurrentAction() is " | |
| "called - this should never happen."); | | "called - this should never happen."); | |
| | | | |
| const int action_count = static_cast<int>(actions().size()); | | const int action_count = static_cast<int>(actions().size()); | |
| if (action_count > 0 && !repeated_action_specified_ && | | if (action_count > 0 && !repeated_action_specified_ && | |
| count > action_count) { | | count > action_count) { | |
| // If there is at least one WillOnce() and no WillRepeatedly(), | | // If there is at least one WillOnce() and no WillRepeatedly(), | |
| // we warn the user when the WillOnce() clauses ran out. | | // we warn the user when the WillOnce() clauses ran out. | |
| ::std::stringstream ss; | | ::std::stringstream ss; | |
| DescribeLocationTo(&ss); | | DescribeLocationTo(&ss); | |
|
| ss << "Actions ran out.\n" | | ss << "Actions ran out in " << source_text() << "...\n" | |
| << "Called " << count << " times, but only " | | << "Called " << count << " times, but only " | |
| << action_count << " WillOnce()" | | << action_count << " WillOnce()" | |
| << (action_count == 1 ? " is" : "s are") << " specified - "; | | << (action_count == 1 ? " is" : "s are") << " specified - "; | |
| mocker->DescribeDefaultActionTo(args, &ss); | | mocker->DescribeDefaultActionTo(args, &ss); | |
| Log(WARNING, ss.str(), 1); | | Log(WARNING, ss.str(), 1); | |
| } | | } | |
| | | | |
| return count <= action_count ? actions()[count - 1] : repeated_action()
; | | return count <= action_count ? actions()[count - 1] : repeated_action()
; | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 1080 | | skipping to change at line 1098 | |
| } | | } | |
| | | | |
| IncrementCallCount(); | | IncrementCallCount(); | |
| RetireAllPreRequisites(); | | RetireAllPreRequisites(); | |
| | | | |
| if (retires_on_saturation() && IsSaturated()) { | | if (retires_on_saturation() && IsSaturated()) { | |
| Retire(); | | Retire(); | |
| } | | } | |
| | | | |
| // Must be done after IncrementCount()! | | // Must be done after IncrementCount()! | |
|
| *what << "Expected mock function call.\n"; | | *what << "Mock function call matches " << source_text() <<"...\n"; | |
| return GetCurrentAction(mocker, args); | | return GetCurrentAction(mocker, args); | |
| } | | } | |
| | | | |
| // Checks the action count (i.e. the number of WillOnce() and | | // Checks the action count (i.e. the number of WillOnce() and | |
| // WillRepeatedly() clauses) against the cardinality if this hasn't | | // WillRepeatedly() clauses) against the cardinality if this hasn't | |
| // been done before. Prints a warning if there are too many or too | | // been done before. Prints a warning if there are too many or too | |
| // few actions. | | // few actions. | |
| // L < mutex_ | | // L < mutex_ | |
| void CheckActionCountIfNotDone() const { | | void CheckActionCountIfNotDone() const { | |
| bool should_check = false; | | bool should_check = false; | |
| | | | |
| skipping to change at line 1125 | | skipping to change at line 1143 | |
| } else if (0 < action_count && action_count < lower_bound && | | } else if (0 < action_count && action_count < lower_bound && | |
| !repeated_action_specified_) { | | !repeated_action_specified_) { | |
| too_many = false; | | too_many = false; | |
| } else { | | } else { | |
| return; | | return; | |
| } | | } | |
| | | | |
| ::std::stringstream ss; | | ::std::stringstream ss; | |
| DescribeLocationTo(&ss); | | DescribeLocationTo(&ss); | |
| ss << "Too " << (too_many ? "many" : "few") | | ss << "Too " << (too_many ? "many" : "few") | |
|
| << " actions specified.\n" | | << " actions specified in " << source_text() << "...\n" | |
| << "Expected to be "; | | << "Expected to be "; | |
| cardinality().DescribeTo(&ss); | | cardinality().DescribeTo(&ss); | |
| ss << ", but has " << (too_many ? "" : "only ") | | ss << ", but has " << (too_many ? "" : "only ") | |
| << action_count << " WillOnce()" | | << action_count << " WillOnce()" | |
| << (action_count == 1 ? "" : "s"); | | << (action_count == 1 ? "" : "s"); | |
| if (repeated_action_specified_) { | | if (repeated_action_specified_) { | |
| ss << " and a WillRepeatedly()"; | | ss << " and a WillRepeatedly()"; | |
| } | | } | |
| ss << "."; | | ss << "."; | |
| Log(WARNING, ss.str(), -1); // -1 means "don't print stack trace". | | Log(WARNING, ss.str(), -1); // -1 means "don't print stack trace". | |
| } | | } | |
| } | | } | |
| | | | |
| // All the fields below won't change once the EXPECT_CALL() | | // All the fields below won't change once the EXPECT_CALL() | |
| // statement finishes. | | // statement finishes. | |
| FunctionMockerBase<F>* const owner_; | | FunctionMockerBase<F>* const owner_; | |
| ArgumentMatcherTuple matchers_; | | ArgumentMatcherTuple matchers_; | |
|
| | | bool extra_matcher_specified_; | |
| Matcher<const ArgumentTuple&> extra_matcher_; | | Matcher<const ArgumentTuple&> extra_matcher_; | |
| std::vector<Action<F> > actions_; | | std::vector<Action<F> > actions_; | |
| bool repeated_action_specified_; // True if a WillRepeatedly() was speci
fied. | | bool repeated_action_specified_; // True if a WillRepeatedly() was speci
fied. | |
| Action<F> repeated_action_; | | Action<F> repeated_action_; | |
| bool retires_on_saturation_; | | bool retires_on_saturation_; | |
| Clause last_clause_; | | Clause last_clause_; | |
| mutable bool action_count_checked_; // Under mutex_. | | mutable bool action_count_checked_; // Under mutex_. | |
| mutable Mutex mutex_; // Protects action_count_checked_. | | mutable Mutex mutex_; // Protects action_count_checked_. | |
|
| | | | |
| | | GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation); | |
| }; // class TypedExpectation | | }; // class TypedExpectation | |
| | | | |
| // A MockSpec object is used by ON_CALL() or EXPECT_CALL() for | | // A MockSpec object is used by ON_CALL() or EXPECT_CALL() for | |
| // specifying the default behavior of, or expectation on, a mock | | // specifying the default behavior of, or expectation on, a mock | |
| // function. | | // function. | |
| | | | |
| // Note: class MockSpec really belongs to the ::testing namespace. | | // Note: class MockSpec really belongs to the ::testing namespace. | |
| // However if we define it in ::testing, MSVC will complain when | | // However if we define it in ::testing, MSVC will complain when | |
| // classes in ::testing::internal declare it as a friend class | | // classes in ::testing::internal declare it as a friend class | |
| // template. To workaround this compiler bug, we define MockSpec in | | // template. To workaround this compiler bug, we define MockSpec in | |
| | | | |
| skipping to change at line 1188 | | skipping to change at line 1209 | |
| const char* file, int line, const char* obj, const char* call) { | | const char* file, int line, const char* obj, const char* call) { | |
| LogWithLocation(internal::INFO, file, line, | | LogWithLocation(internal::INFO, file, line, | |
| string("ON_CALL(") + obj + ", " + call + ") invoked"); | | string("ON_CALL(") + obj + ", " + call + ") invoked"); | |
| return function_mocker_->AddNewDefaultActionSpec(file, line, matchers_)
; | | return function_mocker_->AddNewDefaultActionSpec(file, line, matchers_)
; | |
| } | | } | |
| | | | |
| // Adds a new expectation spec to the function mocker and returns | | // Adds a new expectation spec to the function mocker and returns | |
| // the newly created spec. | | // the newly created spec. | |
| internal::TypedExpectation<F>& InternalExpectedAt( | | internal::TypedExpectation<F>& InternalExpectedAt( | |
| const char* file, int line, const char* obj, const char* call) { | | const char* file, int line, const char* obj, const char* call) { | |
|
| LogWithLocation(internal::INFO, file, line, | | const string source_text(string("EXPECT_CALL(") + obj + ", " + call + " | |
| string("EXPECT_CALL(") + obj + ", " + call + ") invoked"); | | )"); | |
| return function_mocker_->AddNewExpectation(file, line, matchers_); | | LogWithLocation(internal::INFO, file, line, source_text + " invoked"); | |
| | | return function_mocker_->AddNewExpectation( | |
| | | file, line, source_text, matchers_); | |
| } | | } | |
| | | | |
| private: | | private: | |
| template <typename Function> | | template <typename Function> | |
| friend class internal::FunctionMocker; | | friend class internal::FunctionMocker; | |
| | | | |
| void SetMatchers(const ArgumentMatcherTuple& matchers) { | | void SetMatchers(const ArgumentMatcherTuple& matchers) { | |
| matchers_ = matchers; | | matchers_ = matchers; | |
| } | | } | |
| | | | |
| | | | |
| skipping to change at line 1214 | | skipping to change at line 1236 | |
| const string& message) { | | const string& message) { | |
| ::std::ostringstream s; | | ::std::ostringstream s; | |
| s << file << ":" << line << ": " << message << ::std::endl; | | s << file << ":" << line << ": " << message << ::std::endl; | |
| Log(severity, s.str(), 0); | | Log(severity, s.str(), 0); | |
| } | | } | |
| | | | |
| // The function mocker that owns this spec. | | // The function mocker that owns this spec. | |
| internal::FunctionMockerBase<F>* const function_mocker_; | | internal::FunctionMockerBase<F>* const function_mocker_; | |
| // The argument matchers specified in the spec. | | // The argument matchers specified in the spec. | |
| ArgumentMatcherTuple matchers_; | | ArgumentMatcherTuple matchers_; | |
|
| | | | |
| | | GTEST_DISALLOW_ASSIGN_(MockSpec); | |
| }; // class MockSpec | | }; // class MockSpec | |
| | | | |
| // MSVC warns about using 'this' in base member initializer list, so | | // MSVC warns about using 'this' in base member initializer list, so | |
| // we need to temporarily disable the warning. We have to do it for | | // we need to temporarily disable the warning. We have to do it for | |
| // the entire class to suppress the warning, even though it's about | | // the entire class to suppress the warning, even though it's about | |
| // the constructor only. | | // the constructor only. | |
| | | | |
| #ifdef _MSC_VER | | #ifdef _MSC_VER | |
| #pragma warning(push) // Saves the current warning state. | | #pragma warning(push) // Saves the current warning state. | |
| #pragma warning(disable:4355) // Temporarily disables warning 4355. | | #pragma warning(disable:4355) // Temporarily disables warning 4355. | |
| | | | |
| skipping to change at line 1237 | | skipping to change at line 1261 | |
| // a void-typed variable or pass a void value to a function. | | // a void-typed variable or pass a void value to a function. | |
| // ActionResultHolder<T> holds a value of type T, where T must be a | | // ActionResultHolder<T> holds a value of type T, where T must be a | |
| // copyable type or void (T doesn't need to be default-constructable). | | // copyable type or void (T doesn't need to be default-constructable). | |
| // It hides the syntactic difference between void and other types, and | | // It hides the syntactic difference between void and other types, and | |
| // is used to unify the code for invoking both void-returning and | | // is used to unify the code for invoking both void-returning and | |
| // non-void-returning mock functions. This generic definition is used | | // non-void-returning mock functions. This generic definition is used | |
| // when T is not void. | | // when T is not void. | |
| template <typename T> | | template <typename T> | |
| class ActionResultHolder { | | class ActionResultHolder { | |
| public: | | public: | |
|
| explicit ActionResultHolder(T value) : value_(value) {} | | explicit ActionResultHolder(T a_value) : value_(a_value) {} | |
| | | | |
| // The compiler-generated copy constructor and assignment operator | | // The compiler-generated copy constructor and assignment operator | |
| // are exactly what we need, so we don't need to define them. | | // are exactly what we need, so we don't need to define them. | |
| | | | |
| T value() const { return value_; } | | T value() const { return value_; } | |
| | | | |
| // Prints the held value as an action's result to os. | | // Prints the held value as an action's result to os. | |
| void PrintAsActionResult(::std::ostream* os) const { | | void PrintAsActionResult(::std::ostream* os) const { | |
| *os << "\n Returns: "; | | *os << "\n Returns: "; | |
| UniversalPrinter<T>::Print(value_, os); | | UniversalPrinter<T>::Print(value_, os); | |
| | | | |
| skipping to change at line 1271 | | skipping to change at line 1295 | |
| // Performs the given action and returns the result in a | | // Performs the given action and returns the result in a | |
| // ActionResultHolder. | | // ActionResultHolder. | |
| template <typename Function, typename Arguments> | | template <typename Function, typename Arguments> | |
| static ActionResultHolder PerformAction(const Action<Function>& action, | | static ActionResultHolder PerformAction(const Action<Function>& action, | |
| const Arguments& args) { | | const Arguments& args) { | |
| return ActionResultHolder(action.Perform(args)); | | return ActionResultHolder(action.Perform(args)); | |
| } | | } | |
| | | | |
| private: | | private: | |
| T value_; | | T value_; | |
|
| | | | |
| | | // T could be a reference type, so = isn't supported. | |
| | | GTEST_DISALLOW_ASSIGN_(ActionResultHolder); | |
| }; | | }; | |
| | | | |
| // Specialization for T = void. | | // Specialization for T = void. | |
| template <> | | template <> | |
| class ActionResultHolder<void> { | | class ActionResultHolder<void> { | |
| public: | | public: | |
| ActionResultHolder() {} | | ActionResultHolder() {} | |
| void value() const {} | | void value() const {} | |
| void PrintAsActionResult(::std::ostream* /* os */) const {} | | void PrintAsActionResult(::std::ostream* /* os */) const {} | |
| | | | |
| | | | |
| skipping to change at line 1442 | | skipping to change at line 1470 | |
| const char* file, int line, | | const char* file, int line, | |
| const ArgumentMatcherTuple& m) { | | const ArgumentMatcherTuple& m) { | |
| Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line); | | Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line); | |
| default_actions_.push_back(DefaultActionSpec<F>(file, line, m)); | | default_actions_.push_back(DefaultActionSpec<F>(file, line, m)); | |
| return default_actions_.back(); | | return default_actions_.back(); | |
| } | | } | |
| | | | |
| // Adds and returns an expectation spec for this mock function. | | // Adds and returns an expectation spec for this mock function. | |
| // L < g_gmock_mutex | | // L < g_gmock_mutex | |
| TypedExpectation<F>& AddNewExpectation( | | TypedExpectation<F>& AddNewExpectation( | |
|
| const char* file, int line, | | const char* file, | |
| | | int line, | |
| | | const string& source_text, | |
| const ArgumentMatcherTuple& m) { | | const ArgumentMatcherTuple& m) { | |
| Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line); | | Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line); | |
| const linked_ptr<TypedExpectation<F> > expectation( | | const linked_ptr<TypedExpectation<F> > expectation( | |
|
| new TypedExpectation<F>(this, file, line, m)); | | new TypedExpectation<F>(this, file, line, source_text, m)); | |
| expectations_.push_back(expectation); | | expectations_.push_back(expectation); | |
| | | | |
| // Adds this expectation into the implicit sequence if there is one. | | // Adds this expectation into the implicit sequence if there is one. | |
| Sequence* const implicit_sequence = g_gmock_implicit_sequence.get(); | | Sequence* const implicit_sequence = g_gmock_implicit_sequence.get(); | |
| if (implicit_sequence != NULL) { | | if (implicit_sequence != NULL) { | |
| implicit_sequence->AddExpectation(Expectation(expectation)); | | implicit_sequence->AddExpectation(Expectation(expectation)); | |
| } | | } | |
| | | | |
| return *expectation; | | return *expectation; | |
| } | | } | |
| | | | |
| skipping to change at line 1586 | | skipping to change at line 1617 | |
| g_gmock_mutex.AssertHeld(); | | g_gmock_mutex.AssertHeld(); | |
| const int count = static_cast<int>(expectations_.size()); | | const int count = static_cast<int>(expectations_.size()); | |
| *why << "Google Mock tried the following " << count << " " | | *why << "Google Mock tried the following " << count << " " | |
| << (count == 1 ? "expectation, but it didn't match" : | | << (count == 1 ? "expectation, but it didn't match" : | |
| "expectations, but none matched") | | "expectations, but none matched") | |
| << ":\n"; | | << ":\n"; | |
| for (int i = 0; i < count; i++) { | | for (int i = 0; i < count; i++) { | |
| *why << "\n"; | | *why << "\n"; | |
| expectations_[i]->DescribeLocationTo(why); | | expectations_[i]->DescribeLocationTo(why); | |
| if (count > 1) { | | if (count > 1) { | |
|
| *why << "tried expectation #" << i; | | *why << "tried expectation #" << i << ": "; | |
| } | | } | |
|
| *why << "\n"; | | *why << expectations_[i]->source_text() << "...\n"; | |
| expectations_[i]->DescribeMatchResultTo(args, why); | | expectations_[i]->ExplainMatchResultTo(args, why); | |
| expectations_[i]->DescribeCallCountTo(why); | | expectations_[i]->DescribeCallCountTo(why); | |
| } | | } | |
| } | | } | |
| | | | |
| // Address of the mock object this mock method belongs to. Only | | // Address of the mock object this mock method belongs to. Only | |
| // valid after this mock method has been called or | | // valid after this mock method has been called or | |
| // ON_CALL/EXPECT_CALL has been invoked on it. | | // ON_CALL/EXPECT_CALL has been invoked on it. | |
| const void* mock_obj_; // Protected by g_gmock_mutex. | | const void* mock_obj_; // Protected by g_gmock_mutex. | |
| | | | |
| // Name of the function being mocked. Only valid after this mock | | // Name of the function being mocked. Only valid after this mock | |
| | | | |
| skipping to change at line 1653 | | skipping to change at line 1684 | |
| TypedExpectation<F>* const exp = it->get(); | | TypedExpectation<F>* const exp = it->get(); | |
| | | | |
| if (exp->IsOverSaturated()) { | | if (exp->IsOverSaturated()) { | |
| // There was an upper-bound violation. Since the error was | | // There was an upper-bound violation. Since the error was | |
| // already reported when it occurred, there is no need to do | | // already reported when it occurred, there is no need to do | |
| // anything here. | | // anything here. | |
| expectations_met = false; | | expectations_met = false; | |
| } else if (!exp->IsSatisfied()) { | | } else if (!exp->IsSatisfied()) { | |
| expectations_met = false; | | expectations_met = false; | |
| ::std::stringstream ss; | | ::std::stringstream ss; | |
|
| ss << "Actual function call count doesn't match this expectation.\n"; | | ss << "Actual function call count doesn't match " | |
| | | << exp->source_text() << "...\n"; | |
| // No need to show the source file location of the expectation | | // No need to show the source file location of the expectation | |
| // in the description, as the Expect() call that follows already | | // in the description, as the Expect() call that follows already | |
| // takes care of it. | | // takes care of it. | |
|
| | | exp->MaybeDescribeExtraMatcherTo(&ss); | |
| exp->DescribeCallCountTo(&ss); | | exp->DescribeCallCountTo(&ss); | |
| Expect(false, exp->file(), exp->line(), ss.str()); | | Expect(false, exp->file(), exp->line(), ss.str()); | |
| } | | } | |
| } | | } | |
| expectations_.clear(); | | expectations_.clear(); | |
| return expectations_met; | | return expectations_met; | |
| } | | } | |
| | | | |
| // Reports an uninteresting call (whose description is in msg) in the | | // Reports an uninteresting call (whose description is in msg) in the | |
| // manner specified by 'reaction'. | | // manner specified by 'reaction'. | |
| | | | |
End of changes. 35 change blocks. |
| 35 lines changed or deleted | | 66 lines changed or added | |
|
| gtest.h | | gtest.h | |
| | | | |
| skipping to change at line 55 | | skipping to change at line 55 | |
| // program! | | // program! | |
| // | | // | |
| // Acknowledgment: Google Test borrowed the idea of automatic test | | // Acknowledgment: Google Test borrowed the idea of automatic test | |
| // registration from Barthelemy Dagenais' (barthelemy@prologique.com) | | // registration from Barthelemy Dagenais' (barthelemy@prologique.com) | |
| // easyUnit framework. | | // easyUnit framework. | |
| | | | |
| #ifndef GTEST_INCLUDE_GTEST_GTEST_H_ | | #ifndef GTEST_INCLUDE_GTEST_GTEST_H_ | |
| #define GTEST_INCLUDE_GTEST_GTEST_H_ | | #define GTEST_INCLUDE_GTEST_GTEST_H_ | |
| | | | |
| #include <limits> | | #include <limits> | |
|
| | | #include <vector> | |
| | | | |
| #include <gtest/internal/gtest-internal.h> | | #include <gtest/internal/gtest-internal.h> | |
| #include <gtest/internal/gtest-string.h> | | #include <gtest/internal/gtest-string.h> | |
| #include <gtest/gtest-death-test.h> | | #include <gtest/gtest-death-test.h> | |
| #include <gtest/gtest-message.h> | | #include <gtest/gtest-message.h> | |
| #include <gtest/gtest-param-test.h> | | #include <gtest/gtest-param-test.h> | |
| #include <gtest/gtest_prod.h> | | #include <gtest/gtest_prod.h> | |
| #include <gtest/gtest-test-part.h> | | #include <gtest/gtest-test-part.h> | |
| #include <gtest/gtest-typed-test.h> | | #include <gtest/gtest-typed-test.h> | |
| | | | |
| // Depending on the platform, different string classes are available. | | // Depending on the platform, different string classes are available. | |
|
| // On Windows, ::std::string compiles only when exceptions are | | // On Linux, in addition to ::std::string, Google also makes use of | |
| // enabled. On Linux, in addition to ::std::string, Google also makes | | // class ::string, which has the same interface as ::std::string, but | |
| // use of class ::string, which has the same interface as | | // has a different implementation. | |
| // ::std::string, but has a different implementation. | | | |
| // | | // | |
|
| // The user can tell us whether ::std::string is available in his | | // The user can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that | |
| // environment by defining the macro GTEST_HAS_STD_STRING to either 1 | | // ::string is available AND is a distinct type to ::std::string, or | |
| // or 0 on the compiler command line. He can also define | | // define it to 0 to indicate otherwise. | |
| // GTEST_HAS_GLOBAL_STRING to 1 to indicate that ::string is available | | | |
| // AND is a distinct type to ::std::string, or define it to 0 to | | | |
| // indicate otherwise. | | | |
| // | | // | |
| // If the user's ::std::string and ::string are the same class due to | | // If the user's ::std::string and ::string are the same class due to | |
|
| // aliasing, he should define GTEST_HAS_STD_STRING to 1 and | | // aliasing, he should define GTEST_HAS_GLOBAL_STRING to 0. | |
| // GTEST_HAS_GLOBAL_STRING to 0. | | | |
| // | | // | |
|
| // If the user doesn't define GTEST_HAS_STD_STRING and/or | | // If the user doesn't define GTEST_HAS_GLOBAL_STRING, it is defined | |
| // GTEST_HAS_GLOBAL_STRING, they are defined heuristically. | | // heuristically. | |
| | | | |
| namespace testing { | | namespace testing { | |
| | | | |
| // Declares the flags. | | // Declares the flags. | |
| | | | |
| // This flag temporary enables the disabled tests. | | // This flag temporary enables the disabled tests. | |
| GTEST_DECLARE_bool_(also_run_disabled_tests); | | GTEST_DECLARE_bool_(also_run_disabled_tests); | |
| | | | |
| // This flag brings the debugger on an assertion failure. | | // This flag brings the debugger on an assertion failure. | |
| GTEST_DECLARE_bool_(break_on_failure); | | GTEST_DECLARE_bool_(break_on_failure); | |
| | | | |
| skipping to change at line 180 | | skipping to change at line 177 | |
| // compiler. | | // compiler. | |
| template <typename T> | | template <typename T> | |
| String StreamableToString(const T& streamable) { | | String StreamableToString(const T& streamable) { | |
| return (Message() << streamable).GetString(); | | return (Message() << streamable).GetString(); | |
| } | | } | |
| | | | |
| } // namespace internal | | } // namespace internal | |
| | | | |
| // A class for indicating whether an assertion was successful. When | | // A class for indicating whether an assertion was successful. When | |
| // the assertion wasn't successful, the AssertionResult object | | // the assertion wasn't successful, the AssertionResult object | |
|
| // remembers a non-empty message that described how it failed. | | // remembers a non-empty message that describes how it failed. | |
| // | | | |
| // This class is useful for defining predicate-format functions to be | | | |
| // used with predicate assertions (ASSERT_PRED_FORMAT*, etc). | | | |
| // | | // | |
|
| // The constructor of AssertionResult is private. To create an | | // To create an instance of this class, use one of the factory functions | |
| // instance of this class, use one of the factory functions | | | |
| // (AssertionSuccess() and AssertionFailure()). | | // (AssertionSuccess() and AssertionFailure()). | |
| // | | // | |
|
| // For example, in order to be able to write: | | // This class is useful for two purposes: | |
| | | // 1. Defining predicate functions to be used with Boolean test assertion | |
| | | s | |
| | | // EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts | |
| | | // 2. Defining predicate-format functions to be | |
| | | // used with predicate assertions (ASSERT_PRED_FORMAT*, etc). | |
| | | // | |
| | | // For example, if you define IsEven predicate: | |
| | | // | |
| | | // testing::AssertionResult IsEven(int n) { | |
| | | // if ((n % 2) == 0) | |
| | | // return testing::AssertionSuccess(); | |
| | | // else | |
| | | // return testing::AssertionFailure() << n << " is odd"; | |
| | | // } | |
| | | // | |
| | | // Then the failed expectation EXPECT_TRUE(IsEven(Fib(5))) | |
| | | // will print the message | |
| | | // | |
| | | // Value of: IsEven(Fib(5)) | |
| | | // Actual: false (5 is odd) | |
| | | // Expected: true | |
| | | // | |
| | | // instead of a more opaque | |
| | | // | |
| | | // Value of: IsEven(Fib(5)) | |
| | | // Actual: false | |
| | | // Expected: true | |
| | | // | |
| | | // in case IsEven is a simple Boolean predicate. | |
| | | // | |
| | | // If you expect your predicate to be reused and want to support informativ | |
| | | e | |
| | | // messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up | |
| | | // about half as often as positive ones in our tests), supply messages for | |
| | | // both success and failure cases: | |
| | | // | |
| | | // testing::AssertionResult IsEven(int n) { | |
| | | // if ((n % 2) == 0) | |
| | | // return testing::AssertionSuccess() << n << " is even"; | |
| | | // else | |
| | | // return testing::AssertionFailure() << n << " is odd"; | |
| | | // } | |
| | | // | |
| | | // Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print | |
| | | // | |
| | | // Value of: IsEven(Fib(6)) | |
| | | // Actual: true (8 is even) | |
| | | // Expected: false | |
| | | // | |
| | | // NB: Predicates that support negative Boolean assertions have reduced | |
| | | // performance in positive ones so be careful not to use them in tests | |
| | | // that have lots (tens of thousands) of positive Boolean assertions. | |
| | | // | |
| | | // To use this class with EXPECT_PRED_FORMAT assertions such as: | |
| // | | // | |
| // // Verifies that Foo() returns an even number. | | // // Verifies that Foo() returns an even number. | |
| // EXPECT_PRED_FORMAT1(IsEven, Foo()); | | // EXPECT_PRED_FORMAT1(IsEven, Foo()); | |
| // | | // | |
|
| // you just need to define: | | // you need to define: | |
| // | | // | |
| // testing::AssertionResult IsEven(const char* expr, int n) { | | // testing::AssertionResult IsEven(const char* expr, int n) { | |
|
| // if ((n % 2) == 0) return testing::AssertionSuccess(); | | // if ((n % 2) == 0) | |
| // | | // return testing::AssertionSuccess(); | |
| // Message msg; | | // else | |
| // msg << "Expected: " << expr << " is even\n" | | // return testing::AssertionFailure() | |
| // << " Actual: it's " << n; | | // << "Expected: " << expr << " is even\n Actual: it's " << n; | |
| // return testing::AssertionFailure(msg); | | | |
| // } | | // } | |
| // | | // | |
| // If Foo() returns 5, you will see the following message: | | // If Foo() returns 5, you will see the following message: | |
| // | | // | |
| // Expected: Foo() is even | | // Expected: Foo() is even | |
| // Actual: it's 5 | | // Actual: it's 5 | |
|
| class AssertionResult { | | // | |
| | | class GTEST_API_ AssertionResult { | |
| public: | | public: | |
|
| // Declares factory functions for making successful and failed | | // Copy constructor. | |
| // assertion results as friends. | | // Used in EXPECT_TRUE/FALSE(assertion_result). | |
| friend AssertionResult AssertionSuccess(); | | AssertionResult(const AssertionResult& other); | |
| friend AssertionResult AssertionFailure(const Message&); | | // Used in the EXPECT_TRUE/FALSE(bool_expression). | |
| | | explicit AssertionResult(bool success) : success_(success) {} | |
| | | | |
| // Returns true iff the assertion succeeded. | | // Returns true iff the assertion succeeded. | |
|
| operator bool() const { return failure_message_.c_str() == NULL; } // NO
LINT | | operator bool() const { return success_; } // NOLINT | |
| | | | |
|
| // Returns the assertion's failure message. | | // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. | |
| const char* failure_message() const { return failure_message_.c_str(); } | | AssertionResult operator!() const; | |
| | | | |
| | | // Returns the text streamed into this AssertionResult. Test assertions | |
| | | // use it when they fail (i.e., the predicate's outcome doesn't match the | |
| | | // assertion's expectation). When nothing has been streamed into the | |
| | | // object, returns an empty string. | |
| | | const char* message() const { | |
| | | return message_.get() != NULL && message_->c_str() != NULL ? | |
| | | message_->c_str() : ""; | |
| | | } | |
| | | // TODO(vladl@google.com): Remove this after making sure no clients use i | |
| | | t. | |
| | | // Deprecated; please use message() instead. | |
| | | const char* failure_message() const { return message(); } | |
| | | | |
| | | // Streams a custom failure message into this object. | |
| | | template <typename T> AssertionResult& operator<<(const T& value); | |
| | | | |
| private: | | private: | |
|
| // The default constructor. It is used when the assertion succeeded. | | // No implementation - we want AssertionResult to be | |
| AssertionResult() {} | | // copy-constructible but not assignable. | |
| | | void operator=(const AssertionResult& other); | |
| | | | |
|
| // The constructor used when the assertion failed. | | // Stores result of the assertion predicate. | |
| explicit AssertionResult(const internal::String& failure_message); | | bool success_; | |
| | | // Stores the message describing the condition in case the expectation | |
| | | // construct is not satisfied with the predicate's outcome. | |
| | | // Referenced via a pointer to avoid taking too much stack frame space | |
| | | // with test assertions. | |
| | | internal::scoped_ptr<internal::String> message_; | |
| | | }; // class AssertionResult | |
| | | | |
|
| // Stores the assertion's failure message. | | // Streams a custom failure message into this object. | |
| internal::String failure_message_; | | template <typename T> | |
| }; | | AssertionResult& AssertionResult::operator<<(const T& value) { | |
| | | Message msg; | |
| | | if (message_.get() != NULL) | |
| | | msg << *message_; | |
| | | msg << value; | |
| | | message_.reset(new internal::String(msg.GetString())); | |
| | | return *this; | |
| | | } | |
| | | | |
| // Makes a successful assertion result. | | // Makes a successful assertion result. | |
|
| AssertionResult AssertionSuccess(); | | GTEST_API_ AssertionResult AssertionSuccess(); | |
| | | | |
| | | // Makes a failed assertion result. | |
| | | GTEST_API_ AssertionResult AssertionFailure(); | |
| | | | |
| // Makes a failed assertion result with the given failure message. | | // Makes a failed assertion result with the given failure message. | |
|
| AssertionResult AssertionFailure(const Message& msg); | | // Deprecated; use AssertionFailure() << msg. | |
| | | GTEST_API_ AssertionResult AssertionFailure(const Message& msg); | |
| | | | |
| // The abstract class that all tests inherit from. | | // The abstract class that all tests inherit from. | |
| // | | // | |
| // In Google Test, a unit test program contains one or many TestCases, and | | // In Google Test, a unit test program contains one or many TestCases, and | |
| // each TestCase contains one or many Tests. | | // each TestCase contains one or many Tests. | |
| // | | // | |
| // When you define a test using the TEST macro, you don't need to | | // When you define a test using the TEST macro, you don't need to | |
| // explicitly derive from Test - the TEST macro automatically does | | // explicitly derive from Test - the TEST macro automatically does | |
| // this for you. | | // this for you. | |
| // | | // | |
| | | | |
| skipping to change at line 262 | | skipping to change at line 341 | |
| // protected: | | // protected: | |
| // virtual void SetUp() { ... } | | // virtual void SetUp() { ... } | |
| // virtual void TearDown() { ... } | | // virtual void TearDown() { ... } | |
| // ... | | // ... | |
| // }; | | // }; | |
| // | | // | |
| // TEST_F(FooTest, Bar) { ... } | | // TEST_F(FooTest, Bar) { ... } | |
| // TEST_F(FooTest, Baz) { ... } | | // TEST_F(FooTest, Baz) { ... } | |
| // | | // | |
| // Test is not copyable. | | // Test is not copyable. | |
|
| class Test { | | class GTEST_API_ Test { | |
| public: | | public: | |
| friend class internal::TestInfoImpl; | | friend class internal::TestInfoImpl; | |
| | | | |
| // Defines types for pointers to functions that set up and tear down | | // Defines types for pointers to functions that set up and tear down | |
| // a test case. | | // a test case. | |
| typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc; | | typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc; | |
| typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc; | | typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc; | |
| | | | |
| // The d'tor is virtual as we intend to inherit from Test. | | // The d'tor is virtual as we intend to inherit from Test. | |
| virtual ~Test(); | | virtual ~Test(); | |
| | | | |
| skipping to change at line 378 | | skipping to change at line 457 | |
| | | | |
| // A copyable object representing a user specified test property which can
be | | // A copyable object representing a user specified test property which can
be | |
| // output as a key/value string pair. | | // output as a key/value string pair. | |
| // | | // | |
| // Don't inherit from TestProperty as its destructor is not virtual. | | // Don't inherit from TestProperty as its destructor is not virtual. | |
| class TestProperty { | | class TestProperty { | |
| public: | | public: | |
| // C'tor. TestProperty does NOT have a default constructor. | | // C'tor. TestProperty does NOT have a default constructor. | |
| // Always use this constructor (with parameters) to create a | | // Always use this constructor (with parameters) to create a | |
| // TestProperty object. | | // TestProperty object. | |
|
| TestProperty(const char* key, const char* value) : | | TestProperty(const char* a_key, const char* a_value) : | |
| key_(key), value_(value) { | | key_(a_key), value_(a_value) { | |
| } | | } | |
| | | | |
| // Gets the user supplied key. | | // Gets the user supplied key. | |
| const char* key() const { | | const char* key() const { | |
| return key_.c_str(); | | return key_.c_str(); | |
| } | | } | |
| | | | |
| // Gets the user supplied value. | | // Gets the user supplied value. | |
| const char* value() const { | | const char* value() const { | |
| return value_.c_str(); | | return value_.c_str(); | |
| | | | |
| skipping to change at line 410 | | skipping to change at line 489 | |
| // The value supplied by the user. | | // The value supplied by the user. | |
| internal::String value_; | | internal::String value_; | |
| }; | | }; | |
| | | | |
| // The result of a single Test. This includes a list of | | // The result of a single Test. This includes a list of | |
| // TestPartResults, a list of TestProperties, a count of how many | | // TestPartResults, a list of TestProperties, a count of how many | |
| // death tests there are in the Test, and how much time it took to run | | // death tests there are in the Test, and how much time it took to run | |
| // the Test. | | // the Test. | |
| // | | // | |
| // TestResult is not copyable. | | // TestResult is not copyable. | |
|
| class TestResult { | | class GTEST_API_ TestResult { | |
| public: | | public: | |
| // Creates an empty TestResult. | | // Creates an empty TestResult. | |
| TestResult(); | | TestResult(); | |
| | | | |
| // D'tor. Do not inherit from TestResult. | | // D'tor. Do not inherit from TestResult. | |
| ~TestResult(); | | ~TestResult(); | |
| | | | |
| // Gets the number of all test parts. This is the sum of the number | | // Gets the number of all test parts. This is the sum of the number | |
| // of successful test parts and the number of failed test parts. | | // of successful test parts and the number of failed test parts. | |
| int total_part_count() const; | | int total_part_count() const; | |
| | | | |
| skipping to change at line 461 | | skipping to change at line 540 | |
| friend class TestInfo; | | friend class TestInfo; | |
| friend class UnitTest; | | friend class UnitTest; | |
| friend class internal::DefaultGlobalTestPartResultReporter; | | friend class internal::DefaultGlobalTestPartResultReporter; | |
| friend class internal::ExecDeathTest; | | friend class internal::ExecDeathTest; | |
| friend class internal::TestInfoImpl; | | friend class internal::TestInfoImpl; | |
| friend class internal::TestResultAccessor; | | friend class internal::TestResultAccessor; | |
| friend class internal::UnitTestImpl; | | friend class internal::UnitTestImpl; | |
| friend class internal::WindowsDeathTest; | | friend class internal::WindowsDeathTest; | |
| | | | |
| // Gets the vector of TestPartResults. | | // Gets the vector of TestPartResults. | |
|
| const internal::Vector<TestPartResult>& test_part_results() const { | | const std::vector<TestPartResult>& test_part_results() const { | |
| return *test_part_results_; | | return test_part_results_; | |
| } | | } | |
| | | | |
| // Gets the vector of TestProperties. | | // Gets the vector of TestProperties. | |
|
| const internal::Vector<TestProperty>& test_properties() const { | | const std::vector<TestProperty>& test_properties() const { | |
| return *test_properties_; | | return test_properties_; | |
| } | | } | |
| | | | |
| // Sets the elapsed time. | | // Sets the elapsed time. | |
| void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; } | | void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; } | |
| | | | |
| // Adds a test property to the list. The property is validated and may ad
d | | // Adds a test property to the list. The property is validated and may ad
d | |
| // a non-fatal failure if invalid (e.g., if it conflicts with reserved | | // a non-fatal failure if invalid (e.g., if it conflicts with reserved | |
| // key names). If a property is already recorded for the same key, the | | // key names). If a property is already recorded for the same key, the | |
| // value will be updated, rather than storing multiple values for the sam
e | | // value will be updated, rather than storing multiple values for the sam
e | |
| // key. | | // key. | |
| | | | |
| skipping to change at line 505 | | skipping to change at line 584 | |
| void ClearTestPartResults(); | | void ClearTestPartResults(); | |
| | | | |
| // Clears the object. | | // Clears the object. | |
| void Clear(); | | void Clear(); | |
| | | | |
| // Protects mutable state of the property vector and of owned | | // Protects mutable state of the property vector and of owned | |
| // properties, whose values may be updated. | | // properties, whose values may be updated. | |
| internal::Mutex test_properites_mutex_; | | internal::Mutex test_properites_mutex_; | |
| | | | |
| // The vector of TestPartResults | | // The vector of TestPartResults | |
|
| internal::scoped_ptr<internal::Vector<TestPartResult> > test_part_results
_; | | std::vector<TestPartResult> test_part_results_; | |
| // The vector of TestProperties | | // The vector of TestProperties | |
|
| internal::scoped_ptr<internal::Vector<TestProperty> > test_properties_; | | std::vector<TestProperty> test_properties_; | |
| // Running count of death tests. | | // Running count of death tests. | |
| int death_test_count_; | | int death_test_count_; | |
| // The elapsed time, in milliseconds. | | // The elapsed time, in milliseconds. | |
| TimeInMillis elapsed_time_; | | TimeInMillis elapsed_time_; | |
| | | | |
| // We disallow copying TestResult. | | // We disallow copying TestResult. | |
| GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult); | | GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult); | |
| }; // class TestResult | | }; // class TestResult | |
| | | | |
| // A TestInfo object stores the following information about a test: | | // A TestInfo object stores the following information about a test: | |
| // | | // | |
| // Test case name | | // Test case name | |
| // Test name | | // Test name | |
| // Whether the test should be run | | // Whether the test should be run | |
| // A function pointer that creates the test object when invoked | | // A function pointer that creates the test object when invoked | |
| // Test result | | // Test result | |
| // | | // | |
| // The constructor of TestInfo registers itself with the UnitTest | | // The constructor of TestInfo registers itself with the UnitTest | |
| // singleton such that the RUN_ALL_TESTS() macro knows which tests to | | // singleton such that the RUN_ALL_TESTS() macro knows which tests to | |
| // run. | | // run. | |
|
| class TestInfo { | | class GTEST_API_ TestInfo { | |
| public: | | public: | |
| // Destructs a TestInfo object. This function is not virtual, so | | // Destructs a TestInfo object. This function is not virtual, so | |
| // don't inherit from TestInfo. | | // don't inherit from TestInfo. | |
| ~TestInfo(); | | ~TestInfo(); | |
| | | | |
| // Returns the test case name. | | // Returns the test case name. | |
| const char* test_case_name() const; | | const char* test_case_name() const; | |
| | | | |
| // Returns the test name. | | // Returns the test name. | |
| const char* name() const; | | const char* name() const; | |
| | | | |
| skipping to change at line 610 | | skipping to change at line 689 | |
| | | | |
| // An opaque implementation object. | | // An opaque implementation object. | |
| internal::TestInfoImpl* impl_; | | internal::TestInfoImpl* impl_; | |
| | | | |
| GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo); | | GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo); | |
| }; | | }; | |
| | | | |
| // A test case, which consists of a vector of TestInfos. | | // A test case, which consists of a vector of TestInfos. | |
| // | | // | |
| // TestCase is not copyable. | | // TestCase is not copyable. | |
|
| class TestCase { | | class GTEST_API_ TestCase { | |
| public: | | public: | |
| // Creates a TestCase with the given name. | | // Creates a TestCase with the given name. | |
| // | | // | |
| // TestCase does NOT have a default constructor. Always use this | | // TestCase does NOT have a default constructor. Always use this | |
| // constructor to create a TestCase object. | | // constructor to create a TestCase object. | |
| // | | // | |
| // Arguments: | | // Arguments: | |
| // | | // | |
| // name: name of the test case | | // name: name of the test case | |
| // set_up_tc: pointer to the function that sets up the test case | | // set_up_tc: pointer to the function that sets up the test case | |
| | | | |
| skipping to change at line 671 | | skipping to change at line 750 | |
| | | | |
| // Returns the i-th test among all the tests. i can range from 0 to | | // Returns the i-th test among all the tests. i can range from 0 to | |
| // total_test_count() - 1. If i is not in that range, returns NULL. | | // total_test_count() - 1. If i is not in that range, returns NULL. | |
| const TestInfo* GetTestInfo(int i) const; | | const TestInfo* GetTestInfo(int i) const; | |
| | | | |
| private: | | private: | |
| friend class Test; | | friend class Test; | |
| friend class internal::UnitTestImpl; | | friend class internal::UnitTestImpl; | |
| | | | |
| // Gets the (mutable) vector of TestInfos in this TestCase. | | // Gets the (mutable) vector of TestInfos in this TestCase. | |
|
| internal::Vector<TestInfo*>& test_info_list() { return *test_info_list_;
} | | std::vector<TestInfo*>& test_info_list() { return test_info_list_; } | |
| | | | |
| // Gets the (immutable) vector of TestInfos in this TestCase. | | // Gets the (immutable) vector of TestInfos in this TestCase. | |
|
| const internal::Vector<TestInfo *> & test_info_list() const { | | const std::vector<TestInfo*>& test_info_list() const { | |
| return *test_info_list_; | | return test_info_list_; | |
| } | | } | |
| | | | |
| // Returns the i-th test among all the tests. i can range from 0 to | | // Returns the i-th test among all the tests. i can range from 0 to | |
| // total_test_count() - 1. If i is not in that range, returns NULL. | | // total_test_count() - 1. If i is not in that range, returns NULL. | |
| TestInfo* GetMutableTestInfo(int i); | | TestInfo* GetMutableTestInfo(int i); | |
| | | | |
| // Sets the should_run member. | | // Sets the should_run member. | |
| void set_should_run(bool should) { should_run_ = should; } | | void set_should_run(bool should) { should_run_ = should; } | |
| | | | |
| // Adds a TestInfo to this test case. Will delete the TestInfo upon | | // Adds a TestInfo to this test case. Will delete the TestInfo upon | |
| | | | |
| skipping to change at line 724 | | skipping to change at line 803 | |
| | | | |
| // Restores the test order to before the first shuffle. | | // Restores the test order to before the first shuffle. | |
| void UnshuffleTests(); | | void UnshuffleTests(); | |
| | | | |
| // Name of the test case. | | // Name of the test case. | |
| internal::String name_; | | internal::String name_; | |
| // Comment on the test case. | | // Comment on the test case. | |
| internal::String comment_; | | internal::String comment_; | |
| // The vector of TestInfos in their original order. It owns the | | // The vector of TestInfos in their original order. It owns the | |
| // elements in the vector. | | // elements in the vector. | |
|
| const internal::scoped_ptr<internal::Vector<TestInfo*> > test_info_list_; | | std::vector<TestInfo*> test_info_list_; | |
| // Provides a level of indirection for the test list to allow easy | | // Provides a level of indirection for the test list to allow easy | |
| // shuffling and restoring the test order. The i-th element in this | | // shuffling and restoring the test order. The i-th element in this | |
| // vector is the index of the i-th test in the shuffled test list. | | // vector is the index of the i-th test in the shuffled test list. | |
|
| const internal::scoped_ptr<internal::Vector<int> > test_indices_; | | std::vector<int> test_indices_; | |
| // Pointer to the function that sets up the test case. | | // Pointer to the function that sets up the test case. | |
| Test::SetUpTestCaseFunc set_up_tc_; | | Test::SetUpTestCaseFunc set_up_tc_; | |
| // Pointer to the function that tears down the test case. | | // Pointer to the function that tears down the test case. | |
| Test::TearDownTestCaseFunc tear_down_tc_; | | Test::TearDownTestCaseFunc tear_down_tc_; | |
| // True iff any test in this test case should run. | | // True iff any test in this test case should run. | |
| bool should_run_; | | bool should_run_; | |
| // Elapsed time, in milliseconds. | | // Elapsed time, in milliseconds. | |
| TimeInMillis elapsed_time_; | | TimeInMillis elapsed_time_; | |
| | | | |
| // We disallow copying TestCases. | | // We disallow copying TestCases. | |
| | | | |
| skipping to change at line 848 | | skipping to change at line 927 | |
| virtual void OnTestEnd(const TestInfo& /*test_info*/) {} | | virtual void OnTestEnd(const TestInfo& /*test_info*/) {} | |
| virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {} | | virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {} | |
| virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {
} | | virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {
} | |
| virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {} | | virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {} | |
| virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/, | | virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/, | |
| int /*iteration*/) {} | | int /*iteration*/) {} | |
| virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {} | | virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {} | |
| }; | | }; | |
| | | | |
| // TestEventListeners lets users add listeners to track events in Google Te
st. | | // TestEventListeners lets users add listeners to track events in Google Te
st. | |
|
| class TestEventListeners { | | class GTEST_API_ TestEventListeners { | |
| public: | | public: | |
| TestEventListeners(); | | TestEventListeners(); | |
| ~TestEventListeners(); | | ~TestEventListeners(); | |
| | | | |
| // Appends an event listener to the end of the list. Google Test assumes | | // Appends an event listener to the end of the list. Google Test assumes | |
| // the ownership of the listener (i.e. it will delete the listener when | | // the ownership of the listener (i.e. it will delete the listener when | |
| // the test program finishes). | | // the test program finishes). | |
| void Append(TestEventListener* listener); | | void Append(TestEventListener* listener); | |
| | | | |
| // Removes the given event listener from the list and returns it. It the
n | | // Removes the given event listener from the list and returns it. It the
n | |
| | | | |
| skipping to change at line 935 | | skipping to change at line 1014 | |
| // A UnitTest consists of a vector of TestCases. | | // A UnitTest consists of a vector of TestCases. | |
| // | | // | |
| // This is a singleton class. The only instance of UnitTest is | | // This is a singleton class. The only instance of UnitTest is | |
| // created when UnitTest::GetInstance() is first called. This | | // created when UnitTest::GetInstance() is first called. This | |
| // instance is never deleted. | | // instance is never deleted. | |
| // | | // | |
| // UnitTest is not copyable. | | // UnitTest is not copyable. | |
| // | | // | |
| // This class is thread-safe as long as the methods are called | | // This class is thread-safe as long as the methods are called | |
| // according to their specification. | | // according to their specification. | |
|
| class UnitTest { | | class GTEST_API_ UnitTest { | |
| public: | | public: | |
| // Gets the singleton UnitTest object. The first time this method | | // Gets the singleton UnitTest object. The first time this method | |
| // is called, a UnitTest object is constructed and returned. | | // is called, a UnitTest object is constructed and returned. | |
| // Consecutive calls will return the same object. | | // Consecutive calls will return the same object. | |
| static UnitTest* GetInstance(); | | static UnitTest* GetInstance(); | |
| | | | |
| // Runs all tests in this UnitTest object and prints the result. | | // Runs all tests in this UnitTest object and prints the result. | |
| // Returns 0 if successful, or 1 otherwise. | | // Returns 0 if successful, or 1 otherwise. | |
| // | | // | |
| // This method can only be called from the main thread. | | // This method can only be called from the main thread. | |
| | | | |
| skipping to change at line 1122 | | skipping to change at line 1201 | |
| | | | |
| // Initializes Google Test. This must be called before calling | | // Initializes Google Test. This must be called before calling | |
| // RUN_ALL_TESTS(). In particular, it parses a command line for the | | // RUN_ALL_TESTS(). In particular, it parses a command line for the | |
| // flags that Google Test recognizes. Whenever a Google Test flag is | | // flags that Google Test recognizes. Whenever a Google Test flag is | |
| // seen, it is removed from argv, and *argc is decremented. | | // seen, it is removed from argv, and *argc is decremented. | |
| // | | // | |
| // No value is returned. Instead, the Google Test flag variables are | | // No value is returned. Instead, the Google Test flag variables are | |
| // updated. | | // updated. | |
| // | | // | |
| // Calling the function for the second time has no user-visible effect. | | // Calling the function for the second time has no user-visible effect. | |
|
| void InitGoogleTest(int* argc, char** argv); | | GTEST_API_ void InitGoogleTest(int* argc, char** argv); | |
| | | | |
| // This overloaded version can be used in Windows programs compiled in | | // This overloaded version can be used in Windows programs compiled in | |
| // UNICODE mode. | | // UNICODE mode. | |
|
| void InitGoogleTest(int* argc, wchar_t** argv); | | GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv); | |
| | | | |
| namespace internal { | | namespace internal { | |
| | | | |
| // These overloaded versions handle ::std::string and ::std::wstring. | | // These overloaded versions handle ::std::string and ::std::wstring. | |
|
| #if GTEST_HAS_STD_STRING | | GTEST_API_ inline String FormatForFailureMessage(const ::std::string& str) | |
| inline String FormatForFailureMessage(const ::std::string& str) { | | { | |
| return (Message() << '"' << str << '"').GetString(); | | return (Message() << '"' << str << '"').GetString(); | |
| } | | } | |
|
| #endif // GTEST_HAS_STD_STRING | | | |
| | | | |
| #if GTEST_HAS_STD_WSTRING | | #if GTEST_HAS_STD_WSTRING | |
|
| inline String FormatForFailureMessage(const ::std::wstring& wstr) { | | GTEST_API_ inline String FormatForFailureMessage(const ::std::wstring& wstr
) { | |
| return (Message() << "L\"" << wstr << '"').GetString(); | | return (Message() << "L\"" << wstr << '"').GetString(); | |
| } | | } | |
| #endif // GTEST_HAS_STD_WSTRING | | #endif // GTEST_HAS_STD_WSTRING | |
| | | | |
| // These overloaded versions handle ::string and ::wstring. | | // These overloaded versions handle ::string and ::wstring. | |
| #if GTEST_HAS_GLOBAL_STRING | | #if GTEST_HAS_GLOBAL_STRING | |
|
| inline String FormatForFailureMessage(const ::string& str) { | | GTEST_API_ inline String FormatForFailureMessage(const ::string& str) { | |
| return (Message() << '"' << str << '"').GetString(); | | return (Message() << '"' << str << '"').GetString(); | |
| } | | } | |
| #endif // GTEST_HAS_GLOBAL_STRING | | #endif // GTEST_HAS_GLOBAL_STRING | |
| | | | |
| #if GTEST_HAS_GLOBAL_WSTRING | | #if GTEST_HAS_GLOBAL_WSTRING | |
|
| inline String FormatForFailureMessage(const ::wstring& wstr) { | | GTEST_API_ inline String FormatForFailureMessage(const ::wstring& wstr) { | |
| return (Message() << "L\"" << wstr << '"').GetString(); | | return (Message() << "L\"" << wstr << '"').GetString(); | |
| } | | } | |
| #endif // GTEST_HAS_GLOBAL_WSTRING | | #endif // GTEST_HAS_GLOBAL_WSTRING | |
| | | | |
| // Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc) | | // Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc) | |
| // operand to be used in a failure message. The type (but not value) | | // operand to be used in a failure message. The type (but not value) | |
| // of the other operand may affect the format. This allows us to | | // of the other operand may affect the format. This allows us to | |
| // print a char* as a raw pointer when it is compared against another | | // print a char* as a raw pointer when it is compared against another | |
| // char*, and print it as a C string when it is compared against an | | // char*, and print it as a C string when it is compared against an | |
| // std::string object, for example. | | // std::string object, for example. | |
| | | | |
| skipping to change at line 1204 | | skipping to change at line 1281 | |
| return EqFailure(expected_expression, | | return EqFailure(expected_expression, | |
| actual_expression, | | actual_expression, | |
| FormatForComparisonFailureMessage(expected, actual), | | FormatForComparisonFailureMessage(expected, actual), | |
| FormatForComparisonFailureMessage(actual, expected), | | FormatForComparisonFailureMessage(actual, expected), | |
| false); | | false); | |
| } | | } | |
| | | | |
| // With this overloaded version, we allow anonymous enums to be used | | // With this overloaded version, we allow anonymous enums to be used | |
| // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums | | // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums | |
| // can be implicitly cast to BiggestInt. | | // can be implicitly cast to BiggestInt. | |
|
| AssertionResult CmpHelperEQ(const char* expected_expression, | | GTEST_API_ AssertionResult CmpHelperEQ(const char* expected_expression, | |
| const char* actual_expression, | | const char* actual_expression, | |
| BiggestInt expected, | | BiggestInt expected, | |
| BiggestInt actual); | | BiggestInt actual); | |
| | | | |
| // The helper class for {ASSERT|EXPECT}_EQ. The template argument | | // The helper class for {ASSERT|EXPECT}_EQ. The template argument | |
| // lhs_is_null_literal is true iff the first argument to ASSERT_EQ() | | // lhs_is_null_literal is true iff the first argument to ASSERT_EQ() | |
| // is a null pointer literal. The following default implementation is | | // is a null pointer literal. The following default implementation is | |
| // for lhs_is_null_literal being false. | | // for lhs_is_null_literal being false. | |
| template <bool lhs_is_null_literal> | | template <bool lhs_is_null_literal> | |
| class EqHelper { | | class EqHelper { | |
| public: | | public: | |
| // This templatized version is for the general case. | | // This templatized version is for the general case. | |
| template <typename T1, typename T2> | | template <typename T1, typename T2> | |
| | | | |
| skipping to change at line 1296 | | skipping to change at line 1373 | |
| if (val1 op val2) {\ | | if (val1 op val2) {\ | |
| return AssertionSuccess();\ | | return AssertionSuccess();\ | |
| } else {\ | | } else {\ | |
| Message msg;\ | | Message msg;\ | |
| msg << "Expected: (" << expr1 << ") " #op " (" << expr2\ | | msg << "Expected: (" << expr1 << ") " #op " (" << expr2\ | |
| << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\ | | << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\ | |
| << " vs " << FormatForComparisonFailureMessage(val2, val1);\ | | << " vs " << FormatForComparisonFailureMessage(val2, val1);\ | |
| return AssertionFailure(msg);\ | | return AssertionFailure(msg);\ | |
| }\ | | }\ | |
| }\ | | }\ | |
|
| AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ | | GTEST_API_ AssertionResult CmpHelper##op_name(\ | |
| BiggestInt val1, BiggestInt val2); | | const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2) | |
| | | | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | |
| | | | |
| // Implements the helper function for {ASSERT|EXPECT}_NE | | // Implements the helper function for {ASSERT|EXPECT}_NE | |
|
| GTEST_IMPL_CMP_HELPER_(NE, !=) | | GTEST_IMPL_CMP_HELPER_(NE, !=); | |
| // Implements the helper function for {ASSERT|EXPECT}_LE | | // Implements the helper function for {ASSERT|EXPECT}_LE | |
|
| GTEST_IMPL_CMP_HELPER_(LE, <=) | | GTEST_IMPL_CMP_HELPER_(LE, <=); | |
| // Implements the helper function for {ASSERT|EXPECT}_LT | | // Implements the helper function for {ASSERT|EXPECT}_LT | |
|
| GTEST_IMPL_CMP_HELPER_(LT, < ) | | GTEST_IMPL_CMP_HELPER_(LT, < ); | |
| // Implements the helper function for {ASSERT|EXPECT}_GE | | // Implements the helper function for {ASSERT|EXPECT}_GE | |
|
| GTEST_IMPL_CMP_HELPER_(GE, >=) | | GTEST_IMPL_CMP_HELPER_(GE, >=); | |
| // Implements the helper function for {ASSERT|EXPECT}_GT | | // Implements the helper function for {ASSERT|EXPECT}_GT | |
|
| GTEST_IMPL_CMP_HELPER_(GT, > ) | | GTEST_IMPL_CMP_HELPER_(GT, > ); | |
| | | | |
| #undef GTEST_IMPL_CMP_HELPER_ | | #undef GTEST_IMPL_CMP_HELPER_ | |
| | | | |
| // The helper function for {ASSERT|EXPECT}_STREQ. | | // The helper function for {ASSERT|EXPECT}_STREQ. | |
| // | | // | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | |
|
| AssertionResult CmpHelperSTREQ(const char* expected_expression, | | GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression, | |
| const char* actual_expression, | | const char* actual_expression, | |
| const char* expected, | | const char* expected, | |
| const char* actual); | | const char* actual); | |
| | | | |
| // The helper function for {ASSERT|EXPECT}_STRCASEEQ. | | // The helper function for {ASSERT|EXPECT}_STRCASEEQ. | |
| // | | // | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | |
|
| AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression, | | GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* expected_expressi | |
| const char* actual_expression, | | on, | |
| const char* expected, | | const char* actual_expression | |
| const char* actual); | | , | |
| | | const char* expected, | |
| | | const char* actual); | |
| | | | |
| // The helper function for {ASSERT|EXPECT}_STRNE. | | // The helper function for {ASSERT|EXPECT}_STRNE. | |
| // | | // | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | |
|
| AssertionResult CmpHelperSTRNE(const char* s1_expression, | | GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, | |
| const char* s2_expression, | | const char* s2_expression, | |
| const char* s1, | | const char* s1, | |
| const char* s2); | | const char* s2); | |
| | | | |
| // The helper function for {ASSERT|EXPECT}_STRCASENE. | | // The helper function for {ASSERT|EXPECT}_STRCASENE. | |
| // | | // | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | |
|
| AssertionResult CmpHelperSTRCASENE(const char* s1_expression, | | GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression, | |
| const char* s2_expression, | | const char* s2_expression, | |
| const char* s1, | | const char* s1, | |
| const char* s2); | | const char* s2); | |
| | | | |
| // Helper function for *_STREQ on wide strings. | | // Helper function for *_STREQ on wide strings. | |
| // | | // | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | |
|
| AssertionResult CmpHelperSTREQ(const char* expected_expression, | | GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression, | |
| const char* actual_expression, | | const char* actual_expression, | |
| const wchar_t* expected, | | const wchar_t* expected, | |
| const wchar_t* actual); | | const wchar_t* actual); | |
| | | | |
| // Helper function for *_STRNE on wide strings. | | // Helper function for *_STRNE on wide strings. | |
| // | | // | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | |
|
| AssertionResult CmpHelperSTRNE(const char* s1_expression, | | GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, | |
| const char* s2_expression, | | const char* s2_expression, | |
| const wchar_t* s1, | | const wchar_t* s1, | |
| const wchar_t* s2); | | const wchar_t* s2); | |
| | | | |
| } // namespace internal | | } // namespace internal | |
| | | | |
| // IsSubstring() and IsNotSubstring() are intended to be used as the | | // IsSubstring() and IsNotSubstring() are intended to be used as the | |
| // first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by | | // first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by | |
| // themselves. They check whether needle is a substring of haystack | | // themselves. They check whether needle is a substring of haystack | |
| // (NULL is considered a substring of itself only), and return an | | // (NULL is considered a substring of itself only), and return an | |
| // appropriate error message when they fail. | | // appropriate error message when they fail. | |
| // | | // | |
| // The {needle,haystack}_expr arguments are the stringified | | // The {needle,haystack}_expr arguments are the stringified | |
| // expressions that generated the two real arguments. | | // expressions that generated the two real arguments. | |
|
| AssertionResult IsSubstring( | | GTEST_API_ AssertionResult IsSubstring( | |
| const char* needle_expr, const char* haystack_expr, | | const char* needle_expr, const char* haystack_expr, | |
| const char* needle, const char* haystack); | | const char* needle, const char* haystack); | |
|
| AssertionResult IsSubstring( | | GTEST_API_ AssertionResult IsSubstring( | |
| const char* needle_expr, const char* haystack_expr, | | const char* needle_expr, const char* haystack_expr, | |
| const wchar_t* needle, const wchar_t* haystack); | | const wchar_t* needle, const wchar_t* haystack); | |
|
| AssertionResult IsNotSubstring( | | GTEST_API_ AssertionResult IsNotSubstring( | |
| const char* needle_expr, const char* haystack_expr, | | const char* needle_expr, const char* haystack_expr, | |
| const char* needle, const char* haystack); | | const char* needle, const char* haystack); | |
|
| AssertionResult IsNotSubstring( | | GTEST_API_ AssertionResult IsNotSubstring( | |
| const char* needle_expr, const char* haystack_expr, | | const char* needle_expr, const char* haystack_expr, | |
| const wchar_t* needle, const wchar_t* haystack); | | const wchar_t* needle, const wchar_t* haystack); | |
|
| #if GTEST_HAS_STD_STRING | | GTEST_API_ AssertionResult IsSubstring( | |
| AssertionResult IsSubstring( | | | |
| const char* needle_expr, const char* haystack_expr, | | const char* needle_expr, const char* haystack_expr, | |
| const ::std::string& needle, const ::std::string& haystack); | | const ::std::string& needle, const ::std::string& haystack); | |
|
| AssertionResult IsNotSubstring( | | GTEST_API_ AssertionResult IsNotSubstring( | |
| const char* needle_expr, const char* haystack_expr, | | const char* needle_expr, const char* haystack_expr, | |
| const ::std::string& needle, const ::std::string& haystack); | | const ::std::string& needle, const ::std::string& haystack); | |
|
| #endif // GTEST_HAS_STD_STRING | | | |
| | | | |
| #if GTEST_HAS_STD_WSTRING | | #if GTEST_HAS_STD_WSTRING | |
|
| AssertionResult IsSubstring( | | GTEST_API_ AssertionResult IsSubstring( | |
| const char* needle_expr, const char* haystack_expr, | | const char* needle_expr, const char* haystack_expr, | |
| const ::std::wstring& needle, const ::std::wstring& haystack); | | const ::std::wstring& needle, const ::std::wstring& haystack); | |
|
| AssertionResult IsNotSubstring( | | GTEST_API_ AssertionResult IsNotSubstring( | |
| const char* needle_expr, const char* haystack_expr, | | const char* needle_expr, const char* haystack_expr, | |
| const ::std::wstring& needle, const ::std::wstring& haystack); | | const ::std::wstring& needle, const ::std::wstring& haystack); | |
| #endif // GTEST_HAS_STD_WSTRING | | #endif // GTEST_HAS_STD_WSTRING | |
| | | | |
| namespace internal { | | namespace internal { | |
| | | | |
| // Helper template function for comparing floating-points. | | // Helper template function for comparing floating-points. | |
| // | | // | |
| // Template parameter: | | // Template parameter: | |
| // | | // | |
| | | | |
| skipping to change at line 1440 | | skipping to change at line 1515 | |
| return EqFailure(expected_expression, | | return EqFailure(expected_expression, | |
| actual_expression, | | actual_expression, | |
| StrStreamToString(&expected_ss), | | StrStreamToString(&expected_ss), | |
| StrStreamToString(&actual_ss), | | StrStreamToString(&actual_ss), | |
| false); | | false); | |
| } | | } | |
| | | | |
| // Helper function for implementing ASSERT_NEAR. | | // Helper function for implementing ASSERT_NEAR. | |
| // | | // | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. | |
|
| AssertionResult DoubleNearPredFormat(const char* expr1, | | GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1, | |
| const char* expr2, | | const char* expr2, | |
| const char* abs_error_expr, | | const char* abs_error_expr, | |
| double val1, | | double val1, | |
| double val2, | | double val2, | |
| double abs_error); | | double abs_error); | |
| | | | |
| // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. | | // INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. | |
| // A class that enables one to stream messages to assertion macros | | // A class that enables one to stream messages to assertion macros | |
|
| class AssertHelper { | | class GTEST_API_ AssertHelper { | |
| public: | | public: | |
| // Constructor. | | // Constructor. | |
| AssertHelper(TestPartResult::Type type, | | AssertHelper(TestPartResult::Type type, | |
| const char* file, | | const char* file, | |
| int line, | | int line, | |
| const char* message); | | const char* message); | |
| ~AssertHelper(); | | ~AssertHelper(); | |
| | | | |
| // Message assignment is a semantic trick to enable assertion | | // Message assignment is a semantic trick to enable assertion | |
| // streaming; see the GTEST_MESSAGE_ macro below. | | // streaming; see the GTEST_MESSAGE_ macro below. | |
| | | | |
| skipping to change at line 1578 | | skipping to change at line 1653 | |
| // Examples: | | // Examples: | |
| // | | // | |
| // EXPECT_TRUE(server.StatusIsOK()); | | // EXPECT_TRUE(server.StatusIsOK()); | |
| // ASSERT_FALSE(server.HasPendingRequest(port)) | | // ASSERT_FALSE(server.HasPendingRequest(port)) | |
| // << "There are still pending requests " << "on port " << port; | | // << "There are still pending requests " << "on port " << port; | |
| | | | |
| // Generates a nonfatal failure with a generic message. | | // Generates a nonfatal failure with a generic message. | |
| #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed") | | #define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed") | |
| | | | |
| // Generates a fatal failure with a generic message. | | // Generates a fatal failure with a generic message. | |
|
| #define FAIL() GTEST_FATAL_FAILURE_("Failed") | | #define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed") | |
| | | | |
| | | // Define this macro to 1 to omit the definition of FAIL(), which is a | |
| | | // generic name and clashes with some other libraries. | |
| | | #if !GTEST_DONT_DEFINE_FAIL | |
| | | #define FAIL() GTEST_FAIL() | |
| | | #endif | |
| | | | |
| // Generates a success with a generic message. | | // Generates a success with a generic message. | |
|
| #define SUCCEED() GTEST_SUCCESS_("Succeeded") | | #define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded") | |
| | | | |
| | | // Define this macro to 1 to omit the definition of SUCCEED(), which | |
| | | // is a generic name and clashes with some other libraries. | |
| | | #if !GTEST_DONT_DEFINE_SUCCEED | |
| | | #define SUCCEED() GTEST_SUCCEED() | |
| | | #endif | |
| | | | |
| // Macros for testing exceptions. | | // Macros for testing exceptions. | |
| // | | // | |
| // * {ASSERT|EXPECT}_THROW(statement, expected_exception): | | // * {ASSERT|EXPECT}_THROW(statement, expected_exception): | |
| // Tests that the statement throws the expected exception. | | // Tests that the statement throws the expected exception. | |
| // * {ASSERT|EXPECT}_NO_THROW(statement): | | // * {ASSERT|EXPECT}_NO_THROW(statement): | |
| // Tests that the statement doesn't throw any exception. | | // Tests that the statement doesn't throw any exception. | |
| // * {ASSERT|EXPECT}_ANY_THROW(statement): | | // * {ASSERT|EXPECT}_ANY_THROW(statement): | |
| // Tests that the statement throws an exception. | | // Tests that the statement throws an exception. | |
| | | | |
| | | | |
| skipping to change at line 1605 | | skipping to change at line 1692 | |
| GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_) | | GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_) | |
| #define EXPECT_ANY_THROW(statement) \ | | #define EXPECT_ANY_THROW(statement) \ | |
| GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_) | | GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_) | |
| #define ASSERT_THROW(statement, expected_exception) \ | | #define ASSERT_THROW(statement, expected_exception) \ | |
| GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_) | | GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_) | |
| #define ASSERT_NO_THROW(statement) \ | | #define ASSERT_NO_THROW(statement) \ | |
| GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_) | | GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_) | |
| #define ASSERT_ANY_THROW(statement) \ | | #define ASSERT_ANY_THROW(statement) \ | |
| GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_) | | GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_) | |
| | | | |
|
| // Boolean assertions. | | // Boolean assertions. Condition can be either a Boolean expression or an | |
| | | // AssertionResult. For more information on how to use AssertionResult with | |
| | | // these macros see comments on that class. | |
| #define EXPECT_TRUE(condition) \ | | #define EXPECT_TRUE(condition) \ | |
| GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ | | GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ | |
| GTEST_NONFATAL_FAILURE_) | | GTEST_NONFATAL_FAILURE_) | |
| #define EXPECT_FALSE(condition) \ | | #define EXPECT_FALSE(condition) \ | |
| GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ | | GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ | |
| GTEST_NONFATAL_FAILURE_) | | GTEST_NONFATAL_FAILURE_) | |
| #define ASSERT_TRUE(condition) \ | | #define ASSERT_TRUE(condition) \ | |
| GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ | | GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ | |
| GTEST_FATAL_FAILURE_) | | GTEST_FATAL_FAILURE_) | |
| #define ASSERT_FALSE(condition) \ | | #define ASSERT_FALSE(condition) \ | |
| | | | |
| skipping to change at line 1778 | | skipping to change at line 1867 | |
| ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ | | ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ | |
| val1, val2, abs_error) | | val1, val2, abs_error) | |
| | | | |
| // These predicate format functions work on floating-point values, and | | // These predicate format functions work on floating-point values, and | |
| // can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g. | | // can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g. | |
| // | | // | |
| // EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0); | | // EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0); | |
| | | | |
| // Asserts that val1 is less than, or almost equal to, val2. Fails | | // Asserts that val1 is less than, or almost equal to, val2. Fails | |
| // otherwise. In particular, it fails if either val1 or val2 is NaN. | | // otherwise. In particular, it fails if either val1 or val2 is NaN. | |
|
| AssertionResult FloatLE(const char* expr1, const char* expr2, | | GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2, | |
| float val1, float val2); | | float val1, float val2); | |
| AssertionResult DoubleLE(const char* expr1, const char* expr2, | | GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, | |
| double val1, double val2); | | double val1, double val2); | |
| | | | |
| #if GTEST_OS_WINDOWS | | #if GTEST_OS_WINDOWS | |
| | | | |
| // Macros that test for HRESULT failure and success, these are only useful | | // Macros that test for HRESULT failure and success, these are only useful | |
| // on Windows, and rely on Windows SDK macros and APIs to compile. | | // on Windows, and rely on Windows SDK macros and APIs to compile. | |
| // | | // | |
| // * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr) | | // * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr) | |
| // | | // | |
| // When expr unexpectedly fails or succeeds, Google Test prints the | | // When expr unexpectedly fails or succeeds, Google Test prints the | |
| // expected result and the actual result with both a human-readable | | // expected result and the actual result with both a human-readable | |
| | | | |
| skipping to change at line 1910 | | skipping to change at line 1999 | |
| | | | |
| // Note that we call GetTestTypeId() instead of GetTypeId< | | // Note that we call GetTestTypeId() instead of GetTypeId< | |
| // ::testing::Test>() here to get the type ID of testing::Test. This | | // ::testing::Test>() here to get the type ID of testing::Test. This | |
| // is to work around a suspected linker bug when using Google Test as | | // is to work around a suspected linker bug when using Google Test as | |
| // a framework on Mac OS X. The bug causes GetTypeId< | | // a framework on Mac OS X. The bug causes GetTypeId< | |
| // ::testing::Test>() to return different values depending on whether | | // ::testing::Test>() to return different values depending on whether | |
| // the call is from the Google Test framework itself or from user test | | // the call is from the Google Test framework itself or from user test | |
| // code. GetTestTypeId() is guaranteed to always return the same | | // code. GetTestTypeId() is guaranteed to always return the same | |
| // value, as it always calls GetTypeId<>() from the Google Test | | // value, as it always calls GetTypeId<>() from the Google Test | |
| // framework. | | // framework. | |
|
| #define TEST(test_case_name, test_name)\ | | #define GTEST_TEST(test_case_name, test_name)\ | |
| GTEST_TEST_(test_case_name, test_name, \ | | GTEST_TEST_(test_case_name, test_name, \ | |
| ::testing::Test, ::testing::internal::GetTestTypeId()) | | ::testing::Test, ::testing::internal::GetTestTypeId()) | |
| | | | |
|
| | | // Define this macro to 1 to omit the definition of TEST(), which | |
| | | // is a generic name and clashes with some other libraries. | |
| | | #if !GTEST_DONT_DEFINE_TEST | |
| | | #define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_nam | |
| | | e) | |
| | | #endif | |
| | | | |
| // Defines a test that uses a test fixture. | | // Defines a test that uses a test fixture. | |
| // | | // | |
| // The first parameter is the name of the test fixture class, which | | // The first parameter is the name of the test fixture class, which | |
| // also doubles as the test case name. The second parameter is the | | // also doubles as the test case name. The second parameter is the | |
| // name of the test within the test case. | | // name of the test within the test case. | |
| // | | // | |
| // A test fixture class must be declared earlier. The user should put | | // A test fixture class must be declared earlier. The user should put | |
| // his test code between braces after using this macro. Example: | | // his test code between braces after using this macro. Example: | |
| // | | // | |
| // class FooTest : public testing::Test { | | // class FooTest : public testing::Test { | |
| | | | |
End of changes. 71 change blocks. |
| 132 lines changed or deleted | | 234 lines changed or added | |
|