aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/gmock/gmock-actions.h49
-rw-r--r--include/gmock/gmock-generated-actions.h64
-rw-r--r--include/gmock/gmock-generated-actions.h.pump24
-rw-r--r--include/gmock/gmock-generated-function-mockers.h55
-rw-r--r--include/gmock/gmock-generated-function-mockers.h.pump5
-rw-r--r--include/gmock/gmock-generated-matchers.h71
-rw-r--r--include/gmock/gmock-generated-matchers.h.pump13
-rw-r--r--include/gmock/gmock-generated-nice-strict.h6
-rw-r--r--include/gmock/gmock-generated-nice-strict.h.pump6
-rw-r--r--include/gmock/gmock-matchers.h111
-rw-r--r--include/gmock/gmock-more-actions.h20
-rw-r--r--include/gmock/gmock-spec-builders.h33
-rw-r--r--include/gmock/internal/gmock-internal-utils.h8
13 files changed, 444 insertions, 21 deletions
diff --git a/include/gmock/gmock-actions.h b/include/gmock/gmock-actions.h
index d965e108..007ad9d3 100644
--- a/include/gmock/gmock-actions.h
+++ b/include/gmock/gmock-actions.h
@@ -268,6 +268,7 @@ class ActionInterface {
// Returns true iff this is the DoDefault() action.
bool IsDoDefault() const { return is_do_default_; }
+
private:
template <typename Function>
friend class internal::MonomorphicDoDefaultActionImpl;
@@ -279,6 +280,8 @@ class ActionInterface {
// True iff this action is DoDefault().
const bool is_do_default_;
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);
};
// An Action<F> is a copyable and IMMUTABLE (except by assignment)
@@ -325,6 +328,7 @@ class Action {
Result Perform(const ArgumentTuple& args) const {
return impl_->Perform(args);
}
+
private:
template <typename F1, typename F2>
friend class internal::ActionAdaptor;
@@ -362,6 +366,7 @@ class PolymorphicAction {
operator Action<F>() const {
return Action<F>(new MonomorphicImpl<F>(impl_));
}
+
private:
template <typename F>
class MonomorphicImpl : public ActionInterface<F> {
@@ -377,9 +382,13 @@ class PolymorphicAction {
private:
Impl impl_;
+
+ GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
};
Impl impl_;
+
+ GTEST_DISALLOW_ASSIGN_(PolymorphicAction);
};
// Creates an Action from its implementation and returns it. The
@@ -416,8 +425,11 @@ class ActionAdaptor : public ActionInterface<F1> {
virtual Result Perform(const ArgumentTuple& args) {
return impl_->Perform(args);
}
+
private:
const internal::linked_ptr<ActionInterface<F2> > impl_;
+
+ GTEST_DISALLOW_ASSIGN_(ActionAdaptor);
};
// Implements the polymorphic Return(x) action, which can be used in
@@ -470,6 +482,7 @@ class ReturnAction {
use_ReturnRef_instead_of_Return_to_return_a_reference);
return Action<F>(new Impl<F>(value_));
}
+
private:
// Implements the Return(x) action for a particular function type F.
template <typename F>
@@ -494,9 +507,13 @@ class ReturnAction {
GMOCK_COMPILE_ASSERT_(!internal::is_reference<Result>::value,
Result_cannot_be_a_reference_type);
Result value_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
};
R value_;
+
+ GTEST_DISALLOW_ASSIGN_(ReturnAction);
};
// Implements the ReturnNull() action.
@@ -542,6 +559,7 @@ class ReturnRefAction {
use_Return_instead_of_ReturnRef_to_return_a_value);
return Action<F>(new Impl<F>(ref_));
}
+
private:
// Implements the ReturnRef(x) action for a particular function type F.
template <typename F>
@@ -555,11 +573,16 @@ class ReturnRefAction {
virtual Result Perform(const ArgumentTuple&) {
return ref_;
}
+
private:
T& ref_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
};
T& ref_;
+
+ GTEST_DISALLOW_ASSIGN_(ReturnRefAction);
};
// Implements the DoDefault() action for a particular function type F.
@@ -611,9 +634,12 @@ class AssignAction {
void Perform(const ArgumentTuple& /* args */) const {
*ptr_ = value_;
}
+
private:
T1* const ptr_;
const T2 value_;
+
+ GTEST_DISALLOW_ASSIGN_(AssignAction);
};
#if !GTEST_OS_WINDOWS_MOBILE
@@ -631,9 +657,12 @@ class SetErrnoAndReturnAction {
errno = errno_;
return result_;
}
+
private:
const int errno_;
const T result_;
+
+ GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction);
};
#endif // !GTEST_OS_WINDOWS_MOBILE
@@ -657,6 +686,8 @@ class SetArgumentPointeeAction {
private:
const A value_;
+
+ GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
};
template <size_t N, typename Proto>
@@ -675,8 +706,11 @@ class SetArgumentPointeeAction<N, Proto, true> {
CompileAssertTypesEqual<void, Result>();
::std::tr1::get<N>(args)->CopyFrom(*proto_);
}
+
private:
const internal::linked_ptr<Proto> proto_;
+
+ GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);
};
// Implements the InvokeWithoutArgs(f) action. The template argument
@@ -696,8 +730,11 @@ class InvokeWithoutArgsAction {
// compatible with f.
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple&) { return function_impl_(); }
+
private:
FunctionImpl function_impl_;
+
+ GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction);
};
// Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action.
@@ -711,9 +748,12 @@ class InvokeMethodWithoutArgsAction {
Result Perform(const ArgumentTuple&) const {
return (obj_ptr_->*method_ptr_)();
}
+
private:
Class* const obj_ptr_;
const MethodPtr method_ptr_;
+
+ GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction);
};
// Implements the IgnoreResult(action) action.
@@ -739,6 +779,7 @@ class IgnoreResultAction {
return Action<F>(new Impl<F>(action_));
}
+
private:
template <typename F>
class Impl : public ActionInterface<F> {
@@ -760,9 +801,13 @@ class IgnoreResultAction {
OriginalFunction;
const Action<OriginalFunction> action_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
};
const A action_;
+
+ GTEST_DISALLOW_ASSIGN_(IgnoreResultAction);
};
// A ReferenceWrapper<T> object represents a reference to type T,
@@ -827,10 +872,14 @@ class DoBothAction {
private:
const Action<VoidResult> action1_;
const Action<F> action2_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
};
Action1 action1_;
Action2 action2_;
+
+ GTEST_DISALLOW_ASSIGN_(DoBothAction);
};
} // namespace internal
diff --git a/include/gmock/gmock-generated-actions.h b/include/gmock/gmock-generated-actions.h
index 143a99be..2b53c7b9 100644
--- a/include/gmock/gmock-generated-actions.h
+++ b/include/gmock/gmock-generated-actions.h
@@ -615,6 +615,8 @@ class WithArgsAction {
};
const InnerAction action_;
+
+ GTEST_DISALLOW_ASSIGN_(WithArgsAction);
};
// A macro from the ACTION* family (defined later in this file)
@@ -1406,12 +1408,16 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
GMOCK_INTERNAL_DEFN_##value_params\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(\
new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
}\
GMOCK_INTERNAL_DEFN_##value_params\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
};\
template <GMOCK_INTERNAL_DECL_##template_params\
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
@@ -1462,10 +1468,14 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>());\
}\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##Action);\
};\
inline name##Action name() {\
return name##Action();\
@@ -1505,11 +1515,15 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \
arg9_type arg9) const;\
p0##_type p0;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0));\
}\
p0##_type p0;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP);\
};\
template <typename p0##_type>\
inline name##ActionP<p0##_type> name(p0##_type p0) {\
@@ -1554,12 +1568,16 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
arg9_type arg9) const;\
p0##_type p0;\
p1##_type p1;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\
}\
p0##_type p0;\
p1##_type p1;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP2);\
};\
template <typename p0##_type, typename p1##_type>\
inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \
@@ -1606,6 +1624,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\
@@ -1613,6 +1633,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP3);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type>\
inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
@@ -1664,6 +1686,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\
@@ -1672,6 +1696,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP4);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\
@@ -1729,6 +1755,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\
@@ -1738,6 +1766,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP5);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\
@@ -1797,6 +1827,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\
@@ -1807,6 +1839,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP6);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\
@@ -1869,6 +1903,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
@@ -1881,6 +1917,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP7);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
@@ -1949,6 +1987,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
@@ -1962,6 +2002,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP8);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
@@ -2034,6 +2076,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
@@ -2048,6 +2092,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP9);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
@@ -2123,6 +2169,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p7##_type p7;\
p8##_type p8;\
p9##_type p9;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \
@@ -2138,6 +2186,8 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
p7##_type p7;\
p8##_type p8;\
p9##_type p9;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(name##ActionP10);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
@@ -2172,6 +2222,16 @@ DoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,
// updated.
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>().
//
// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
@@ -2350,6 +2410,10 @@ ACTION_TEMPLATE(ReturnNew,
return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
}
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
} // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
diff --git a/include/gmock/gmock-generated-actions.h.pump b/include/gmock/gmock-generated-actions.h.pump
index 05bf3db3..75b1e7a0 100644
--- a/include/gmock/gmock-generated-actions.h.pump
+++ b/include/gmock/gmock-generated-actions.h.pump
@@ -228,6 +228,8 @@ class WithArgsAction {
};
const InnerAction action_;
+
+ GTEST_DISALLOW_ASSIGN_(WithArgsAction);
};
// A macro from the ACTION* family (defined later in this file)
@@ -630,12 +632,16 @@ $range k 0..n-1
return_type gmock_PerformImpl(const args_type& args[[]]
$for k [[, arg$k[[]]_type arg$k]]) const;\
GMOCK_INTERNAL_DEFN_##value_params\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(\
new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\
}\
GMOCK_INTERNAL_DEFN_##value_params\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\
};\
template <GMOCK_INTERNAL_DECL_##template_params\
GMOCK_INTERNAL_DECL_TYPE_##value_params>\
@@ -712,10 +718,14 @@ $var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]
template <$typename_arg_types>\
return_type gmock_PerformImpl(const args_type& args, [[]]
$arg_types_and_names) const;\$param_field_decls
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename F> operator ::testing::Action<F>() const {\
return ::testing::Action<F>(new gmock_Impl<F>($params));\
}\$param_field_decls2
+ private:\
+ GTEST_DISALLOW_ASSIGN_($class_name);\
};\$template
inline $class_name$param_types name($param_types_and_names) {\
return $class_name$param_types($params);\
@@ -735,6 +745,16 @@ $$ // show up in the generated code.
// updated.
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>().
//
// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th
@@ -796,6 +816,10 @@ ACTION_TEMPLATE(ReturnNew,
]]
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
} // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_
diff --git a/include/gmock/gmock-generated-function-mockers.h b/include/gmock/gmock-generated-function-mockers.h
index 9f3a956c..3b2ede1e 100644
--- a/include/gmock/gmock-generated-function-mockers.h
+++ b/include/gmock/gmock-generated-function-mockers.h
@@ -794,66 +794,116 @@ class MockFunction;
template <typename R>
class MockFunction<R()> {
public:
+ MockFunction() {}
+
MOCK_METHOD0_T(Call, R());
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
};
template <typename R, typename A0>
class MockFunction<R(A0)> {
public:
+ MockFunction() {}
+
MOCK_METHOD1_T(Call, R(A0));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
};
template <typename R, typename A0, typename A1>
class MockFunction<R(A0, A1)> {
public:
+ MockFunction() {}
+
MOCK_METHOD2_T(Call, R(A0, A1));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
};
template <typename R, typename A0, typename A1, typename A2>
class MockFunction<R(A0, A1, A2)> {
public:
+ MockFunction() {}
+
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>
class MockFunction<R(A0, A1, A2, A3)> {
public:
+ MockFunction() {}
+
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,
typename A4>
class MockFunction<R(A0, A1, A2, A3, A4)> {
public:
+ MockFunction() {}
+
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,
typename A4, typename A5>
class MockFunction<R(A0, A1, A2, A3, A4, A5)> {
public:
+ MockFunction() {}
+
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,
typename A4, typename A5, typename A6>
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {
public:
+ MockFunction() {}
+
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,
typename A4, typename A5, typename A6, typename A7>
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {
public:
+ MockFunction() {}
+
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,
typename A4, typename A5, typename A6, typename A7, typename A8>
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {
public:
+ MockFunction() {}
+
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,
@@ -861,7 +911,12 @@ template <typename R, typename A0, typename A1, typename A2, typename A3,
typename A9>
class MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {
public:
+ MockFunction() {}
+
MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
};
} // namespace testing
diff --git a/include/gmock/gmock-generated-function-mockers.h.pump b/include/gmock/gmock-generated-function-mockers.h.pump
index 82106eb1..619debd2 100644
--- a/include/gmock/gmock-generated-function-mockers.h.pump
+++ b/include/gmock/gmock-generated-function-mockers.h.pump
@@ -242,7 +242,12 @@ $range j 0..i-1
template <typename R$for j [[, typename A$j]]>
class MockFunction<R($for j, [[A$j]])> {
public:
+ MockFunction() {}
+
MOCK_METHOD$i[[]]_T(Call, R($for j, [[A$j]]));
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);
};
diff --git a/include/gmock/gmock-generated-matchers.h b/include/gmock/gmock-generated-matchers.h
index a59e457f..18420c1d 100644
--- a/include/gmock/gmock-generated-matchers.h
+++ b/include/gmock/gmock-generated-matchers.h
@@ -89,7 +89,7 @@ template <class Tuple>
class TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {
public:
typedef ::std::tr1::tuple<> type;
- static type GetSelectedFields(const Tuple& t) {
+ static type GetSelectedFields(const Tuple& /* t */) {
using ::std::tr1::get;
return type();
}
@@ -271,6 +271,8 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
}
const MonomorphicInnerMatcher inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
};
template <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,
@@ -287,7 +289,10 @@ class ArgsMatcher {
k6, k7, k8, k9>(inner_matcher_));
}
+ private:
const InnerMatcher inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
};
// Implements ElementsAre() of 1-10 arguments.
@@ -317,6 +322,8 @@ class ElementsAreMatcher1 {
private:
const T1& e1_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher1);
};
template <typename T1, typename T2>
@@ -342,6 +349,8 @@ class ElementsAreMatcher2 {
private:
const T1& e1_;
const T2& e2_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher2);
};
template <typename T1, typename T2, typename T3>
@@ -370,6 +379,8 @@ class ElementsAreMatcher3 {
const T1& e1_;
const T2& e2_;
const T3& e3_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher3);
};
template <typename T1, typename T2, typename T3, typename T4>
@@ -400,6 +411,8 @@ class ElementsAreMatcher4 {
const T2& e2_;
const T3& e3_;
const T4& e4_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher4);
};
template <typename T1, typename T2, typename T3, typename T4, typename T5>
@@ -432,6 +445,8 @@ class ElementsAreMatcher5 {
const T3& e3_;
const T4& e4_;
const T5& e5_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher5);
};
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -468,6 +483,8 @@ class ElementsAreMatcher6 {
const T4& e4_;
const T5& e5_;
const T6& e6_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher6);
};
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -506,6 +523,8 @@ class ElementsAreMatcher7 {
const T5& e5_;
const T6& e6_;
const T7& e7_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher7);
};
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -546,6 +565,8 @@ class ElementsAreMatcher8 {
const T6& e6_;
const T7& e7_;
const T8& e8_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher8);
};
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -589,6 +610,8 @@ class ElementsAreMatcher9 {
const T7& e7_;
const T8& e8_;
const T9& e9_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher9);
};
template <typename T1, typename T2, typename T3, typename T4, typename T5,
@@ -634,6 +657,8 @@ class ElementsAreMatcher10 {
const T8& e8_;
const T9& e9_;
const T10& e10_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher10);
};
} // namespace internal
@@ -1012,6 +1037,8 @@ ElementsAreArray(const T (&array)[N]) {
#name, description, gmock_interp_, gmock_printed_params);\
}\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1023,7 +1050,9 @@ ElementsAreArray(const T (&array)[N]) {
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##Matcher);\
};\
inline name##Matcher name() {\
return name##Matcher();\
@@ -1052,6 +1081,8 @@ ElementsAreArray(const T (&array)[N]) {
}\
p0##_type p0;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1064,7 +1095,9 @@ ElementsAreArray(const T (&array)[N]) {
gmock_param_names, ("" description ""));\
}\
p0##_type p0;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP);\
};\
template <typename p0##_type>\
inline name##MatcherP<p0##_type> name(p0##_type p0) {\
@@ -1096,6 +1129,8 @@ ElementsAreArray(const T (&array)[N]) {
p0##_type p0;\
p1##_type p1;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1110,7 +1145,9 @@ ElementsAreArray(const T (&array)[N]) {
}\
p0##_type p0;\
p1##_type p1;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\
};\
template <typename p0##_type, typename p1##_type>\
inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \
@@ -1146,6 +1183,8 @@ ElementsAreArray(const T (&array)[N]) {
p1##_type p1;\
p2##_type p2;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1161,7 +1200,9 @@ ElementsAreArray(const T (&array)[N]) {
p0##_type p0;\
p1##_type p1;\
p2##_type p2;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type>\
inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \
@@ -1200,6 +1241,8 @@ ElementsAreArray(const T (&array)[N]) {
p2##_type p2;\
p3##_type p3;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1217,7 +1260,9 @@ ElementsAreArray(const T (&array)[N]) {
p1##_type p1;\
p2##_type p2;\
p3##_type p3;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type>\
@@ -1261,6 +1306,8 @@ ElementsAreArray(const T (&array)[N]) {
p3##_type p3;\
p4##_type p4;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1280,7 +1327,9 @@ ElementsAreArray(const T (&array)[N]) {
p2##_type p2;\
p3##_type p3;\
p4##_type p4;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type>\
@@ -1325,6 +1374,8 @@ ElementsAreArray(const T (&array)[N]) {
p4##_type p4;\
p5##_type p5;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1345,7 +1396,9 @@ ElementsAreArray(const T (&array)[N]) {
p3##_type p3;\
p4##_type p4;\
p5##_type p5;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type>\
@@ -1396,6 +1449,8 @@ ElementsAreArray(const T (&array)[N]) {
p5##_type p5;\
p6##_type p6;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1419,7 +1474,9 @@ ElementsAreArray(const T (&array)[N]) {
p4##_type p4;\
p5##_type p5;\
p6##_type p6;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
@@ -1474,6 +1531,8 @@ ElementsAreArray(const T (&array)[N]) {
p6##_type p6;\
p7##_type p7;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1500,7 +1559,9 @@ ElementsAreArray(const T (&array)[N]) {
p5##_type p5;\
p6##_type p6;\
p7##_type p7;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
@@ -1557,6 +1618,8 @@ ElementsAreArray(const T (&array)[N]) {
p7##_type p7;\
p8##_type p8;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1584,7 +1647,9 @@ ElementsAreArray(const T (&array)[N]) {
p6##_type p6;\
p7##_type p7;\
p8##_type p8;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
@@ -1645,6 +1710,8 @@ ElementsAreArray(const T (&array)[N]) {
p8##_type p8;\
p9##_type p9;\
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -1673,7 +1740,9 @@ ElementsAreArray(const T (&array)[N]) {
p7##_type p7;\
p8##_type p8;\
p9##_type p9;\
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\
};\
template <typename p0##_type, typename p1##_type, typename p2##_type, \
typename p3##_type, typename p4##_type, typename p5##_type, \
diff --git a/include/gmock/gmock-generated-matchers.h.pump b/include/gmock/gmock-generated-matchers.h.pump
index c43aa873..8abbc0cb 100644
--- a/include/gmock/gmock-generated-matchers.h.pump
+++ b/include/gmock/gmock-generated-matchers.h.pump
@@ -91,7 +91,7 @@ template <class Tuple$for j [[, int k$j]]>
class TupleFields<Tuple, $for k, [[$if k < i [[k$k]] $else [[-1]]]]> {
public:
typedef ::std::tr1::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;
- static type GetSelectedFields(const Tuple& t) {
+ static type GetSelectedFields(const Tuple& $if i==0 [[/* t */]] $else [[t]]) {
using ::std::tr1::get;
return type($for j, [[get<k$j>(t)]]);
}
@@ -157,6 +157,8 @@ class ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {
}
const MonomorphicInnerMatcher inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);
};
template <class InnerMatcher$for i [[, int k$i = -1]]>
@@ -170,7 +172,10 @@ class ArgsMatcher {
return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, $ks>(inner_matcher_));
}
+ private:
const InnerMatcher inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ArgsMatcher);
};
// Implements ElementsAre() of 1-$n arguments.
@@ -224,6 +229,8 @@ $for j [[
const T$j& e$j[[]]_;
]]
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher$i);
};
@@ -512,6 +519,8 @@ $var param_field_decls2 = [[$for j
#name, description, gmock_interp_, gmock_printed_params);\
}\$param_field_decls
const ::testing::internal::Interpolations gmock_interp_;\
+ private:\
+ GTEST_DISALLOW_ASSIGN_(gmock_Impl);\
};\
template <typename arg_type>\
operator ::testing::Matcher<arg_type>() const {\
@@ -523,7 +532,9 @@ $var param_field_decls2 = [[$for j
gmock_interp_ = ::testing::internal::ValidateMatcherDescription(\
gmock_param_names, ("" description ""));\
}\$param_field_decls2
+ private:\
::testing::internal::Interpolations gmock_interp_;\
+ GTEST_DISALLOW_ASSIGN_($class_name);\
};\$template
inline $class_name$param_types name($param_types_and_names) {\
return $class_name$param_types($params);\
diff --git a/include/gmock/gmock-generated-nice-strict.h b/include/gmock/gmock-generated-nice-strict.h
index fc9a81b5..435467fa 100644
--- a/include/gmock/gmock-generated-nice-strict.h
+++ b/include/gmock/gmock-generated-nice-strict.h
@@ -155,6 +155,9 @@ class NiceMock : public MockClass {
::testing::Mock::UnregisterCallReaction(
internal::implicit_cast<MockClass*>(this));
}
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
};
template <class MockClass>
@@ -246,6 +249,9 @@ class StrictMock : public MockClass {
::testing::Mock::UnregisterCallReaction(
internal::implicit_cast<MockClass*>(this));
}
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
};
// The following specializations catch some (relatively more common)
diff --git a/include/gmock/gmock-generated-nice-strict.h.pump b/include/gmock/gmock-generated-nice-strict.h.pump
index b265c2e4..96371f57 100644
--- a/include/gmock/gmock-generated-nice-strict.h.pump
+++ b/include/gmock/gmock-generated-nice-strict.h.pump
@@ -100,6 +100,9 @@ $range j 1..i
::testing::Mock::UnregisterCallReaction(
internal::implicit_cast<MockClass*>(this));
}
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);
};
template <class MockClass>
@@ -132,6 +135,9 @@ $range j 1..i
::testing::Mock::UnregisterCallReaction(
internal::implicit_cast<MockClass*>(this));
}
+
+ private:
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);
};
// The following specializations catch some (relatively more common)
diff --git a/include/gmock/gmock-matchers.h b/include/gmock/gmock-matchers.h
index deb09463..5f5a29fd 100644
--- a/include/gmock/gmock-matchers.h
+++ b/include/gmock/gmock-matchers.h
@@ -121,6 +121,7 @@ class MatcherBase {
void ExplainMatchResultTo(T x, ::std::ostream* os) const {
impl_->ExplainMatchResultTo(x, os);
}
+
protected:
MatcherBase() {}
@@ -129,6 +130,7 @@ class MatcherBase {
: impl_(impl) {}
virtual ~MatcherBase() {}
+
private:
// shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar
// interfaces. The former dynamically allocates a chunk of memory
@@ -234,7 +236,7 @@ class Matcher<internal::string>
template <class Impl>
class PolymorphicMatcher {
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
// implementation object.
@@ -248,6 +250,7 @@ class PolymorphicMatcher {
operator Matcher<T>() const {
return Matcher<T>(new MonomorphicImpl<T>(impl_));
}
+
private:
template <typename T>
class MonomorphicImpl : public MatcherInterface<T> {
@@ -284,9 +287,13 @@ class PolymorphicMatcher {
private:
const Impl impl_;
+
+ GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);
};
Impl impl_;
+
+ GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher);
};
// Creates a matcher from its implementation. This is easier to use
@@ -522,6 +529,7 @@ class MatcherCastImpl<T, Matcher<U> > {
static Matcher<T> Cast(const Matcher<U>& source_matcher) {
return Matcher<T>(new Impl(source_matcher));
}
+
private:
class Impl : public MatcherInterface<T> {
public:
@@ -544,8 +552,11 @@ class MatcherCastImpl<T, Matcher<U> > {
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const {
source_matcher_.ExplainMatchResultTo(static_cast<U>(x), os);
}
+
private:
const Matcher<U> source_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
};
};
@@ -618,8 +629,10 @@ class AnythingMatcher {
} \
private: \
Rhs rhs_; \
+ GTEST_DISALLOW_ASSIGN_(Impl); \
}; \
Rhs rhs_; \
+ GTEST_DISALLOW_ASSIGN_(name##Matcher); \
}
// Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v)
@@ -697,6 +710,7 @@ class RefMatcher<T&> {
// reference to a non-const reference.
return MakeMatcher(new Impl<Super>(object_));
}
+
private:
template <typename Super>
class Impl : public MatcherInterface<Super&> {
@@ -721,11 +735,16 @@ class RefMatcher<T&> {
::std::ostream* os) const {
*os << "is located @" << static_cast<const void*>(&x);
}
+
private:
const Super& object_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
};
T& object_;
+
+ GTEST_DISALLOW_ASSIGN_(RefMatcher);
};
// Polymorphic helper functions for narrow and wide string matchers.
@@ -795,6 +814,7 @@ class StrEqualityMatcher {
void DescribeNegationTo(::std::ostream* os) const {
DescribeToHelper(!expect_eq_, os);
}
+
private:
void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {
*os << "is ";
@@ -811,6 +831,8 @@ class StrEqualityMatcher {
const StringType string_;
const bool expect_eq_;
const bool case_sensitive_;
+
+ GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher);
};
// Implements the polymorphic HasSubstr(substring) matcher, which
@@ -845,8 +867,11 @@ class HasSubstrMatcher {
*os << "has no substring ";
UniversalPrinter<StringType>::Print(substring_, os);
}
+
private:
const StringType substring_;
+
+ GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher);
};
// Implements the polymorphic StartsWith(substring) matcher, which
@@ -881,8 +906,11 @@ class StartsWithMatcher {
*os << "doesn't start with ";
UniversalPrinter<StringType>::Print(prefix_, os);
}
+
private:
const StringType prefix_;
+
+ GTEST_DISALLOW_ASSIGN_(StartsWithMatcher);
};
// Implements the polymorphic EndsWith(substring) matcher, which
@@ -916,8 +944,11 @@ class EndsWithMatcher {
*os << "doesn't end with ";
UniversalPrinter<StringType>::Print(suffix_, os);
}
+
private:
const StringType suffix_;
+
+ GTEST_DISALLOW_ASSIGN_(EndsWithMatcher);
};
#if GMOCK_HAS_REGEX
@@ -954,9 +985,12 @@ class MatchesRegexMatcher {
<< " regular expression ";
UniversalPrinter<internal::string>::Print(regex_->pattern(), os);
}
+
private:
const internal::linked_ptr<const RE> regex_;
const bool full_match_;
+
+ GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher);
};
#endif // GMOCK_HAS_REGEX
@@ -1030,8 +1064,11 @@ class NotMatcherImpl : public MatcherInterface<T> {
virtual void ExplainMatchResultTo(T x, ::std::ostream* os) const {
matcher_.ExplainMatchResultTo(x, os);
}
+
private:
const Matcher<T> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(NotMatcherImpl);
};
// Implements the Not(m) matcher, which matches a value that doesn't
@@ -1047,8 +1084,11 @@ class NotMatcher {
operator Matcher<T>() const {
return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));
}
+
private:
InnerMatcher matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(NotMatcher);
};
// Implements the AllOf(m1, m2) matcher for a particular argument type
@@ -1108,9 +1148,12 @@ class BothOfMatcherImpl : public MatcherInterface<T> {
}
}
}
+
private:
const Matcher<T> matcher1_;
const Matcher<T> matcher2_;
+
+ GTEST_DISALLOW_ASSIGN_(BothOfMatcherImpl);
};
// Used for implementing the AllOf(m_1, ..., m_n) matcher, which
@@ -1129,9 +1172,12 @@ class BothOfMatcher {
return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),
SafeMatcherCast<T>(matcher2_)));
}
+
private:
Matcher1 matcher1_;
Matcher2 matcher2_;
+
+ GTEST_DISALLOW_ASSIGN_(BothOfMatcher);
};
// Implements the AnyOf(m1, m2) matcher for a particular argument type
@@ -1190,9 +1236,12 @@ class EitherOfMatcherImpl : public MatcherInterface<T> {
}
}
}
+
private:
const Matcher<T> matcher1_;
const Matcher<T> matcher2_;
+
+ GTEST_DISALLOW_ASSIGN_(EitherOfMatcherImpl);
};
// Used for implementing the AnyOf(m_1, ..., m_n) matcher, which
@@ -1212,9 +1261,12 @@ class EitherOfMatcher {
return Matcher<T>(new EitherOfMatcherImpl<T>(
SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));
}
+
private:
Matcher1 matcher1_;
Matcher2 matcher2_;
+
+ GTEST_DISALLOW_ASSIGN_(EitherOfMatcher);
};
// Used for implementing Truly(pred), which turns a predicate into a
@@ -1248,8 +1300,11 @@ class TrulyMatcher {
void DescribeNegationTo(::std::ostream* os) const {
*os << "doesn't satisfy the given predicate";
}
+
private:
Predicate predicate_;
+
+ GTEST_DISALLOW_ASSIGN_(TrulyMatcher);
};
// Used for implementing Matches(matcher), which turns a matcher into
@@ -1283,8 +1338,11 @@ class MatcherAsPredicate {
// in all of the above situations.
return MatcherCast<const T&>(matcher_).Matches(x);
}
+
private:
M matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate);
};
// For implementing ASSERT_THAT() and EXPECT_THAT(). The template
@@ -1322,8 +1380,11 @@ class PredicateFormatterFromMatcher {
return AssertionFailure(Message() << ss.str());
}
}
+
private:
const M matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher);
};
// A helper function for converting a matcher to a predicate-formatter
@@ -1405,6 +1466,8 @@ class FloatingEqMatcher {
private:
const FloatType rhs_;
const bool nan_eq_nan_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
};
// The following 3 type conversion operators allow FloatEq(rhs) and
@@ -1427,6 +1490,8 @@ class FloatingEqMatcher {
private:
const FloatType rhs_;
const bool nan_eq_nan_;
+
+ GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher);
};
// Implements the Pointee(m) matcher for matching a pointer whose
@@ -1448,6 +1513,7 @@ class PointeeMatcher {
operator Matcher<Pointer>() const {
return MakeMatcher(new Impl<Pointer>(matcher_));
}
+
private:
// The monomorphic implementation that works for a particular pointer type.
template <typename Pointer>
@@ -1485,11 +1551,16 @@ class PointeeMatcher {
*os << "points to a value that " << s;
}
}
+
private:
const Matcher<const Pointee&> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
};
const InnerMatcher matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PointeeMatcher);
};
// Implements the Field() matcher for matching a field (i.e. member
@@ -1543,9 +1614,12 @@ class FieldMatcher {
ExplainMatchResultTo(false_type(), *p, os);
}
}
+
private:
const FieldType Class::*field_;
const Matcher<const FieldType&> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(FieldMatcher);
};
// Explains the result of matching an object or pointer against a field matcher.
@@ -1613,9 +1687,12 @@ class PropertyMatcher {
ExplainMatchResultTo(false_type(), *p, os);
}
}
+
private:
PropertyType (Class::*property_)() const;
const Matcher<RefToConstProperty> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PropertyMatcher);
};
// Explains the result of matching an object or pointer against a
@@ -1636,7 +1713,7 @@ struct CallableTraits {
typedef typename Functor::result_type ResultType;
typedef Functor StorageType;
- static void CheckIsValid(Functor functor) {}
+ static void CheckIsValid(Functor /* functor */) {}
template <typename T>
static ResultType Invoke(Functor f, T arg) { return f(arg); }
};
@@ -1709,6 +1786,7 @@ class ResultOfMatcher {
if (s != "")
*os << "result of the given callable " << s;
}
+
private:
// Functors often define operator() as non-const method even though
// they are actualy stateless. But we need to use them even when
@@ -1717,10 +1795,14 @@ class ResultOfMatcher {
// how many times the callable will be invoked.
mutable CallableStorageType callable_;
const Matcher<ResultType> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(Impl);
}; // class Impl
const CallableStorageType callable_;
const Matcher<ResultType> matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ResultOfMatcher);
};
// Explains the result of matching a value against a functor matcher.
@@ -1818,8 +1900,11 @@ class ContainerEqMatcher {
}
}
}
+
private:
const StlContainer rhs_;
+
+ GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher);
};
template <typename LhsContainer, typename Container>
@@ -1884,6 +1969,8 @@ class ContainsMatcherImpl : public MatcherInterface<Container> {
private:
const Matcher<const Element&> inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl);
};
// Implements polymorphic Contains(element_matcher).
@@ -1899,6 +1986,8 @@ class ContainsMatcher {
private:
const M inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(ContainsMatcher);
};
// Implements Key(inner_matcher) for the given argument pair type.
@@ -1942,6 +2031,8 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
private:
const Matcher<const KeyType&> inner_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl);
};
// Implements polymorphic Key(matcher_for_key).
@@ -1957,6 +2048,8 @@ class KeyMatcher {
private:
const M matcher_for_key_;
+
+ GTEST_DISALLOW_ASSIGN_(KeyMatcher);
};
// Implements Pair(first_matcher, second_matcher) for the given argument pair
@@ -2026,6 +2119,8 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
private:
const Matcher<const FirstType&> first_matcher_;
const Matcher<const SecondType&> second_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PairMatcherImpl);
};
// Implements polymorphic Pair(first_matcher, second_matcher).
@@ -2045,6 +2140,8 @@ class PairMatcher {
private:
const FirstMatcher first_matcher_;
const SecondMatcher second_matcher_;
+
+ GTEST_DISALLOW_ASSIGN_(PairMatcher);
};
// Implements ElementsAre() and ElementsAreArray().
@@ -2060,10 +2157,10 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
// Constructs the matcher from a sequence of element values or
// element matchers.
template <typename InputIter>
- ElementsAreMatcherImpl(InputIter first, size_t count) {
- matchers_.reserve(count);
+ ElementsAreMatcherImpl(InputIter first, size_t a_count) {
+ matchers_.reserve(a_count);
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));
}
}
@@ -2185,6 +2282,8 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
size_t count() const { return matchers_.size(); }
std::vector<Matcher<const Element&> > matchers_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl);
};
// Implements ElementsAre() of 0 arguments.
@@ -2224,6 +2323,8 @@ class ElementsAreArrayMatcher {
private:
const T* const first_;
const size_t count_;
+
+ GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher);
};
// Constants denoting interpolations in a matcher description string.
diff --git a/include/gmock/gmock-more-actions.h b/include/gmock/gmock-more-actions.h
index c6fa6bbd..6226392d 100644
--- a/include/gmock/gmock-more-actions.h
+++ b/include/gmock/gmock-more-actions.h
@@ -58,8 +58,11 @@ class InvokeAction {
Result Perform(const ArgumentTuple& args) {
return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args);
}
+
private:
FunctionImpl function_impl_;
+
+ GTEST_DISALLOW_ASSIGN_(InvokeAction);
};
// Implements the Invoke(object_ptr, &Class::Method) action.
@@ -74,9 +77,12 @@ class InvokeMethodAction {
return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(
obj_ptr_, method_ptr_, args);
}
+
private:
Class* const obj_ptr_;
const MethodPtr method_ptr_;
+
+ GTEST_DISALLOW_ASSIGN_(InvokeMethodAction);
};
} // namespace internal
@@ -122,6 +128,16 @@ WithArg(const InnerAction& action) {
return internal::WithArgsAction<InnerAction, k>(action);
}
+// 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
+
// Action ReturnArg<k>() returns the k-th argument of the mock function.
ACTION_TEMPLATE(ReturnArg,
HAS_1_TEMPLATE_PARAMS(int, k),
@@ -185,6 +201,10 @@ ACTION_TEMPLATE(DeleteArg,
ACTION_P(Throw, exception) { throw exception; }
#endif // GTEST_HAS_EXCEPTIONS
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
} // namespace testing
#endif // GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_
diff --git a/include/gmock/gmock-spec-builders.h b/include/gmock/gmock-spec-builders.h
index 9cb549ab..9aa0a9ee 100644
--- a/include/gmock/gmock-spec-builders.h
+++ b/include/gmock/gmock-spec-builders.h
@@ -142,10 +142,10 @@ class DefaultActionSpec {
// Constructs a DefaultActionSpec object from the information inside
// the parenthesis of an ON_CALL() statement.
- DefaultActionSpec(const char* file, int line,
+ DefaultActionSpec(const char* a_file, int a_line,
const ArgumentMatcherTuple& matchers)
- : file_(file),
- line_(line),
+ : file_(a_file),
+ line_(a_line),
matchers_(matchers),
// By default, extra_matcher_ should match anything. However,
// we cannot initialize it with _ as that triggers a compiler
@@ -196,6 +196,7 @@ class DefaultActionSpec {
"once in an ON_CALL().");
return action_;
}
+
private:
// Gives each clause in the ON_CALL() statement a name.
enum Clause {
@@ -582,6 +583,7 @@ class ExpectationBase {
// expectation has occurred.
// L >= g_gmock_mutex
virtual void DescribeCallCountTo(::std::ostream* os) const = 0;
+
protected:
friend class ::testing::Expectation;
@@ -620,8 +622,8 @@ class ExpectationBase {
bool cardinality_specified() const { return cardinality_specified_; }
// Sets the cardinality of this expectation spec.
- void set_cardinality(const Cardinality& cardinality) {
- cardinality_ = cardinality;
+ void set_cardinality(const Cardinality& a_cardinality) {
+ cardinality_ = a_cardinality;
}
// The following group of methods should only be called after the
@@ -716,6 +718,8 @@ class ExpectationBase {
// and can change as the mock function is called.
int call_count_; // How many times this expectation has been invoked.
bool retired_; // True iff this expectation has retired.
+
+ GTEST_DISALLOW_ASSIGN_(ExpectationBase);
}; // class ExpectationBase
// Impements an expectation for the given function type.
@@ -727,9 +731,9 @@ class TypedExpectation : public ExpectationBase {
typedef typename Function<F>::Result Result;
TypedExpectation(FunctionMockerBase<F>* owner,
- const char* file, int line, const string& source_text,
+ const char* a_file, int a_line, const string& a_source_text,
const ArgumentMatcherTuple& m)
- : ExpectationBase(file, line, source_text),
+ : ExpectationBase(a_file, a_line, a_source_text),
owner_(owner),
matchers_(m),
extra_matcher_specified_(false),
@@ -769,7 +773,7 @@ class TypedExpectation : public ExpectationBase {
}
// Implements the .Times() clause.
- TypedExpectation& Times(const Cardinality& cardinality) {
+ TypedExpectation& Times(const Cardinality& a_cardinality) {
if (last_clause_ ==kTimes) {
ExpectSpecProperty(false,
".Times() cannot appear "
@@ -782,7 +786,7 @@ class TypedExpectation : public ExpectationBase {
}
last_clause_ = kTimes;
- ExpectationBase::SpecifyCardinality(cardinality);
+ ExpectationBase::SpecifyCardinality(a_cardinality);
return *this;
}
@@ -1164,6 +1168,8 @@ class TypedExpectation : public ExpectationBase {
Clause last_clause_;
mutable bool action_count_checked_; // Under mutex_.
mutable Mutex mutex_; // Protects action_count_checked_.
+
+ GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);
}; // class TypedExpectation
// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for
@@ -1228,6 +1234,8 @@ class MockSpec {
internal::FunctionMockerBase<F>* const function_mocker_;
// The argument matchers specified in the spec.
ArgumentMatcherTuple matchers_;
+
+ GTEST_DISALLOW_ASSIGN_(MockSpec);
}; // class MockSpec
// MSVC warns about using 'this' in base member initializer list, so
@@ -1251,7 +1259,7 @@ class MockSpec {
template <typename T>
class ActionResultHolder {
public:
- explicit ActionResultHolder(T value) : value_(value) {}
+ explicit ActionResultHolder(T a_value) : value_(a_value) {}
// The compiler-generated copy constructor and assignment operator
// are exactly what we need, so we don't need to define them.
@@ -1285,6 +1293,9 @@ class ActionResultHolder {
private:
T value_;
+
+ // T could be a reference type, so = isn't supported.
+ GTEST_DISALLOW_ASSIGN_(ActionResultHolder);
};
// Specialization for T = void.
@@ -1433,6 +1444,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
}
return name;
}
+
protected:
template <typename Function>
friend class MockSpec;
@@ -1477,6 +1489,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase {
// The current spec (either default action spec or expectation spec)
// being described on this function mocker.
MockSpec<F>& current_spec() { return current_spec_; }
+
private:
template <typename Func> friend class TypedExpectation;
diff --git a/include/gmock/internal/gmock-internal-utils.h b/include/gmock/internal/gmock-internal-utils.h
index 7b173350..0c33fdd0 100644
--- a/include/gmock/internal/gmock-internal-utils.h
+++ b/include/gmock/internal/gmock-internal-utils.h
@@ -640,15 +640,15 @@ class NativeArray {
// Initializes this object; makes a copy of the input array if
// 'relation' is kCopy.
- void Init(const Element* array, size_t size, RelationToSource relation) {
+ void Init(const Element* array, size_t a_size, RelationToSource relation) {
if (relation == kReference) {
array_ = array;
} else {
- Element* const copy = new Element[size];
- CopyArray(array, size, copy);
+ Element* const copy = new Element[a_size];
+ CopyArray(array, a_size, copy);
array_ = copy;
}
- size_ = size;
+ size_ = a_size;
relation_to_source_ = relation;
}