summaryrefslogtreecommitdiffstats
path: root/googlemock
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-03-15 20:41:41 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-03-15 20:42:11 (GMT)
commitb007c54f2944e193ac44fba1bc997cb65826a0b9 (patch)
tree3ea747410f93a40da0df6f8777e2ba551761cf8c /googlemock
parent8a422b8398dd7e2b6b3e1fcbfbceb43ead2a5761 (diff)
downloadgoogletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.zip
googletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.tar.gz
googletest-b007c54f2944e193ac44fba1bc997cb65826a0b9.tar.bz2
Running clang-format over all of GoogleTest
A few tests are examining code locations and looking af the resulting line numbers to verify that GoogleTest shows those to users correctly. Some of those locations change when clang-format is run. For those locations, I've wrapped portions in: // clang-format off ... // clang-format on There may be other locations that are currently not tickled by running clang-format. PiperOrigin-RevId: 434844712 Change-Id: I3a9f0a6f39eff741c576b6de389bef9b1d11139d
Diffstat (limited to 'googlemock')
-rw-r--r--googlemock/include/gmock/gmock-actions.h167
-rw-r--r--googlemock/include/gmock/gmock-cardinalities.h4
-rw-r--r--googlemock/include/gmock/gmock-function-mocker.h2
-rw-r--r--googlemock/include/gmock/gmock-more-actions.h596
-rw-r--r--googlemock/include/gmock/gmock-more-matchers.h11
-rw-r--r--googlemock/include/gmock/gmock-spec-builders.h208
-rw-r--r--googlemock/include/gmock/internal/gmock-internal-utils.h71
-rw-r--r--googlemock/include/gmock/internal/gmock-port.h23
-rw-r--r--googlemock/src/gmock-cardinalities.cc9
-rw-r--r--googlemock/src/gmock-internal-utils.cc24
-rw-r--r--googlemock/src/gmock-matchers.cc1
-rw-r--r--googlemock/src/gmock-spec-builders.cc62
-rw-r--r--googlemock/src/gmock.cc2
-rw-r--r--googlemock/src/gmock_main.cc4
-rw-r--r--googlemock/test/gmock-actions_test.cc168
-rw-r--r--googlemock/test/gmock-cardinalities_test.cc108
-rw-r--r--googlemock/test/gmock-function-mocker_test.cc83
-rw-r--r--googlemock/test/gmock-internal-utils_test.cc143
-rw-r--r--googlemock/test/gmock-matchers_test.cc808
-rw-r--r--googlemock/test/gmock-more-actions_test.cc33
-rw-r--r--googlemock/test/gmock-nice-strict_test.cc20
-rw-r--r--googlemock/test/gmock-port_test.cc2
-rw-r--r--googlemock/test/gmock-pp-string_test.cc3
-rw-r--r--googlemock/test/gmock-spec-builders_test.cc909
-rw-r--r--googlemock/test/gmock_ex_test.cc2
-rw-r--r--googlemock/test/gmock_leak_test_.cc1
-rw-r--r--googlemock/test/gmock_link2_test.cc1
-rw-r--r--googlemock/test/gmock_link_test.cc1
-rw-r--r--googlemock/test/gmock_link_test.h34
-rw-r--r--googlemock/test/gmock_output_test_.cc63
-rw-r--r--googlemock/test/gmock_stress_test.cc53
-rw-r--r--googlemock/test/gmock_test.cc2
32 files changed, 1678 insertions, 1940 deletions
diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h
index 035b66b..26272e9 100644
--- a/googlemock/include/gmock/gmock-actions.h
+++ b/googlemock/include/gmock/gmock-actions.h
@@ -131,7 +131,7 @@
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#ifndef _WIN32_WCE
-# include <errno.h>
+#include <errno.h>
#endif
#include <algorithm>
@@ -147,8 +147,8 @@
#include "gmock/internal/gmock-pp.h"
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
+#pragma warning(push)
+#pragma warning(disable : 4100)
#endif
namespace testing {
@@ -196,9 +196,7 @@ class BuiltInDefaultValue {
public:
// This function returns true if and only if type T has a built-in default
// value.
- static bool Exists() {
- return ::std::is_default_constructible<T>::value;
- }
+ static bool Exists() { return ::std::is_default_constructible<T>::value; }
static T Get() {
return BuiltInDefaultValueGetter<
@@ -227,11 +225,11 @@ class BuiltInDefaultValue<T*> {
// The following specializations define the default values for
// specific types we care about.
#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \
- template <> \
- class BuiltInDefaultValue<type> { \
- public: \
- static bool Exists() { return true; } \
- static type Get() { return value; } \
+ template <> \
+ class BuiltInDefaultValue<type> { \
+ public: \
+ static bool Exists() { return true; } \
+ static type Get() { return value; } \
}
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, ); // NOLINT
@@ -255,10 +253,10 @@ GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U); // NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0); // NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL); // NOLINT
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L); // NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long long, 0); // NOLINT
-GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long long, 0); // NOLINT
+GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long long, 0); // NOLINT
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);
GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);
@@ -839,7 +837,7 @@ class ReturnRoundRobinAction {
template <typename... Args>
T operator()(Args&&...) const {
- return state_->Next();
+ return state_->Next();
}
private:
@@ -862,7 +860,9 @@ class DoDefaultAction {
// This template type conversion operator allows DoDefault() to be
// used in any function.
template <typename F>
- operator Action<F>() const { return Action<F>(); } // NOLINT
+ operator Action<F>() const {
+ return Action<F>();
+ } // NOLINT
};
// Implements the Assign action to set a given pointer referent to a
@@ -890,8 +890,7 @@ template <typename T>
class SetErrnoAndReturnAction {
public:
SetErrnoAndReturnAction(int errno_value, T result)
- : errno_(errno_value),
- result_(result) {}
+ : errno_(errno_value), result_(result) {}
template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& /* args */) const {
errno = errno_;
@@ -1002,8 +1001,8 @@ class IgnoreResultAction {
private:
// Type OriginalFunction is the same as F except that its return
// type is IgnoredValue.
- typedef typename internal::Function<F>::MakeResultIgnoredValue
- OriginalFunction;
+ typedef
+ typename internal::Function<F>::MakeResultIgnoredValue OriginalFunction;
const Action<OriginalFunction> action_;
};
@@ -1020,12 +1019,12 @@ struct WithArgsAction {
template <typename R, typename... Args>
operator Action<R(Args...)>() const { // NOLINT
using TupleType = std::tuple<Args...>;
- Action<R(typename std::tuple_element<I, TupleType>::type...)>
- converted(action);
+ Action<R(typename std::tuple_element<I, TupleType>::type...)> converted(
+ action);
return [converted](Args... args) -> R {
return converted.Perform(std::forward_as_tuple(
- std::get<I>(std::forward_as_tuple(std::forward<Args>(args)...))...));
+ std::get<I>(std::forward_as_tuple(std::forward<Args>(args)...))...));
};
}
};
@@ -1212,8 +1211,8 @@ internal::DoAllAction<typename std::decay<Action>::type...> DoAll(
// multiple arguments. For convenience, we also provide
// WithArgs<k>(an_action) (defined below) as a synonym.
template <size_t k, typename InnerAction>
-internal::WithArgsAction<typename std::decay<InnerAction>::type, k>
-WithArg(InnerAction&& action) {
+internal::WithArgsAction<typename std::decay<InnerAction>::type, k> WithArg(
+ InnerAction&& action) {
return {std::forward<InnerAction>(action)};
}
@@ -1232,8 +1231,8 @@ WithArgs(InnerAction&& action) {
// argument. In other words, it adapts an action accepting no
// argument to one that accepts (and ignores) arguments.
template <typename InnerAction>
-internal::WithArgsAction<typename std::decay<InnerAction>::type>
-WithoutArgs(InnerAction&& action) {
+internal::WithArgsAction<typename std::decay<InnerAction>::type> WithoutArgs(
+ InnerAction&& action) {
return {std::forward<InnerAction>(action)};
}
@@ -1319,7 +1318,7 @@ internal::SetArgumentPointeeAction<N, T> SetArgumentPointee(T value) {
// Creates an action that sets a pointer referent to a given value.
template <typename T1, typename T2>
-PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
+PolymorphicAction<internal::AssignAction<T1, T2>> Assign(T1* ptr, T2 val) {
return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
}
@@ -1327,8 +1326,8 @@ PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {
// Creates an action that sets errno and returns the appropriate error.
template <typename T>
-PolymorphicAction<internal::SetErrnoAndReturnAction<T> >
-SetErrnoAndReturn(int errval, T result) {
+PolymorphicAction<internal::SetErrnoAndReturnAction<T>> SetErrnoAndReturn(
+ int errval, T result) {
return MakePolymorphicAction(
internal::SetErrnoAndReturnAction<T>(errval, result));
}
@@ -1482,7 +1481,8 @@ struct ExcessiveArg {};
// Builds an implementation of an Action<> for some particular signature, using
// a class defined by an ACTION* macro.
-template <typename F, typename Impl> struct ActionImpl;
+template <typename F, typename Impl>
+struct ActionImpl;
template <typename Impl>
struct ImplBase {
@@ -1502,7 +1502,7 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
using args_type = std::tuple<Args...>;
ActionImpl() = default; // Only defined if appropriate for Base.
- explicit ActionImpl(std::shared_ptr<Impl> impl) : Base{std::move(impl)} { }
+ explicit ActionImpl(std::shared_ptr<Impl> impl) : Base{std::move(impl)} {}
R operator()(Args&&... arg) const {
static constexpr size_t kMaxArgs =
@@ -1521,12 +1521,14 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
// args_type get passed, followed by a dummy of unspecified type for the
// remainder up to 10 explicit args.
static constexpr ExcessiveArg kExcessArg{};
- return static_cast<const Impl&>(*this).template gmock_PerformImpl<
- /*function_type=*/function_type, /*return_type=*/R,
- /*args_type=*/args_type,
- /*argN_type=*/typename std::tuple_element<arg_id, args_type>::type...>(
- /*args=*/args, std::get<arg_id>(args)...,
- ((void)excess_id, kExcessArg)...);
+ return static_cast<const Impl&>(*this)
+ .template gmock_PerformImpl<
+ /*function_type=*/function_type, /*return_type=*/R,
+ /*args_type=*/args_type,
+ /*argN_type=*/
+ typename std::tuple_element<arg_id, args_type>::type...>(
+ /*args=*/args, std::get<arg_id>(args)...,
+ ((void)excess_id, kExcessArg)...);
}
};
@@ -1545,7 +1547,7 @@ template <typename F, typename Impl>
#define GMOCK_INTERNAL_ARG_UNUSED(i, data, el) \
, const arg##i##_type& arg##i GTEST_ATTRIBUTE_UNUSED_
-#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
+#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_ \
const args_type& args GTEST_ATTRIBUTE_UNUSED_ GMOCK_PP_REPEAT( \
GMOCK_INTERNAL_ARG_UNUSED, , 10)
@@ -1584,45 +1586,47 @@ template <typename F, typename Impl>
#define GMOCK_ACTION_FIELD_PARAMS_(params) \
GMOCK_PP_FOR_EACH(GMOCK_INTERNAL_FIELD_PARAM, , params)
-#define GMOCK_INTERNAL_ACTION(name, full_name, params) \
- template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
- class full_name { \
- public: \
- explicit full_name(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
- : impl_(std::make_shared<gmock_Impl>( \
- GMOCK_ACTION_GVALUE_PARAMS_(params))) { } \
- full_name(const full_name&) = default; \
- full_name(full_name&&) noexcept = default; \
- template <typename F> \
- operator ::testing::Action<F>() const { \
- return ::testing::internal::MakeAction<F>(impl_); \
- } \
- private: \
- class gmock_Impl { \
- public: \
- explicit gmock_Impl(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
- : GMOCK_ACTION_INIT_PARAMS_(params) {} \
- template <typename function_type, typename return_type, \
- typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
- return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
- GMOCK_ACTION_FIELD_PARAMS_(params) \
- }; \
- std::shared_ptr<const gmock_Impl> impl_; \
- }; \
- template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
- inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
- GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) GTEST_MUST_USE_RESULT_; \
- template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
- inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
- GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) { \
- return full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>( \
- GMOCK_ACTION_GVALUE_PARAMS_(params)); \
- } \
- template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
- template <typename function_type, typename return_type, typename args_type, \
- GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
- return_type full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>::gmock_Impl:: \
- gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+#define GMOCK_INTERNAL_ACTION(name, full_name, params) \
+ template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
+ class full_name { \
+ public: \
+ explicit full_name(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
+ : impl_(std::make_shared<gmock_Impl>( \
+ GMOCK_ACTION_GVALUE_PARAMS_(params))) {} \
+ full_name(const full_name&) = default; \
+ full_name(full_name&&) noexcept = default; \
+ template <typename F> \
+ operator ::testing::Action<F>() const { \
+ return ::testing::internal::MakeAction<F>(impl_); \
+ } \
+ \
+ private: \
+ class gmock_Impl { \
+ public: \
+ explicit gmock_Impl(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
+ : GMOCK_ACTION_INIT_PARAMS_(params) {} \
+ template <typename function_type, typename return_type, \
+ typename args_type, GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
+ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
+ GMOCK_ACTION_FIELD_PARAMS_(params) \
+ }; \
+ std::shared_ptr<const gmock_Impl> impl_; \
+ }; \
+ template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
+ inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
+ GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) GTEST_MUST_USE_RESULT_; \
+ template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
+ inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \
+ GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) { \
+ return full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>( \
+ GMOCK_ACTION_GVALUE_PARAMS_(params)); \
+ } \
+ template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
+ template <typename function_type, typename return_type, typename args_type, \
+ GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
+ return_type \
+ full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>::gmock_Impl::gmock_PerformImpl( \
+ GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
} // namespace internal
@@ -1630,12 +1634,13 @@ template <typename F, typename Impl>
#define ACTION(name) \
class name##Action { \
public: \
- explicit name##Action() noexcept {} \
- name##Action(const name##Action&) noexcept {} \
+ explicit name##Action() noexcept {} \
+ name##Action(const name##Action&) noexcept {} \
template <typename F> \
operator ::testing::Action<F>() const { \
return ::testing::internal::MakeAction<F, gmock_Impl>(); \
} \
+ \
private: \
class gmock_Impl { \
public: \
@@ -1684,7 +1689,7 @@ template <typename F, typename Impl>
} // namespace testing
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
diff --git a/googlemock/include/gmock/gmock-cardinalities.h b/googlemock/include/gmock/gmock-cardinalities.h
index 48196dd..b6ab648 100644
--- a/googlemock/include/gmock/gmock-cardinalities.h
+++ b/googlemock/include/gmock/gmock-cardinalities.h
@@ -40,8 +40,10 @@
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#include <limits.h>
+
#include <memory>
#include <ostream> // NOLINT
+
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
@@ -116,7 +118,7 @@ class GTEST_API_ Cardinality {
// cardinality, i.e. exceed the maximum number of allowed calls.
bool IsOverSaturatedByCallCount(int call_count) const {
return impl_->IsSaturatedByCallCount(call_count) &&
- !impl_->IsSatisfiedByCallCount(call_count);
+ !impl_->IsSatisfiedByCallCount(call_count);
}
// Describes self to an ostream
diff --git a/googlemock/include/gmock/gmock-function-mocker.h b/googlemock/include/gmock/gmock-function-mocker.h
index 2de1d41..f565d98 100644
--- a/googlemock/include/gmock/gmock-function-mocker.h
+++ b/googlemock/include/gmock/gmock-function-mocker.h
@@ -201,7 +201,7 @@ using internal::FunctionMocker;
GMOCK_INTERNAL_A_MATCHER_ARGUMENT, _Signature, _N)); \
} \
mutable ::testing::FunctionMocker<GMOCK_PP_REMOVE_PARENS(_Signature)> \
- GMOCK_MOCKER_(_N, _Constness, _MethodName)
+ GMOCK_MOCKER_(_N, _Constness, _MethodName)
#define GMOCK_INTERNAL_EXPAND(...) __VA_ARGS__
diff --git a/googlemock/include/gmock/gmock-more-actions.h b/googlemock/include/gmock/gmock-more-actions.h
index bf85ff5..87307f0 100644
--- a/googlemock/include/gmock/gmock-more-actions.h
+++ b/googlemock/include/gmock/gmock-more-actions.h
@@ -129,170 +129,207 @@
// Declares the template parameters.
#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0
-#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
- name1) kind0 name0, kind1 name1
+#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, name1) \
+ kind0 name0, kind1 name1
#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2) kind0 name0, kind1 name1, kind2 name2
+ kind2, name2) \
+ kind0 name0, kind1 name1, kind2 name2
#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \
- kind3 name3
-#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \
- kind2 name2, kind3 name3, kind4 name4
+ kind2, name2, kind3, name3) \
+ kind0 name0, kind1 name1, kind2 name2, kind3 name3
+#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4) \
+ kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4
#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \
- kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
-#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
- name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
- kind5 name5, kind6 name6
-#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
- kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \
- kind4 name4, kind5 name5, kind6 name6, kind7 name7
-#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
- kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \
- kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \
- kind8 name8
-#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
- name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
- name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \
- kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \
- kind6 name6, kind7 name7, kind8 name8, kind9 name9
+ kind2, name2, kind3, name3, \
+ kind4, name4, kind5, name5) \
+ kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5
+#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
+ kind5, name5, kind6, name6) \
+ kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
+ kind5 name5, kind6 name6
+#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
+ kind5, name5, kind6, name6, kind7, name7) \
+ kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
+ kind5 name5, kind6 name6, kind7 name7
+#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
+ kind5, name5, kind6, name6, kind7, name7, kind8, name8) \
+ kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
+ kind5 name5, kind6 name6, kind7 name7, kind8 name8
+#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
+ kind5, name5, kind6, name6, kind7, name7, kind8, name8, kind9, name9) \
+ kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \
+ kind5 name5, kind6 name6, kind7 name7, kind8 name8, kind9 name9
// Lists the template parameters.
#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0
-#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \
- name1) name0, name1
+#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, name1) \
+ name0, name1
#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2) name0, name1, name2
+ kind2, name2) \
+ name0, name1, name2
#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3) name0, name1, name2, name3
-#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \
- name4
+ kind2, name2, kind3, name3) \
+ name0, name1, name2, name3
+#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4) \
+ name0, name1, name2, name3, name4
#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \
- name2, name3, name4, name5
-#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
- name6) name0, name1, name2, name3, name4, name5, name6
-#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
- kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7
-#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \
- kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \
- kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \
- name6, name7, name8
-#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \
- name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \
- name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \
- name3, name4, name5, name6, name7, name8, name9
+ kind2, name2, kind3, name3, \
+ kind4, name4, kind5, name5) \
+ name0, name1, name2, name3, name4, name5
+#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
+ kind5, name5, kind6, name6) \
+ name0, name1, name2, name3, name4, name5, name6
+#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
+ kind5, name5, kind6, name6, kind7, name7) \
+ name0, name1, name2, name3, name4, name5, name6, name7
+#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
+ kind5, name5, kind6, name6, kind7, name7, kind8, name8) \
+ name0, name1, name2, name3, name4, name5, name6, name7, name8
+#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS( \
+ kind0, name0, kind1, name1, kind2, name2, kind3, name3, kind4, name4, \
+ kind5, name5, kind6, name6, kind7, name7, kind8, name8, kind9, name9) \
+ name0, name1, name2, name3, name4, name5, name6, name7, name8, name9
// Declares the types of value parameters.
#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \
- typename p0##_type, typename p1##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \
- typename p0##_type, typename p1##_type, typename p2##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
- typename p0##_type, typename p1##_type, typename p2##_type, \
- typename p3##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
- typename p0##_type, typename p1##_type, typename p2##_type, \
- typename p3##_type, typename p4##_type
-#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
- typename p0##_type, typename p1##_type, typename p2##_type, \
- typename p3##_type, typename p4##_type, typename p5##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) \
+ , typename p0##_type, typename p1##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) \
+ , typename p0##_type, typename p1##_type, typename p2##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
+ , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
+ , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type
+#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
+ , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6) , typename p0##_type, typename p1##_type, typename p2##_type, \
- typename p3##_type, typename p4##_type, typename p5##_type, \
- typename p6##_type
+ p6) \
+ , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \
- typename p3##_type, typename p4##_type, typename p5##_type, \
- typename p6##_type, typename p7##_type
+ p6, p7) \
+ , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \
- typename p3##_type, typename p4##_type, typename p5##_type, \
- typename p6##_type, typename p7##_type, typename p8##_type
+ p6, p7, p8) \
+ , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type
#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \
- typename p2##_type, typename p3##_type, typename p4##_type, \
- typename p5##_type, typename p6##_type, typename p7##_type, \
- typename p8##_type, typename p9##_type
+ p6, p7, p8, p9) \
+ , typename p0##_type, typename p1##_type, typename p2##_type, \
+ typename p3##_type, typename p4##_type, typename p5##_type, \
+ typename p6##_type, typename p7##_type, typename p8##_type, \
+ typename p9##_type
// Initializes the value parameters.
-#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\
- ()
-#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\
- (p0##_type gmock_p0) : p0(::std::move(gmock_p0))
-#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\
- (p0##_type gmock_p0, p1##_type gmock_p1) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1))
-#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\
- (p0##_type gmock_p0, p1##_type gmock_p1, \
- p2##_type gmock_p2) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2))
-#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\
- (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
- p3##_type gmock_p3) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
+#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS() ()
+#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0) \
+ (p0##_type gmock_p0) : p0(::std::move(gmock_p0))
+#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1) \
+ (p0##_type gmock_p0, p1##_type gmock_p1) \
+ : p0(::std::move(gmock_p0)), p1(::std::move(gmock_p1))
+#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2) \
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2) \
+ : p0(::std::move(gmock_p0)), \
+ p1(::std::move(gmock_p1)), \
+ p2(::std::move(gmock_p2))
+#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3) \
+ : p0(::std::move(gmock_p0)), \
+ p1(::std::move(gmock_p1)), \
+ p2(::std::move(gmock_p2)), \
p3(::std::move(gmock_p3))
-#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\
- (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
- p3##_type gmock_p3, p4##_type gmock_p4) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
- p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4))
-#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\
- (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
- p3##_type gmock_p3, p4##_type gmock_p4, \
- p5##_type gmock_p5) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
- p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
+#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4) \
+ : p0(::std::move(gmock_p0)), \
+ p1(::std::move(gmock_p1)), \
+ p2(::std::move(gmock_p2)), \
+ p3(::std::move(gmock_p3)), \
+ p4(::std::move(gmock_p4))
+#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5) \
+ : p0(::std::move(gmock_p0)), \
+ p1(::std::move(gmock_p1)), \
+ p2(::std::move(gmock_p2)), \
+ p3(::std::move(gmock_p3)), \
+ p4(::std::move(gmock_p4)), \
p5(::std::move(gmock_p5))
-#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\
- (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
- p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
- p6##_type gmock_p6) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
- p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
- p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6))
-#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\
- (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
- p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
- p6##_type gmock_p6, p7##_type gmock_p7) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
- p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
- p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
+#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6) \
+ : p0(::std::move(gmock_p0)), \
+ p1(::std::move(gmock_p1)), \
+ p2(::std::move(gmock_p2)), \
+ p3(::std::move(gmock_p3)), \
+ p4(::std::move(gmock_p4)), \
+ p5(::std::move(gmock_p5)), \
+ p6(::std::move(gmock_p6))
+#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7) \
+ : p0(::std::move(gmock_p0)), \
+ p1(::std::move(gmock_p1)), \
+ p2(::std::move(gmock_p2)), \
+ p3(::std::move(gmock_p3)), \
+ p4(::std::move(gmock_p4)), \
+ p5(::std::move(gmock_p5)), \
+ p6(::std::move(gmock_p6)), \
p7(::std::move(gmock_p7))
-#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8)\
- (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
- p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
- p6##_type gmock_p6, p7##_type gmock_p7, \
- p8##_type gmock_p8) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
- p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
- p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
- p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8))
+#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \
+ p8) \
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8) \
+ : p0(::std::move(gmock_p0)), \
+ p1(::std::move(gmock_p1)), \
+ p2(::std::move(gmock_p2)), \
+ p3(::std::move(gmock_p3)), \
+ p4(::std::move(gmock_p4)), \
+ p5(::std::move(gmock_p5)), \
+ p6(::std::move(gmock_p6)), \
+ p7(::std::move(gmock_p7)), \
+ p8(::std::move(gmock_p8))
#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8, p9)\
- (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
- p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
- p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
- p9##_type gmock_p9) : p0(::std::move(gmock_p0)), \
- p1(::std::move(gmock_p1)), p2(::std::move(gmock_p2)), \
- p3(::std::move(gmock_p3)), p4(::std::move(gmock_p4)), \
- p5(::std::move(gmock_p5)), p6(::std::move(gmock_p6)), \
- p7(::std::move(gmock_p7)), p8(::std::move(gmock_p8)), \
+ p7, p8, p9) \
+ (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \
+ p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \
+ p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \
+ p9##_type gmock_p9) \
+ : p0(::std::move(gmock_p0)), \
+ p1(::std::move(gmock_p1)), \
+ p2(::std::move(gmock_p2)), \
+ p3(::std::move(gmock_p3)), \
+ p4(::std::move(gmock_p4)), \
+ p5(::std::move(gmock_p5)), \
+ p6(::std::move(gmock_p6)), \
+ p7(::std::move(gmock_p7)), \
+ p8(::std::move(gmock_p8)), \
p9(::std::move(gmock_p9))
// Defines the copy constructor
#define GMOCK_INTERNAL_DEFN_COPY_AND_0_VALUE_PARAMS() \
- {} // Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82134
+ {} // Avoid https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82134
#define GMOCK_INTERNAL_DEFN_COPY_AND_1_VALUE_PARAMS(...) = default;
#define GMOCK_INTERNAL_DEFN_COPY_AND_2_VALUE_PARAMS(...) = default;
#define GMOCK_INTERNAL_DEFN_COPY_AND_3_VALUE_PARAMS(...) = default;
@@ -307,30 +344,71 @@
// Declares the fields for storing the value parameters.
#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;
-#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \
- p1##_type p1;
-#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \
- p1##_type p1; p2##_type p2;
-#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \
- p1##_type p1; p2##_type p2; p3##_type p3;
-#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
- p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;
-#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
- p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
- p5##_type p5;
-#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
- p5##_type p5; p6##_type p6;
-#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \
- p5##_type p5; p6##_type p6; p7##_type p7;
-#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
- p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;
+#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) \
+ p0##_type p0; \
+ p1##_type p1;
+#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) \
+ p0##_type p0; \
+ p1##_type p1; \
+ p2##_type p2;
+#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
+ p0##_type p0; \
+ p1##_type p1; \
+ p2##_type p2; \
+ p3##_type p3;
+#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
+ p0##_type p0; \
+ p1##_type p1; \
+ p2##_type p2; \
+ p3##_type p3; \
+ p4##_type p4;
+#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
+ p0##_type p0; \
+ p1##_type p1; \
+ p2##_type p2; \
+ p3##_type p3; \
+ p4##_type p4; \
+ p5##_type p5;
+#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \
+ p0##_type p0; \
+ p1##_type p1; \
+ p2##_type p2; \
+ p3##_type p3; \
+ p4##_type p4; \
+ p5##_type p5; \
+ p6##_type p6;
+#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \
+ p0##_type p0; \
+ p1##_type p1; \
+ p2##_type p2; \
+ p3##_type p3; \
+ p4##_type p4; \
+ p5##_type p5; \
+ p6##_type p6; \
+ p7##_type p7;
+#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \
+ p8) \
+ p0##_type p0; \
+ p1##_type p1; \
+ p2##_type p2; \
+ p3##_type p3; \
+ p4##_type p4; \
+ p5##_type p5; \
+ p6##_type p6; \
+ p7##_type p7; \
+ p8##_type p8;
#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \
- p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \
- p9##_type p9;
+ p7, p8, p9) \
+ p0##_type p0; \
+ p1##_type p1; \
+ p2##_type p2; \
+ p3##_type p3; \
+ p4##_type p4; \
+ p5##_type p5; \
+ p6##_type p6; \
+ p7##_type p7; \
+ p8##_type p8; \
+ p9##_type p9;
// Lists the value parameters.
#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()
@@ -338,72 +416,78 @@
#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1
#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2
#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3
-#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \
- p2, p3, p4
-#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \
- p1, p2, p3, p4, p5
-#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6) p0, p1, p2, p3, p4, p5, p6
-#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7) p0, p1, p2, p3, p4, p5, p6, p7
-#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8
+#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
+ p0, p1, p2, p3, p4
+#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
+ p0, p1, p2, p3, p4, p5
+#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \
+ p0, p1, p2, p3, p4, p5, p6
+#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \
+ p0, p1, p2, p3, p4, p5, p6, p7
+#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \
+ p8) \
+ p0, p1, p2, p3, p4, p5, p6, p7, p8
#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
+ p7, p8, p9) \
+ p0, p1, p2, p3, p4, p5, p6, p7, p8, p9
// Lists the value parameter types.
#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \
- p1##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \
- p1##_type, p2##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \
- p0##_type, p1##_type, p2##_type, p3##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \
- p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
-#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \
- p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) \
+ , p0##_type, p1##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) \
+ , p0##_type, p1##_type, p2##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
+ , p0##_type, p1##_type, p2##_type, p3##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
+ , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type
+#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
+ , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
- p6##_type
+ p6) \
+ , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, p6##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
- p5##_type, p6##_type, p7##_type
+ p6, p7) \
+ , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
+ p6##_type, p7##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
- p5##_type, p6##_type, p7##_type, p8##_type
+ p6, p7, p8) \
+ , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
+ p6##_type, p7##_type, p8##_type
#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \
- p5##_type, p6##_type, p7##_type, p8##_type, p9##_type
+ p6, p7, p8, p9) \
+ , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \
+ p6##_type, p7##_type, p8##_type, p9##_type
// Declares the value parameters.
#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()
#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0
-#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \
- p1##_type p1
-#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \
- p1##_type p1, p2##_type p2
-#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \
- p1##_type p1, p2##_type p2, p3##_type p3
-#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \
- p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
-#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \
- p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
- p5##_type p5
-#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \
- p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
- p5##_type p5, p6##_type p6
-#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
- p5##_type p5, p6##_type p6, p7##_type p7
-#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
- p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
+#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) \
+ p0##_type p0, p1##_type p1
+#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) \
+ p0##_type p0, p1##_type p1, p2##_type p2
+#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) \
+ p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3
+#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) \
+ p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4
+#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) \
+ p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
+ p5##_type p5
+#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) \
+ p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
+ p5##_type p5, p6##_type p6
+#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7) \
+ p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
+ p5##_type p5, p6##_type p6, p7##_type p7
+#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, \
+ p8) \
+ p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
+ p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8
#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \
- p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \
- p9##_type p9
+ p7, p8, p9) \
+ p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \
+ p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, p9##_type p9
// The suffix of the class template implementing the action template.
#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()
@@ -415,40 +499,43 @@
#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6
#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7
#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7) P8
+ p7) \
+ P8
#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8) P9
+ p7, p8) \
+ P9
#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \
- p7, p8, p9) P10
+ p7, p8, p9) \
+ P10
// The name of the class template implementing the action template.
-#define GMOCK_ACTION_CLASS_(name, value_params)\
- GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
+#define GMOCK_ACTION_CLASS_(name, value_params) \
+ GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)
#define ACTION_TEMPLATE(name, template_params, value_params) \
template <GMOCK_INTERNAL_DECL_##template_params \
- GMOCK_INTERNAL_DECL_TYPE_##value_params> \
+ GMOCK_INTERNAL_DECL_TYPE_##value_params> \
class GMOCK_ACTION_CLASS_(name, value_params) { \
public: \
explicit GMOCK_ACTION_CLASS_(name, value_params)( \
GMOCK_INTERNAL_DECL_##value_params) \
GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
- = default; , \
+ = default; \
+ , \
: impl_(std::make_shared<gmock_Impl>( \
- GMOCK_INTERNAL_LIST_##value_params)) { }) \
- GMOCK_ACTION_CLASS_(name, value_params)( \
- const GMOCK_ACTION_CLASS_(name, value_params)&) noexcept \
- GMOCK_INTERNAL_DEFN_COPY_##value_params \
- GMOCK_ACTION_CLASS_(name, value_params)( \
- GMOCK_ACTION_CLASS_(name, value_params)&&) noexcept \
- GMOCK_INTERNAL_DEFN_COPY_##value_params \
- template <typename F> \
- operator ::testing::Action<F>() const { \
+ GMOCK_INTERNAL_LIST_##value_params)){}) \
+ GMOCK_ACTION_CLASS_(name, value_params)(const GMOCK_ACTION_CLASS_( \
+ name, value_params) &) noexcept GMOCK_INTERNAL_DEFN_COPY_ \
+ ##value_params GMOCK_ACTION_CLASS_(name, value_params)( \
+ GMOCK_ACTION_CLASS_(name, value_params) &&) noexcept \
+ GMOCK_INTERNAL_DEFN_COPY_##value_params template <typename F> \
+ operator ::testing::Action<F>() const { \
return GMOCK_PP_IF( \
GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
- (::testing::internal::MakeAction<F, gmock_Impl>()), \
- (::testing::internal::MakeAction<F>(impl_))); \
+ (::testing::internal::MakeAction<F, gmock_Impl>()), \
+ (::testing::internal::MakeAction<F>(impl_))); \
} \
+ \
private: \
class gmock_Impl { \
public: \
@@ -458,34 +545,35 @@
return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \
GMOCK_INTERNAL_DEFN_##value_params \
}; \
- GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \
- , std::shared_ptr<const gmock_Impl> impl_;) \
+ GMOCK_PP_IF(GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), , \
+ std::shared_ptr<const gmock_Impl> impl_;) \
}; \
template <GMOCK_INTERNAL_DECL_##template_params \
- GMOCK_INTERNAL_DECL_TYPE_##value_params> \
- GMOCK_ACTION_CLASS_(name, value_params)< \
- GMOCK_INTERNAL_LIST_##template_params \
- GMOCK_INTERNAL_LIST_TYPE_##value_params> name( \
- GMOCK_INTERNAL_DECL_##value_params) GTEST_MUST_USE_RESULT_; \
+ GMOCK_INTERNAL_DECL_TYPE_##value_params> \
+ GMOCK_ACTION_CLASS_( \
+ name, value_params)<GMOCK_INTERNAL_LIST_##template_params \
+ GMOCK_INTERNAL_LIST_TYPE_##value_params> \
+ name(GMOCK_INTERNAL_DECL_##value_params) GTEST_MUST_USE_RESULT_; \
template <GMOCK_INTERNAL_DECL_##template_params \
- GMOCK_INTERNAL_DECL_TYPE_##value_params> \
- inline GMOCK_ACTION_CLASS_(name, value_params)< \
- GMOCK_INTERNAL_LIST_##template_params \
- GMOCK_INTERNAL_LIST_TYPE_##value_params> name( \
- GMOCK_INTERNAL_DECL_##value_params) { \
- return GMOCK_ACTION_CLASS_(name, value_params)< \
- GMOCK_INTERNAL_LIST_##template_params \
- GMOCK_INTERNAL_LIST_TYPE_##value_params>( \
- GMOCK_INTERNAL_LIST_##value_params); \
+ GMOCK_INTERNAL_DECL_TYPE_##value_params> \
+ inline GMOCK_ACTION_CLASS_( \
+ name, value_params)<GMOCK_INTERNAL_LIST_##template_params \
+ GMOCK_INTERNAL_LIST_TYPE_##value_params> \
+ name(GMOCK_INTERNAL_DECL_##value_params) { \
+ return GMOCK_ACTION_CLASS_( \
+ name, value_params)<GMOCK_INTERNAL_LIST_##template_params \
+ GMOCK_INTERNAL_LIST_TYPE_##value_params>( \
+ GMOCK_INTERNAL_LIST_##value_params); \
} \
template <GMOCK_INTERNAL_DECL_##template_params \
- GMOCK_INTERNAL_DECL_TYPE_##value_params> \
+ GMOCK_INTERNAL_DECL_TYPE_##value_params> \
template <typename function_type, typename return_type, typename args_type, \
GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
- return_type GMOCK_ACTION_CLASS_(name, value_params)< \
- GMOCK_INTERNAL_LIST_##template_params \
- GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl::gmock_PerformImpl( \
- GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
+ return_type GMOCK_ACTION_CLASS_( \
+ name, value_params)<GMOCK_INTERNAL_LIST_##template_params \
+ GMOCK_INTERNAL_LIST_TYPE_##value_params>:: \
+ gmock_Impl::gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) \
+ const
namespace testing {
@@ -495,8 +583,8 @@ namespace testing {
// is expanded and macro expansion cannot contain #pragma. Therefore
// we suppress them here.
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
+#pragma warning(push)
+#pragma warning(disable : 4100)
#endif
namespace internal {
@@ -565,7 +653,7 @@ InvokeArgument(Params&&... params) {
}
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
} // namespace testing
diff --git a/googlemock/include/gmock/gmock-more-matchers.h b/googlemock/include/gmock/gmock-more-matchers.h
index 6442d2f..47aaf98 100644
--- a/googlemock/include/gmock/gmock-more-matchers.h
+++ b/googlemock/include/gmock/gmock-more-matchers.h
@@ -47,13 +47,13 @@ namespace testing {
// Silence C4100 (unreferenced formal
// parameter) for MSVC
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
+#pragma warning(push)
+#pragma warning(disable : 4100)
#if (_MSC_VER == 1900)
// and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 14
-# pragma warning(disable:4800)
- #endif
+#pragma warning(disable : 4800)
+#endif
#endif
// Defines a matcher that matches an empty container. The container must
@@ -83,10 +83,9 @@ MATCHER(IsFalse, negation ? "is true" : "is false") {
}
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
-
} // namespace testing
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h
index dfe642d..8e4c5c6 100644
--- a/googlemock/include/gmock/gmock-spec-builders.h
+++ b/googlemock/include/gmock/gmock-spec-builders.h
@@ -70,6 +70,7 @@
#include <type_traits>
#include <utility>
#include <vector>
+
#include "gmock/gmock-actions.h"
#include "gmock/gmock-cardinalities.h"
#include "gmock/gmock-matchers.h"
@@ -78,7 +79,7 @@
#include "gtest/gtest.h"
#if GTEST_HAS_EXCEPTIONS
-# include <stdexcept> // NOLINT
+#include <stdexcept> // NOLINT
#endif
GTEST_DISABLE_MSC_WARNINGS_PUSH_(4251 \
@@ -97,13 +98,15 @@ class ExpectationSet;
namespace internal {
// Implements a mock function.
-template <typename F> class FunctionMocker;
+template <typename F>
+class FunctionMocker;
// Base class for expectations.
class ExpectationBase;
// Implements an expectation.
-template <typename F> class TypedExpectation;
+template <typename F>
+class TypedExpectation;
// Helper class for testing the Expectation class template.
class ExpectationTester;
@@ -171,10 +174,9 @@ class GTEST_API_ UntypedFunctionMockerBase {
// Writes a message that the call is uninteresting (i.e. neither
// explicitly expected nor explicitly unexpected) to the given
// ostream.
- virtual void UntypedDescribeUninterestingCall(
- const void* untyped_args,
- ::std::ostream* os) const
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
+ virtual void UntypedDescribeUninterestingCall(const void* untyped_args,
+ ::std::ostream* os) const
+ GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
// Returns the expectation that matches the given function arguments
// (or NULL is there's no match); when a match is found,
@@ -183,10 +185,9 @@ class GTEST_API_ UntypedFunctionMockerBase {
// is_excessive is modified to indicate whether the call exceeds the
// expected number.
virtual const ExpectationBase* UntypedFindMatchingExpectation(
- const void* untyped_args,
- const void** untyped_action, bool* is_excessive,
+ const void* untyped_args, const void** untyped_action, bool* is_excessive,
::std::ostream* what, ::std::ostream* why)
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
+ GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;
// Prints the given function arguments to the ostream.
virtual void UntypedPrintArgs(const void* untyped_args,
@@ -196,8 +197,7 @@ class GTEST_API_ UntypedFunctionMockerBase {
// this information in the global mock registry. Will be called
// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock
// method.
- void RegisterOwner(const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
+ void RegisterOwner(const void* mock_obj) GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
// Sets the mock object this mock method belongs to, and sets the
// name of the mock function. Will be called upon each invocation
@@ -208,13 +208,11 @@ class GTEST_API_ UntypedFunctionMockerBase {
// Returns the mock object this mock method belongs to. Must be
// called after RegisterOwner() or SetOwnerAndName() has been
// called.
- const void* MockObject() const
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
+ const void* MockObject() const GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
// Returns the name of this mock method. Must be called after
// SetOwnerAndName() has been called.
- const char* Name() const
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
+ const char* Name() const GTEST_LOCK_EXCLUDED_(g_gmock_mutex);
// Returns the result of invoking this mock function with the given
// arguments. This function can be safely called from multiple
@@ -451,8 +449,7 @@ class GTEST_API_ Mock {
// Returns the reaction Google Mock will have on uninteresting calls
// made on the given mock object.
static internal::CallReaction GetReactionOnUninterestingCalls(
- const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
+ const void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
// Verifies that all expectations on the given mock object have been
// satisfied. Reports one or more Google Test non-fatal failures
@@ -465,17 +462,16 @@ class GTEST_API_ Mock {
GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);
// Registers a mock object and a mock method it owns.
- static void Register(
- const void* mock_obj,
- internal::UntypedFunctionMockerBase* mocker)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
+ static void Register(const void* mock_obj,
+ internal::UntypedFunctionMockerBase* mocker)
+ GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
// Tells Google Mock where in the source code mock_obj is used in an
// ON_CALL or EXPECT_CALL. In case mock_obj is leaked, this
// information helps the user identify which object it is.
- static void RegisterUseByOnCallOrExpectCall(
- const void* mock_obj, const char* file, int line)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
+ static void RegisterUseByOnCallOrExpectCall(const void* mock_obj,
+ const char* file, int line)
+ GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);
// Unregisters a mock method; removes the owning mock object from
// the registry when the last mock method associated with it has
@@ -632,7 +628,6 @@ class ExpectationSet {
Expectation::Set expectations_;
};
-
// Sequence objects are used by a user to specify the relative order
// in which the expectations should match. They are copyable (we rely
// on the compiler-defined copy constructor and assignment operator).
@@ -678,6 +673,7 @@ class GTEST_API_ InSequence {
public:
InSequence();
~InSequence();
+
private:
bool sequence_created_;
@@ -784,40 +780,34 @@ class GTEST_API_ ExpectationBase {
// the current thread.
// Retires all pre-requisites of this expectation.
- void RetireAllPreRequisites()
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
+ void RetireAllPreRequisites() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
// Returns true if and only if this expectation is retired.
- bool is_retired() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ bool is_retired() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return retired_;
}
// Retires this expectation.
- void Retire()
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ void Retire() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
retired_ = true;
}
// Returns true if and only if this expectation is satisfied.
- bool IsSatisfied() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ bool IsSatisfied() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return cardinality().IsSatisfiedByCallCount(call_count_);
}
// Returns true if and only if this expectation is saturated.
- bool IsSaturated() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ bool IsSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return cardinality().IsSaturatedByCallCount(call_count_);
}
// Returns true if and only if this expectation is over-saturated.
- bool IsOverSaturated() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ bool IsOverSaturated() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return cardinality().IsOverSaturatedByCallCount(call_count_);
}
@@ -832,15 +822,13 @@ class GTEST_API_ ExpectationBase {
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);
// Returns the number this expectation has been invoked.
- int call_count() const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ int call_count() const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
return call_count_;
}
// Increments the number this expectation has been invoked.
- void IncrementCallCount()
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ void IncrementCallCount() GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
call_count_++;
}
@@ -849,8 +837,7 @@ class GTEST_API_ ExpectationBase {
// WillRepeatedly() clauses) against the cardinality if this hasn't
// been done before. Prints a warning if there are too many or too
// few actions.
- void CheckActionCountIfNotDone() const
- GTEST_LOCK_EXCLUDED_(mutex_);
+ void CheckActionCountIfNotDone() const GTEST_LOCK_EXCLUDED_(mutex_);
friend class ::testing::Sequence;
friend class ::testing::internal::ExpectationTester;
@@ -863,12 +850,12 @@ class GTEST_API_ ExpectationBase {
// This group of fields are part of the spec and won't change after
// an EXPECT_CALL() statement finishes.
- const char* file_; // The file that contains the expectation.
- int line_; // The line number of the expectation.
+ const char* file_; // The file that contains the expectation.
+ int line_; // The line number of the expectation.
const std::string source_text_; // The EXPECT_CALL(...) source text.
// True if and only if the cardinality is specified explicitly.
bool cardinality_specified_;
- Cardinality cardinality_; // The cardinality of the expectation.
+ Cardinality cardinality_; // The cardinality of the expectation.
// The immediate pre-requisites (i.e. expectations that must be
// satisfied before this expectation can be matched) of this
// expectation. We use std::shared_ptr in the set because we want an
@@ -887,8 +874,8 @@ class GTEST_API_ ExpectationBase {
bool retires_on_saturation_;
Clause last_clause_;
mutable bool action_count_checked_; // Under mutex_.
- mutable Mutex mutex_; // Protects action_count_checked_.
-}; // class ExpectationBase
+ mutable Mutex mutex_; // Protects action_count_checked_.
+}; // class ExpectationBase
// Implements an expectation for the given function type.
template <typename F>
@@ -945,9 +932,7 @@ class TypedExpectation : public ExpectationBase {
}
// Implements the .Times() clause.
- TypedExpectation& Times(int n) {
- return Times(Exactly(n));
- }
+ TypedExpectation& Times(int n) { return Times(Exactly(n)); }
// Implements the .InSequence() clause.
TypedExpectation& InSequence(const Sequence& s) {
@@ -1062,9 +1047,7 @@ class TypedExpectation : public ExpectationBase {
// Returns the matchers for the arguments as specified inside the
// EXPECT_CALL() macro.
- const ArgumentMatcherTuple& matchers() const {
- return matchers_;
- }
+ const ArgumentMatcherTuple& matchers() const { return matchers_; }
// Returns the matcher specified by the .With() clause.
const Matcher<const ArgumentTuple&>& extra_matcher() const {
@@ -1119,10 +1102,8 @@ class TypedExpectation : public ExpectationBase {
// Describes the result of matching the arguments against this
// expectation to the given ostream.
- void ExplainMatchResultTo(
- const ArgumentTuple& args,
- ::std::ostream* os) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ void ExplainMatchResultTo(const ArgumentTuple& args, ::std::ostream* os) const
+ GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
if (is_retired()) {
@@ -1181,9 +1162,9 @@ class TypedExpectation : public ExpectationBase {
::std::stringstream ss;
DescribeLocationTo(&ss);
ss << "Actions ran out in " << source_text() << "...\n"
- << "Called " << count << " times, but only "
- << action_count << " WillOnce()"
- << (action_count == 1 ? " is" : "s are") << " specified - ";
+ << "Called " << count << " times, but only " << action_count
+ << " WillOnce()" << (action_count == 1 ? " is" : "s are")
+ << " specified - ";
mocker->DescribeDefaultActionTo(args, &ss);
Log(kWarning, ss.str(), 1);
}
@@ -1225,7 +1206,7 @@ class TypedExpectation : public ExpectationBase {
}
// Must be done after IncrementCount()!
- *what << "Mock function call matches " << source_text() <<"...\n";
+ *what << "Mock function call matches " << source_text() << "...\n";
return &(GetCurrentAction(mocker, args));
}
@@ -1258,8 +1239,8 @@ template <typename F>
class MockSpec {
public:
typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;
- typedef typename internal::Function<F>::ArgumentMatcherTuple
- ArgumentMatcherTuple;
+ typedef
+ typename internal::Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;
// Constructs a MockSpec object, given the function mocker object
// that the spec is associated with.
@@ -1269,8 +1250,9 @@ class MockSpec {
// Adds a new default action spec to the function mocker and returns
// the newly created spec.
- internal::OnCallSpec<F>& InternalDefaultActionSetAt(
- const char* file, int line, const char* obj, const char* call) {
+ internal::OnCallSpec<F>& InternalDefaultActionSetAt(const char* file,
+ int line, const char* obj,
+ const char* call) {
LogWithLocation(internal::kInfo, file, line,
std::string("ON_CALL(") + obj + ", " + call + ") invoked");
return function_mocker_->AddNewOnCallSpec(file, line, matchers_);
@@ -1278,13 +1260,14 @@ class MockSpec {
// Adds a new expectation spec to the function mocker and returns
// the newly created spec.
- internal::TypedExpectation<F>& InternalExpectedAt(
- const char* file, int line, const char* obj, const char* call) {
+ internal::TypedExpectation<F>& InternalExpectedAt(const char* file, int line,
+ const char* obj,
+ const char* call) {
const std::string source_text(std::string("EXPECT_CALL(") + obj + ", " +
call + ")");
LogWithLocation(internal::kInfo, file, line, source_text + " invoked");
- return function_mocker_->AddNewExpectation(
- file, line, source_text, matchers_);
+ return function_mocker_->AddNewExpectation(file, line, source_text,
+ matchers_);
}
// This operator overload is used to swallow the superfluous parameter list
@@ -1317,9 +1300,7 @@ template <typename T>
class ReferenceOrValueWrapper {
public:
// Constructs a wrapper from the given value/reference.
- explicit ReferenceOrValueWrapper(T value)
- : value_(std::move(value)) {
- }
+ explicit ReferenceOrValueWrapper(T value) : value_(std::move(value)) {}
// Unwraps and returns the underlying value/reference, exactly as
// originally passed. The behavior of calling this more than once on
@@ -1330,9 +1311,7 @@ class ReferenceOrValueWrapper {
// Always returns a const reference (more precisely,
// const std::add_lvalue_reference<T>::type). The behavior of calling this
// after calling Unwrap on the same object is unspecified.
- const T& Peek() const {
- return value_;
- }
+ const T& Peek() const { return value_; }
private:
T value_;
@@ -1346,8 +1325,7 @@ class ReferenceOrValueWrapper<T&> {
// Workaround for debatable pass-by-reference lint warning (c-library-team
// policy precludes NOLINT in this context)
typedef T& reference;
- explicit ReferenceOrValueWrapper(reference ref)
- : value_ptr_(&ref) {}
+ explicit ReferenceOrValueWrapper(reference ref) : value_ptr_(&ref) {}
T& Unwrap() { return *value_ptr_; }
const T& Peek() const { return *value_ptr_; }
@@ -1377,9 +1355,7 @@ template <typename T>
class ActionResultHolder : public UntypedActionResultHolderBase {
public:
// Returns the held value. Must not be called more than once.
- T Unwrap() {
- return result_.Unwrap();
- }
+ T Unwrap() { return result_.Unwrap(); }
// Prints the held value as an action's result to os.
void PrintAsActionResult(::std::ostream* os) const override {
@@ -1395,8 +1371,8 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
const FunctionMocker<F>* func_mocker,
typename Function<F>::ArgumentTuple&& args,
const std::string& call_description) {
- return new ActionResultHolder(Wrapper(func_mocker->PerformDefaultAction(
- std::move(args), call_description)));
+ return new ActionResultHolder(Wrapper(
+ func_mocker->PerformDefaultAction(std::move(args), call_description)));
}
// Performs the given action and returns the result in a new-ed
@@ -1404,16 +1380,13 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
template <typename F>
static ActionResultHolder* PerformAction(
const Action<F>& action, typename Function<F>::ArgumentTuple&& args) {
- return new ActionResultHolder(
- Wrapper(action.Perform(std::move(args))));
+ return new ActionResultHolder(Wrapper(action.Perform(std::move(args))));
}
private:
typedef ReferenceOrValueWrapper<T> Wrapper;
- explicit ActionResultHolder(Wrapper result)
- : result_(std::move(result)) {
- }
+ explicit ActionResultHolder(Wrapper result) : result_(std::move(result)) {}
Wrapper result_;
@@ -1424,7 +1397,7 @@ class ActionResultHolder : public UntypedActionResultHolderBase {
template <>
class ActionResultHolder<void> : public UntypedActionResultHolderBase {
public:
- void Unwrap() { }
+ void Unwrap() {}
void PrintAsActionResult(::std::ostream* /* os */) const override {}
@@ -1495,14 +1468,12 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
// Returns the ON_CALL spec that matches this mock function with the
// given arguments; returns NULL if no matching ON_CALL is found.
// L = *
- const OnCallSpec<F>* FindOnCallSpec(
- const ArgumentTuple& args) const {
- for (UntypedOnCallSpecs::const_reverse_iterator it
- = untyped_on_call_specs_.rbegin();
+ const OnCallSpec<F>* FindOnCallSpec(const ArgumentTuple& args) const {
+ for (UntypedOnCallSpecs::const_reverse_iterator it =
+ untyped_on_call_specs_.rbegin();
it != untyped_on_call_specs_.rend(); ++it) {
const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);
- if (spec->Matches(args))
- return spec;
+ if (spec->Matches(args)) return spec;
}
return nullptr;
@@ -1517,8 +1488,7 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
// L = *
Result PerformDefaultAction(ArgumentTuple&& args,
const std::string& call_description) const {
- const OnCallSpec<F>* const spec =
- this->FindOnCallSpec(args);
+ const OnCallSpec<F>* const spec = this->FindOnCallSpec(args);
if (spec != nullptr) {
return spec->GetAction().Perform(std::move(args));
}
@@ -1579,8 +1549,7 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
untyped_on_call_specs_.swap(specs_to_delete);
g_gmock_mutex.Unlock();
- for (UntypedOnCallSpecs::const_iterator it =
- specs_to_delete.begin();
+ for (UntypedOnCallSpecs::const_iterator it = specs_to_delete.begin();
it != specs_to_delete.end(); ++it) {
delete static_cast<const OnCallSpec<F>*>(*it);
}
@@ -1611,10 +1580,9 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
typedef ActionResultHolder<Result> ResultHolder;
// Adds and returns a default action spec for this mock function.
- OnCallSpec<F>& AddNewOnCallSpec(
- const char* file, int line,
- const ArgumentMatcherTuple& m)
- GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
+ OnCallSpec<F>& AddNewOnCallSpec(const char* file, int line,
+ const ArgumentMatcherTuple& m)
+ GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {
Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);
OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);
untyped_on_call_specs_.push_back(on_call_spec);
@@ -1644,7 +1612,8 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
}
private:
- template <typename Func> friend class TypedExpectation;
+ template <typename Func>
+ friend class TypedExpectation;
// Some utilities needed for implementing UntypedInvokeWith().
@@ -1728,9 +1697,8 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
// Returns the expectation that matches the arguments, or NULL if no
// expectation matches them.
- TypedExpectation<F>* FindMatchingExpectationLocked(
- const ArgumentTuple& args) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ TypedExpectation<F>* FindMatchingExpectationLocked(const ArgumentTuple& args)
+ const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
// See the definition of untyped_expectations_ for why access to
// it is unprotected here.
@@ -1747,11 +1715,10 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
}
// Returns a message that the arguments don't match any expectation.
- void FormatUnexpectedCallMessageLocked(
- const ArgumentTuple& args,
- ::std::ostream* os,
- ::std::ostream* why) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ void FormatUnexpectedCallMessageLocked(const ArgumentTuple& args,
+ ::std::ostream* os,
+ ::std::ostream* why) const
+ GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
*os << "\nUnexpected mock function call - ";
DescribeDefaultActionTo(args, os);
@@ -1760,15 +1727,14 @@ class FunctionMocker<R(Args...)> final : public UntypedFunctionMockerBase {
// Prints a list of expectations that have been tried against the
// current mock function call.
- void PrintTriedExpectationsLocked(
- const ArgumentTuple& args,
- ::std::ostream* why) const
- GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
+ void PrintTriedExpectationsLocked(const ArgumentTuple& args,
+ ::std::ostream* why) const
+ GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
const size_t count = untyped_expectations_.size();
*why << "Google Mock tried the following " << count << " "
- << (count == 1 ? "expectation, but it didn't match" :
- "expectations, but none matched")
+ << (count == 1 ? "expectation, but it didn't match"
+ : "expectations, but none matched")
<< ":\n";
for (size_t i = 0; i < count; i++) {
TypedExpectation<F>* const expectation =
@@ -1952,7 +1918,9 @@ using internal::MockSpec;
// // Expects a call to const MockFoo::Bar().
// EXPECT_CALL(Const(foo), Bar());
template <typename T>
-inline const T& Const(const T& x) { return x; }
+inline const T& Const(const T& x) {
+ return x;
+}
// Constructs an Expectation object that references and co-owns exp.
inline Expectation::Expectation(internal::ExpectationBase& exp) // NOLINT
diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h
index d9d812a..22fff5c 100644
--- a/googlemock/include/gmock/internal/gmock-internal-utils.h
+++ b/googlemock/include/gmock/internal/gmock-internal-utils.h
@@ -59,9 +59,9 @@ namespace internal {
// Silence MSVC C4100 (unreferenced formal parameter) and
// C4805('==': unsafe mix of type 'const int' and type 'const bool')
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
-# pragma warning(disable:4805)
+#pragma warning(push)
+#pragma warning(disable : 4100)
+#pragma warning(disable : 4805)
#endif
// Joins a vector of strings as if they are fields of a tuple; returns
@@ -91,7 +91,9 @@ inline const Element* GetRawPointer(const std::reference_wrapper<Element>& r) {
// This overloaded version is for the raw pointer case.
template <typename Element>
-inline Element* GetRawPointer(Element* p) { return p; }
+inline Element* GetRawPointer(Element* p) {
+ return p;
+}
// MSVC treats wchar_t as a native type usually, but treats it as the
// same as unsigned short when the compiler option /Zc:wchar_t- is
@@ -100,7 +102,7 @@ inline Element* GetRawPointer(Element* p) { return p; }
#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
// wchar_t is a typedef.
#else
-# define GMOCK_WCHAR_T_IS_NATIVE_ 1
+#define GMOCK_WCHAR_T_IS_NATIVE_ 1
#endif
// In what follows, we use the term "kind" to indicate whether a type
@@ -108,18 +110,20 @@ inline Element* GetRawPointer(Element* p) { return p; }
// or none of them. This categorization is useful for determining
// when a matcher argument type can be safely converted to another
// type in the implementation of SafeMatcherCast.
-enum TypeKind {
- kBool, kInteger, kFloatingPoint, kOther
-};
+enum TypeKind { kBool, kInteger, kFloatingPoint, kOther };
// KindOf<T>::value is the kind of type T.
-template <typename T> struct KindOf {
+template <typename T>
+struct KindOf {
enum { value = kOther }; // The default kind.
};
// This macro declares that the kind of 'type' is 'kind'.
#define GMOCK_DECLARE_KIND_(type, kind) \
- template <> struct KindOf<type> { enum { value = kind }; }
+ template <> \
+ struct KindOf<type> { \
+ enum { value = kind }; \
+ }
GMOCK_DECLARE_KIND_(bool, kBool);
@@ -127,13 +131,13 @@ GMOCK_DECLARE_KIND_(bool, kBool);
GMOCK_DECLARE_KIND_(char, kInteger);
GMOCK_DECLARE_KIND_(signed char, kInteger);
GMOCK_DECLARE_KIND_(unsigned char, kInteger);
-GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT
+GMOCK_DECLARE_KIND_(short, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned short, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(int, kInteger);
GMOCK_DECLARE_KIND_(unsigned int, kInteger);
-GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
-GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
-GMOCK_DECLARE_KIND_(long long, kInteger); // NOLINT
+GMOCK_DECLARE_KIND_(long, kInteger); // NOLINT
+GMOCK_DECLARE_KIND_(unsigned long, kInteger); // NOLINT
+GMOCK_DECLARE_KIND_(long long, kInteger); // NOLINT
GMOCK_DECLARE_KIND_(unsigned long long, kInteger); // NOLINT
#if GMOCK_WCHAR_T_IS_NATIVE_
@@ -148,7 +152,7 @@ GMOCK_DECLARE_KIND_(long double, kFloatingPoint);
#undef GMOCK_DECLARE_KIND_
// Evaluates to the kind of 'type'.
-#define GMOCK_KIND_OF_(type) \
+#define GMOCK_KIND_OF_(type) \
static_cast< ::testing::internal::TypeKind>( \
::testing::internal::KindOf<type>::value)
@@ -204,9 +208,7 @@ using LosslessArithmeticConvertible =
class FailureReporterInterface {
public:
// The type of a failure (either non-fatal or fatal).
- enum FailureType {
- kNonfatal, kFatal
- };
+ enum FailureType { kNonfatal, kFatal };
virtual ~FailureReporterInterface() {}
@@ -226,8 +228,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter();
inline void Assert(bool condition, const char* file, int line,
const std::string& msg) {
if (!condition) {
- GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,
- file, line, msg);
+ GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal, file,
+ line, msg);
}
}
inline void Assert(bool condition, const char* file, int line) {
@@ -248,10 +250,7 @@ inline void Expect(bool condition, const char* file, int line) {
}
// Severity level of a log.
-enum LogSeverity {
- kInfo = 0,
- kWarning = 1
-};
+enum LogSeverity { kInfo = 0, kWarning = 1 };
// Valid values for the --gmock_verbose flag.
@@ -294,8 +293,8 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers();
// Disable MSVC warnings for infinite recursion, since in this case the
// recursion is unreachable.
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4717)
+#pragma warning(push)
+#pragma warning(disable : 4717)
#endif
// Invalid<T>() is usable as an expression of type T, but will terminate
@@ -313,7 +312,7 @@ inline T Invalid() {
}
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
// Given a raw type (i.e. having no top-level reference or const
@@ -392,7 +391,8 @@ class StlContainerView< ::std::tuple<ElementPointer, Size> > {
// The following specialization prevents the user from instantiating
// StlContainer with a reference type.
-template <typename T> class StlContainerView<T&>;
+template <typename T>
+class StlContainerView<T&>;
// A type transform to remove constness from the first part of a pair.
// Pairs like that are used as the value_type of associative containers,
@@ -413,17 +413,18 @@ struct RemoveConstFromKey<std::pair<const K, V> > {
GTEST_API_ void IllegalDoDefault(const char* file, int line);
template <typename F, typename Tuple, size_t... Idx>
-auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>) -> decltype(
- std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) {
+auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>)
+ -> decltype(std::forward<F>(f)(
+ std::get<Idx>(std::forward<Tuple>(args))...)) {
return std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...);
}
// Apply the function to a tuple of arguments.
template <typename F, typename Tuple>
-auto Apply(F&& f, Tuple&& args) -> decltype(
- ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
- MakeIndexSequence<std::tuple_size<
- typename std::remove_reference<Tuple>::type>::value>())) {
+auto Apply(F&& f, Tuple&& args) -> decltype(ApplyImpl(
+ std::forward<F>(f), std::forward<Tuple>(args),
+ MakeIndexSequence<std::tuple_size<
+ typename std::remove_reference<Tuple>::type>::value>())) {
return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
MakeIndexSequence<std::tuple_size<
typename std::remove_reference<Tuple>::type>::value>());
@@ -463,7 +464,7 @@ constexpr size_t Function<R(Args...)>::ArgumentCount;
bool Base64Unescape(const std::string& encoded, std::string* decoded);
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
} // namespace internal
diff --git a/googlemock/include/gmock/internal/gmock-port.h b/googlemock/include/gmock/internal/gmock-port.h
index 998f6c7..f3e63c1 100644
--- a/googlemock/include/gmock/internal/gmock-port.h
+++ b/googlemock/include/gmock/internal/gmock-port.h
@@ -42,6 +42,7 @@
#include <assert.h>
#include <stdlib.h>
+
#include <cstdint>
#include <iostream>
@@ -53,13 +54,13 @@
// here, as Google Mock depends on Google Test. Only add a utility
// here if it's truly specific to Google Mock.
-#include "gtest/internal/gtest-port.h"
#include "gmock/internal/custom/gmock-port.h"
+#include "gtest/internal/gtest-port.h"
// For MS Visual C++, check the compiler version. At least VS 2015 is
// required to compile Google Mock.
#if defined(_MSC_VER) && _MSC_VER < 1900
-# error "At least Visual C++ 2015 (14.0) is required to compile Google Mock."
+#error "At least Visual C++ 2015 (14.0) is required to compile Google Mock."
#endif
// Macro for referencing flags. This is public as we want the user to
@@ -72,29 +73,35 @@
#define GMOCK_DECLARE_bool_(name) \
namespace testing { \
GTEST_API_ extern bool GMOCK_FLAG(name); \
- } static_assert(true, "no-op to require trailing semicolon")
+ } \
+ static_assert(true, "no-op to require trailing semicolon")
#define GMOCK_DECLARE_int32_(name) \
namespace testing { \
GTEST_API_ extern int32_t GMOCK_FLAG(name); \
- } static_assert(true, "no-op to require trailing semicolon")
+ } \
+ static_assert(true, "no-op to require trailing semicolon")
#define GMOCK_DECLARE_string_(name) \
namespace testing { \
GTEST_API_ extern ::std::string GMOCK_FLAG(name); \
- } static_assert(true, "no-op to require trailing semicolon")
+ } \
+ static_assert(true, "no-op to require trailing semicolon")
// Macros for defining flags.
#define GMOCK_DEFINE_bool_(name, default_val, doc) \
namespace testing { \
GTEST_API_ bool GMOCK_FLAG(name) = (default_val); \
- } static_assert(true, "no-op to require trailing semicolon")
+ } \
+ static_assert(true, "no-op to require trailing semicolon")
#define GMOCK_DEFINE_int32_(name, default_val, doc) \
namespace testing { \
GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val); \
- } static_assert(true, "no-op to require trailing semicolon")
+ } \
+ static_assert(true, "no-op to require trailing semicolon")
#define GMOCK_DEFINE_string_(name, default_val, doc) \
namespace testing { \
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val); \
- } static_assert(true, "no-op to require trailing semicolon")
+ } \
+ static_assert(true, "no-op to require trailing semicolon")
#endif // !defined(GMOCK_DECLARE_bool_)
#if !defined(GMOCK_FLAG_GET)
diff --git a/googlemock/src/gmock-cardinalities.cc b/googlemock/src/gmock-cardinalities.cc
index 7463f43..1e7b898 100644
--- a/googlemock/src/gmock-cardinalities.cc
+++ b/googlemock/src/gmock-cardinalities.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file implements cardinalities.
@@ -35,9 +34,11 @@
#include "gmock/gmock-cardinalities.h"
#include <limits.h>
+
#include <ostream> // NOLINT
#include <sstream>
#include <string>
+
#include "gmock/internal/gmock-internal-utils.h"
#include "gtest/gtest.h"
@@ -49,8 +50,7 @@ namespace {
class BetweenCardinalityImpl : public CardinalityInterface {
public:
BetweenCardinalityImpl(int min, int max)
- : min_(min >= 0 ? min : 0),
- max_(max >= min_ ? max : min_) {
+ : min_(min >= 0 ? min : 0), max_(max >= min_ ? max : min_) {
std::stringstream ss;
if (min < 0) {
ss << "The invocation lower bound must be >= 0, "
@@ -62,8 +62,7 @@ class BetweenCardinalityImpl : public CardinalityInterface {
internal::Expect(false, __FILE__, __LINE__, ss.str());
} else if (min > max) {
ss << "The invocation upper bound (" << max
- << ") must be >= the invocation lower bound (" << min
- << ").";
+ << ") must be >= the invocation lower bound (" << min << ").";
internal::Expect(false, __FILE__, __LINE__, ss.str());
}
}
diff --git a/googlemock/src/gmock-internal-utils.cc b/googlemock/src/gmock-internal-utils.cc
index 6020736..bb0a698 100644
--- a/googlemock/src/gmock-internal-utils.cc
+++ b/googlemock/src/gmock-internal-utils.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file defines some utilities useful for implementing Google
@@ -84,12 +83,11 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {
// We don't care about the current locale as the input is
// guaranteed to be a valid C++ identifier name.
const bool starts_new_word = IsUpper(*p) ||
- (!IsAlpha(prev_char) && IsLower(*p)) ||
- (!IsDigit(prev_char) && IsDigit(*p));
+ (!IsAlpha(prev_char) && IsLower(*p)) ||
+ (!IsDigit(prev_char) && IsDigit(*p));
if (IsAlNum(*p)) {
- if (starts_new_word && result != "")
- result += ' ';
+ if (starts_new_word && result != "") result += ' ';
result += ToLower(*p);
}
}
@@ -103,12 +101,9 @@ class GoogleTestFailureReporter : public FailureReporterInterface {
public:
void ReportFailure(FailureType type, const char* file, int line,
const std::string& message) override {
- AssertHelper(type == kFatal ?
- TestPartResult::kFatalFailure :
- TestPartResult::kNonFatalFailure,
- file,
- line,
- message.c_str()) = Message();
+ AssertHelper(type == kFatal ? TestPartResult::kFatalFailure
+ : TestPartResult::kNonFatalFailure,
+ file, line, message.c_str()) = Message();
if (type == kFatal) {
posix::Abort();
}
@@ -156,8 +151,7 @@ GTEST_API_ bool LogIsVisible(LogSeverity severity) {
// conservative.
GTEST_API_ void Log(LogSeverity severity, const std::string& message,
int stack_frames_to_skip) {
- if (!LogIsVisible(severity))
- return;
+ if (!LogIsVisible(severity)) return;
// Ensures that logs from different threads don't interleave.
MutexLock l(&g_log_mutex);
@@ -186,8 +180,8 @@ GTEST_API_ void Log(LogSeverity severity, const std::string& message,
std::cout << "\n";
}
std::cout << "Stack trace:\n"
- << ::testing::internal::GetCurrentOsStackTraceExceptTop(
- ::testing::UnitTest::GetInstance(), actual_to_skip);
+ << ::testing::internal::GetCurrentOsStackTraceExceptTop(
+ ::testing::UnitTest::GetInstance(), actual_to_skip);
}
std::cout << ::std::flush;
}
diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc
index 873527b..a8d04a6 100644
--- a/googlemock/src/gmock-matchers.cc
+++ b/googlemock/src/gmock-matchers.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file implements Matcher<const string&>, Matcher<string>, and
diff --git a/googlemock/src/gmock-spec-builders.cc b/googlemock/src/gmock-spec-builders.cc
index 7b4a38b..b671921 100644
--- a/googlemock/src/gmock-spec-builders.cc
+++ b/googlemock/src/gmock-spec-builders.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file implements the spec builder syntax (ON_CALL and
@@ -49,15 +48,15 @@
#include "gtest/internal/gtest-port.h"
#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
-# include <unistd.h> // NOLINT
+#include <unistd.h> // NOLINT
#endif
// Silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 15
#ifdef _MSC_VER
#if _MSC_VER == 1900
-# pragma warning(push)
-# pragma warning(disable:4800)
+#pragma warning(push)
+#pragma warning(disable : 4800)
#endif
#endif
@@ -195,11 +194,12 @@ void ExpectationBase::DescribeCallCountTo(::std::ostream* os) const
// Describes the state of the expectation (e.g. is it satisfied?
// is it active?).
- *os << " - " << (IsOverSaturated() ? "over-saturated" :
- IsSaturated() ? "saturated" :
- IsSatisfied() ? "satisfied" : "unsatisfied")
- << " and "
- << (is_retired() ? "retired" : "active");
+ *os << " - "
+ << (IsOverSaturated() ? "over-saturated"
+ : IsSaturated() ? "saturated"
+ : IsSatisfied() ? "satisfied"
+ : "unsatisfied")
+ << " and " << (is_retired() ? "retired" : "active");
}
// Checks the action count (i.e. the number of WillOnce() and
@@ -242,13 +242,12 @@ void ExpectationBase::CheckActionCountIfNotDone() const
::std::stringstream ss;
DescribeLocationTo(&ss);
- ss << "Too " << (too_many ? "many" : "few")
- << " actions specified in " << source_text() << "...\n"
+ ss << "Too " << (too_many ? "many" : "few") << " actions specified in "
+ << source_text() << "...\n"
<< "Expected to be ";
cardinality().DescribeTo(&ss);
- ss << ", but has " << (too_many ? "" : "only ")
- << action_count << " WillOnce()"
- << (action_count == 1 ? "" : "s");
+ ss << ", but has " << (too_many ? "" : "only ") << action_count
+ << " WillOnce()" << (action_count == 1 ? "" : "s");
if (repeated_action_specified_) {
ss << " and a WillRepeatedly()";
}
@@ -398,11 +397,11 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
// If the user wants this to be a warning, we print
// it only when they want to see warnings.
reaction == kWarn
- ? LogIsVisible(kWarning)
- :
- // Otherwise, the user wants this to be an error, and we
- // should always print detailed information in the error.
- true;
+ ? LogIsVisible(kWarning)
+ :
+ // Otherwise, the user wants this to be an error, and we
+ // should always print detailed information in the error.
+ true;
if (!need_to_report_uninteresting_call) {
// Perform the action without printing the call information.
@@ -505,8 +504,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
Expectation UntypedFunctionMockerBase::GetHandleOf(ExpectationBase* exp) {
// See the definition of untyped_expectations_ for why access to it
// is unprotected here.
- for (UntypedExpectations::const_iterator it =
- untyped_expectations_.begin();
+ for (UntypedExpectations::const_iterator it = untyped_expectations_.begin();
it != untyped_expectations_.end(); ++it) {
if (it->get() == exp) {
return Expectation(*it);
@@ -526,8 +524,7 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld();
bool expectations_met = true;
- for (UntypedExpectations::const_iterator it =
- untyped_expectations_.begin();
+ for (UntypedExpectations::const_iterator it = untyped_expectations_.begin();
it != untyped_expectations_.end(); ++it) {
ExpectationBase* const untyped_expectation = it->get();
if (untyped_expectation->IsOverSaturated()) {
@@ -538,15 +535,15 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
} else if (!untyped_expectation->IsSatisfied()) {
expectations_met = false;
::std::stringstream ss;
- ss << "Actual function call count doesn't match "
- << untyped_expectation->source_text() << "...\n";
+ ss << "Actual function call count doesn't match "
+ << untyped_expectation->source_text() << "...\n";
// No need to show the source file location of the expectation
// in the description, as the Expect() call that follows already
// takes care of it.
untyped_expectation->MaybeDescribeExtraMatcherTo(&ss);
untyped_expectation->DescribeCallCountTo(&ss);
- Expect(false, untyped_expectation->file(),
- untyped_expectation->line(), ss.str());
+ Expect(false, untyped_expectation->file(), untyped_expectation->line(),
+ ss.str());
}
}
@@ -633,7 +630,7 @@ class MockObjectRegistry {
<< state.first_used_test << ")";
}
std::cout << " should be deleted but never is. Its address is @"
- << it->first << ".";
+ << it->first << ".";
leaked_count++;
}
if (leaked_count > 0) {
@@ -712,8 +709,7 @@ void Mock::UnregisterCallReaction(const void* mock_obj)
// Returns the reaction Google Mock will have on uninteresting calls
// made on the given mock object.
internal::CallReaction Mock::GetReactionOnUninterestingCalls(
- const void* mock_obj)
- GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
+ const void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
internal::MutexLock l(&internal::g_gmock_mutex);
return (g_uninteresting_call_reaction.count(mock_obj) == 0)
? internal::intToCallReaction(
@@ -873,8 +869,8 @@ Expectation::~Expectation() {}
void Sequence::AddExpectation(const Expectation& expectation) const {
if (*last_expectation_ != expectation) {
if (last_expectation_->expectation_base() != nullptr) {
- expectation.expectation_base()->immediate_prerequisites_
- += *last_expectation_;
+ expectation.expectation_base()->immediate_prerequisites_ +=
+ *last_expectation_;
}
*last_expectation_ = expectation;
}
@@ -903,6 +899,6 @@ InSequence::~InSequence() {
#ifdef _MSC_VER
#if _MSC_VER == 1900
-# pragma warning(pop)
+#pragma warning(pop)
#endif
#endif
diff --git a/googlemock/src/gmock.cc b/googlemock/src/gmock.cc
index a20aed8..5025656 100644
--- a/googlemock/src/gmock.cc
+++ b/googlemock/src/gmock.cc
@@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
#include "gmock/gmock.h"
+
#include "gmock/internal/gmock-port.h"
GMOCK_DEFINE_bool_(catch_leaked_mocks, true,
diff --git a/googlemock/src/gmock_main.cc b/googlemock/src/gmock_main.cc
index 18c500f..b411c5e 100644
--- a/googlemock/src/gmock_main.cc
+++ b/googlemock/src/gmock_main.cc
@@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
#include <iostream>
+
#include "gmock/gmock.h"
#include "gtest/gtest.h"
@@ -56,7 +56,7 @@ void loop() { RUN_ALL_TESTS(); }
// https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library
// // NOLINT
#if GTEST_OS_WINDOWS_MOBILE
-# include <tchar.h> // NOLINT
+#include <tchar.h> // NOLINT
GTEST_API_ int _tmain(int argc, TCHAR** argv) {
#else
diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc
index fc62893..233b60c 100644
--- a/googlemock/test/gmock-actions_test.cc
+++ b/googlemock/test/gmock-actions_test.cc
@@ -27,32 +27,33 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests the built-in actions.
// Silence C4100 (unreferenced formal parameter) for MSVC
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
+#pragma warning(push)
+#pragma warning(disable : 4100)
#if _MSC_VER == 1900
// and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 15
-# pragma warning(disable:4800)
+#pragma warning(disable : 4800)
#endif
#endif
#include "gmock/gmock-actions.h"
+
#include <algorithm>
#include <iterator>
#include <memory>
#include <string>
#include <type_traits>
+
#include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h"
-#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
+#include "gtest/gtest.h"
namespace {
@@ -114,17 +115,17 @@ TEST(BuiltInDefaultValueTest, IsZeroForNumericTypes) {
#endif
#endif
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned short>::Get()); // NOLINT
- EXPECT_EQ(0, BuiltInDefaultValue<signed short>::Get()); // NOLINT
- EXPECT_EQ(0, BuiltInDefaultValue<short>::Get()); // NOLINT
+ EXPECT_EQ(0, BuiltInDefaultValue<signed short>::Get()); // NOLINT
+ EXPECT_EQ(0, BuiltInDefaultValue<short>::Get()); // NOLINT
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned int>::Get());
EXPECT_EQ(0, BuiltInDefaultValue<signed int>::Get());
EXPECT_EQ(0, BuiltInDefaultValue<int>::Get());
- EXPECT_EQ(0U, BuiltInDefaultValue<unsigned long>::Get()); // NOLINT
- EXPECT_EQ(0, BuiltInDefaultValue<signed long>::Get()); // NOLINT
- EXPECT_EQ(0, BuiltInDefaultValue<long>::Get()); // NOLINT
+ EXPECT_EQ(0U, BuiltInDefaultValue<unsigned long>::Get()); // NOLINT
+ EXPECT_EQ(0, BuiltInDefaultValue<signed long>::Get()); // NOLINT
+ EXPECT_EQ(0, BuiltInDefaultValue<long>::Get()); // NOLINT
EXPECT_EQ(0U, BuiltInDefaultValue<unsigned long long>::Get()); // NOLINT
- EXPECT_EQ(0, BuiltInDefaultValue<signed long long>::Get()); // NOLINT
- EXPECT_EQ(0, BuiltInDefaultValue<long long>::Get()); // NOLINT
+ EXPECT_EQ(0, BuiltInDefaultValue<signed long long>::Get()); // NOLINT
+ EXPECT_EQ(0, BuiltInDefaultValue<long long>::Get()); // NOLINT
EXPECT_EQ(0, BuiltInDefaultValue<float>::Get());
EXPECT_EQ(0, BuiltInDefaultValue<double>::Get());
}
@@ -139,17 +140,17 @@ TEST(BuiltInDefaultValueTest, ExistsForNumericTypes) {
EXPECT_TRUE(BuiltInDefaultValue<wchar_t>::Exists());
#endif
EXPECT_TRUE(BuiltInDefaultValue<unsigned short>::Exists()); // NOLINT
- EXPECT_TRUE(BuiltInDefaultValue<signed short>::Exists()); // NOLINT
- EXPECT_TRUE(BuiltInDefaultValue<short>::Exists()); // NOLINT
+ EXPECT_TRUE(BuiltInDefaultValue<signed short>::Exists()); // NOLINT
+ EXPECT_TRUE(BuiltInDefaultValue<short>::Exists()); // NOLINT
EXPECT_TRUE(BuiltInDefaultValue<unsigned int>::Exists());
EXPECT_TRUE(BuiltInDefaultValue<signed int>::Exists());
EXPECT_TRUE(BuiltInDefaultValue<int>::Exists());
- EXPECT_TRUE(BuiltInDefaultValue<unsigned long>::Exists()); // NOLINT
- EXPECT_TRUE(BuiltInDefaultValue<signed long>::Exists()); // NOLINT
- EXPECT_TRUE(BuiltInDefaultValue<long>::Exists()); // NOLINT
+ EXPECT_TRUE(BuiltInDefaultValue<unsigned long>::Exists()); // NOLINT
+ EXPECT_TRUE(BuiltInDefaultValue<signed long>::Exists()); // NOLINT
+ EXPECT_TRUE(BuiltInDefaultValue<long>::Exists()); // NOLINT
EXPECT_TRUE(BuiltInDefaultValue<unsigned long long>::Exists()); // NOLINT
- EXPECT_TRUE(BuiltInDefaultValue<signed long long>::Exists()); // NOLINT
- EXPECT_TRUE(BuiltInDefaultValue<long long>::Exists()); // NOLINT
+ EXPECT_TRUE(BuiltInDefaultValue<signed long long>::Exists()); // NOLINT
+ EXPECT_TRUE(BuiltInDefaultValue<long long>::Exists()); // NOLINT
EXPECT_TRUE(BuiltInDefaultValue<float>::Exists());
EXPECT_TRUE(BuiltInDefaultValue<double>::Exists());
}
@@ -167,13 +168,13 @@ TEST(BuiltInDefaultValueTest, BoolExists) {
// Tests that BuiltInDefaultValue<T>::Get() returns "" when T is a
// string type.
TEST(BuiltInDefaultValueTest, IsEmptyStringForString) {
- EXPECT_EQ("", BuiltInDefaultValue< ::std::string>::Get());
+ EXPECT_EQ("", BuiltInDefaultValue<::std::string>::Get());
}
// Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a
// string type.
TEST(BuiltInDefaultValueTest, ExistsForString) {
- EXPECT_TRUE(BuiltInDefaultValue< ::std::string>::Exists());
+ EXPECT_TRUE(BuiltInDefaultValue<::std::string>::Exists());
}
// Tests that BuiltInDefaultValue<const T>::Get() returns the same
@@ -208,7 +209,6 @@ class MyNonDefaultConstructible {
int value_;
};
-
TEST(BuiltInDefaultValueTest, ExistsForDefaultConstructibleType) {
EXPECT_TRUE(BuiltInDefaultValue<MyDefaultConstructible>::Exists());
}
@@ -217,25 +217,19 @@ TEST(BuiltInDefaultValueTest, IsDefaultConstructedForDefaultConstructibleType) {
EXPECT_EQ(42, BuiltInDefaultValue<MyDefaultConstructible>::Get().value());
}
-
TEST(BuiltInDefaultValueTest, DoesNotExistForNonDefaultConstructibleType) {
EXPECT_FALSE(BuiltInDefaultValue<MyNonDefaultConstructible>::Exists());
}
// Tests that BuiltInDefaultValue<T&>::Get() aborts the program.
TEST(BuiltInDefaultValueDeathTest, IsUndefinedForReferences) {
- EXPECT_DEATH_IF_SUPPORTED({
- BuiltInDefaultValue<int&>::Get();
- }, "");
- EXPECT_DEATH_IF_SUPPORTED({
- BuiltInDefaultValue<const char&>::Get();
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED({ BuiltInDefaultValue<int&>::Get(); }, "");
+ EXPECT_DEATH_IF_SUPPORTED({ BuiltInDefaultValue<const char&>::Get(); }, "");
}
TEST(BuiltInDefaultValueDeathTest, IsUndefinedForNonDefaultConstructibleType) {
- EXPECT_DEATH_IF_SUPPORTED({
- BuiltInDefaultValue<MyNonDefaultConstructible>::Get();
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED(
+ { BuiltInDefaultValue<MyNonDefaultConstructible>::Get(); }, "");
}
// Tests that DefaultValue<T>::IsSet() is false initially.
@@ -281,26 +275,22 @@ TEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
EXPECT_EQ(0, DefaultValue<int>::Get());
- EXPECT_DEATH_IF_SUPPORTED({
- DefaultValue<MyNonDefaultConstructible>::Get();
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<MyNonDefaultConstructible>::Get(); },
+ "");
}
TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) {
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists());
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Get() == nullptr);
- DefaultValue<std::unique_ptr<int>>::SetFactory([] {
- return std::unique_ptr<int>(new int(42));
- });
+ DefaultValue<std::unique_ptr<int>>::SetFactory(
+ [] { return std::unique_ptr<int>(new int(42)); });
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists());
std::unique_ptr<int> i = DefaultValue<std::unique_ptr<int>>::Get();
EXPECT_EQ(42, *i);
}
// Tests that DefaultValue<void>::Get() returns void.
-TEST(DefaultValueTest, GetWorksForVoid) {
- return DefaultValue<void>::Get();
-}
+TEST(DefaultValueTest, GetWorksForVoid) { return DefaultValue<void>::Get(); }
// Tests using DefaultValue with a reference type.
@@ -348,12 +338,9 @@ TEST(DefaultValueOfReferenceDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
EXPECT_FALSE(DefaultValue<int&>::IsSet());
EXPECT_FALSE(DefaultValue<MyNonDefaultConstructible&>::IsSet());
- EXPECT_DEATH_IF_SUPPORTED({
- DefaultValue<int&>::Get();
- }, "");
- EXPECT_DEATH_IF_SUPPORTED({
- DefaultValue<MyNonDefaultConstructible>::Get();
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<int&>::Get(); }, "");
+ EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<MyNonDefaultConstructible>::Get(); },
+ "");
}
// Tests that ActionInterface can be implemented by defining the
@@ -433,7 +420,7 @@ class IsNotZero : public ActionInterface<bool(int)> { // NOLINT
};
TEST(ActionTest, CanBeConvertedToOtherActionType) {
- const Action<bool(int)> a1(new IsNotZero); // NOLINT
+ const Action<bool(int)> a1(new IsNotZero); // NOLINT
const Action<int(char)> a2 = Action<int(char)>(a1); // NOLINT
EXPECT_EQ(1, a2.Perform(std::make_tuple('a')));
EXPECT_EQ(0, a2.Perform(std::make_tuple('\0')));
@@ -528,7 +515,7 @@ TEST(ReturnTest, AcceptsStringLiteral) {
// Test struct which wraps a vector of integers. Used in
// 'SupportsWrapperReturnType' test.
struct IntegerVectorWrapper {
- std::vector<int> * v;
+ std::vector<int>* v;
IntegerVectorWrapper(std::vector<int>& _v) : v(&_v) {} // NOLINT
};
@@ -648,7 +635,9 @@ TEST(ReturnRefTest, IsCovariant) {
}
template <typename T, typename = decltype(ReturnRef(std::declval<T&&>()))>
-bool CanCallReturnRef(T&&) { return true; }
+bool CanCallReturnRef(T&&) {
+ return true;
+}
bool CanCallReturnRef(Unused) { return false; }
// Tests that ReturnRef(v) is working with non-temporaries (T&)
@@ -668,7 +657,7 @@ TEST(ReturnRefTest, WorksForNonTemporary) {
// Tests that ReturnRef(v) is not working with temporaries (T&&)
TEST(ReturnRefTest, DoesNotWorkForTemporary) {
- auto scalar_value = []() -> int { return 123; };
+ auto scalar_value = []() -> int { return 123; };
EXPECT_FALSE(CanCallReturnRef(scalar_value()));
auto non_scalar_value = []() -> std::string { return "ABC"; };
@@ -754,8 +743,7 @@ class MockClass {
// return type by default.
TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
MockClass mock;
- EXPECT_CALL(mock, IntFunc(_))
- .WillOnce(DoDefault());
+ EXPECT_CALL(mock, IntFunc(_)).WillOnce(DoDefault());
EXPECT_EQ(0, mock.IntFunc(true));
}
@@ -763,14 +751,11 @@ TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
// the process when there is no built-in default value for the return type.
TEST(DoDefaultDeathTest, DiesForUnknowType) {
MockClass mock;
- EXPECT_CALL(mock, Foo())
- .WillRepeatedly(DoDefault());
+ EXPECT_CALL(mock, Foo()).WillRepeatedly(DoDefault());
#if GTEST_HAS_EXCEPTIONS
EXPECT_ANY_THROW(mock.Foo());
#else
- EXPECT_DEATH_IF_SUPPORTED({
- mock.Foo();
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED({ mock.Foo(); }, "");
#endif
}
@@ -782,16 +767,13 @@ void VoidFunc(bool /* flag */) {}
TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
MockClass mock;
EXPECT_CALL(mock, IntFunc(_))
- .WillRepeatedly(DoAll(Invoke(VoidFunc),
- DoDefault()));
+ .WillRepeatedly(DoAll(Invoke(VoidFunc), DoDefault()));
// Ideally we should verify the error message as well. Sadly,
// EXPECT_DEATH() can only capture stderr, while Google Mock's
// errors are printed on stdout. Therefore we have to settle for
// not verifying the message.
- EXPECT_DEATH_IF_SUPPORTED({
- mock.IntFunc(true);
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED({ mock.IntFunc(true); }, "");
}
// Tests that DoDefault() returns the default value set by
@@ -799,8 +781,7 @@ TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) {
DefaultValue<int>::Set(1);
MockClass mock;
- EXPECT_CALL(mock, IntFunc(_))
- .WillOnce(DoDefault());
+ EXPECT_CALL(mock, IntFunc(_)).WillOnce(DoDefault());
EXPECT_EQ(1, mock.IntFunc(false));
DefaultValue<int>::Clear();
}
@@ -808,20 +789,19 @@ TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) {
// Tests that DoDefault() does the action specified by ON_CALL().
TEST(DoDefaultTest, DoesWhatOnCallSpecifies) {
MockClass mock;
- ON_CALL(mock, IntFunc(_))
- .WillByDefault(Return(2));
- EXPECT_CALL(mock, IntFunc(_))
- .WillOnce(DoDefault());
+ ON_CALL(mock, IntFunc(_)).WillByDefault(Return(2));
+ EXPECT_CALL(mock, IntFunc(_)).WillOnce(DoDefault());
EXPECT_EQ(2, mock.IntFunc(false));
}
// Tests that using DoDefault() in ON_CALL() leads to a run-time failure.
TEST(DoDefaultTest, CannotBeUsedInOnCall) {
MockClass mock;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- ON_CALL(mock, IntFunc(_))
- .WillByDefault(DoDefault());
- }, "DoDefault() cannot be used in ON_CALL()");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ ON_CALL(mock, IntFunc(_)).WillByDefault(DoDefault());
+ },
+ "DoDefault() cannot be used in ON_CALL()");
}
// Tests that SetArgPointee<N>(v) sets the variable pointed to by
@@ -868,7 +848,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
a.Perform(std::make_tuple(&ptr));
EXPECT_STREQ(L"world", ptr);
-# if GTEST_HAS_STD_WSTRING
+#if GTEST_HAS_STD_WSTRING
typedef void MyStringFunction(std::wstring*);
Action<MyStringFunction> a2 = SetArgPointee<0>(L"world");
@@ -876,7 +856,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
a2.Perform(std::make_tuple(&str));
EXPECT_EQ(L"world", str);
-# endif
+#endif
}
// Tests that SetArgPointee<N>() accepts a char pointer.
@@ -907,7 +887,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
a.Perform(std::make_tuple(true, &ptr));
EXPECT_EQ(hi, ptr);
-# if GTEST_HAS_STD_WSTRING
+#if GTEST_HAS_STD_WSTRING
typedef void MyStringFunction(bool, std::wstring*);
wchar_t world_array[] = L"world";
@@ -916,7 +896,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
std::wstring str;
a2.Perform(std::make_tuple(true, &str));
EXPECT_EQ(world_array, str);
-# endif
+#endif
}
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
@@ -1079,7 +1059,6 @@ TEST(AssignTest, CompatibleTypes) {
EXPECT_DOUBLE_EQ(5, x);
}
-
// Tests using WithArgs and with an action that takes 1 argument.
TEST(WithArgsTest, OneArg) {
Action<bool(double x, int n)> a = WithArgs<1>(Invoke(Unary)); // NOLINT
@@ -1235,7 +1214,7 @@ TEST(ByRefTest, IsCopyable) {
TEST(ByRefTest, ConstValue) {
const int n = 0;
// int& ref = ByRef(n); // This shouldn't compile - we have a
- // negative compilation test to catch it.
+ // negative compilation test to catch it.
const int& const_ref = ByRef(n);
EXPECT_EQ(&n, &const_ref);
}
@@ -1260,7 +1239,7 @@ TEST(ByRefTest, ExplicitType) {
EXPECT_EQ(&n, &r1);
// ByRef<char>(n); // This shouldn't compile - we have a negative
- // compilation test to catch it.
+ // compilation test to catch it.
Derived d;
Derived& r2 = ByRef<Derived>(d);
@@ -1375,9 +1354,10 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_DoAllReturn) {
MockClass mock;
std::unique_ptr<int> i(new int(19));
EXPECT_CALL(mock_function, Call());
- EXPECT_CALL(mock, MakeUnique()).WillOnce(DoAll(
- InvokeWithoutArgs(&mock_function, &testing::MockFunction<void()>::Call),
- Return(ByMove(std::move(i)))));
+ EXPECT_CALL(mock, MakeUnique())
+ .WillOnce(DoAll(InvokeWithoutArgs(&mock_function,
+ &testing::MockFunction<void()>::Call),
+ Return(ByMove(std::move(i)))));
std::unique_ptr<int> result1 = mock.MakeUnique();
EXPECT_EQ(19, *result1);
@@ -1387,9 +1367,8 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
MockClass mock;
// Check default value
- DefaultValue<std::unique_ptr<int>>::SetFactory([] {
- return std::unique_ptr<int>(new int(42));
- });
+ DefaultValue<std::unique_ptr<int>>::SetFactory(
+ [] { return std::unique_ptr<int>(new int(42)); });
EXPECT_EQ(42, *mock.MakeUnique());
EXPECT_CALL(mock, MakeUnique()).WillRepeatedly(Invoke(UniquePtrSource));
@@ -1449,7 +1428,6 @@ TEST(MockMethodTest, CanTakeMoveOnlyValue) {
EXPECT_EQ(42, *saved);
}
-
// Tests for std::function based action.
int Add(int val, int& ref, int* ptr) { // NOLINT
@@ -1463,7 +1441,9 @@ int Deref(std::unique_ptr<int> ptr) { return *ptr; }
struct Double {
template <typename T>
- T operator()(T t) { return 2 * t; }
+ T operator()(T t) {
+ return 2 * t;
+ }
};
std::unique_ptr<int> UniqueInt(int i) {
@@ -1532,8 +1512,9 @@ TEST(FunctorActionTest, TypeConversion) {
TEST(FunctorActionTest, UnusedArguments) {
// Verify that users can ignore uninteresting arguments.
- Action<int(int, double y, double z)> a =
- [](int i, Unused, Unused) { return 2 * i; };
+ Action<int(int, double y, double z)> a = [](int i, Unused, Unused) {
+ return 2 * i;
+ };
std::tuple<int, double, double> dummy = std::make_tuple(3, 7.3, 9.44);
EXPECT_EQ(6, a.Perform(dummy));
}
@@ -1552,9 +1533,7 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) {
EXPECT_EQ(x, 3);
}
-ACTION(ReturnArity) {
- return std::tuple_size<args_type>::value;
-}
+ACTION(ReturnArity) { return std::tuple_size<args_type>::value; }
TEST(ActionMacro, LargeArity) {
EXPECT_EQ(
@@ -1577,7 +1556,6 @@ TEST(ActionMacro, LargeArity) {
#ifdef _MSC_VER
#if _MSC_VER == 1900
-# pragma warning(pop)
+#pragma warning(pop)
#endif
#endif
-
diff --git a/googlemock/test/gmock-cardinalities_test.cc b/googlemock/test/gmock-cardinalities_test.cc
index ca97cae..e7efd97 100644
--- a/googlemock/test/gmock-cardinalities_test.cc
+++ b/googlemock/test/gmock-cardinalities_test.cc
@@ -27,14 +27,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests the built-in cardinalities.
#include "gmock/gmock.h"
-#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
+#include "gtest/gtest.h"
namespace {
@@ -59,9 +58,7 @@ class MockFoo {
};
// Tests that Cardinality objects can be default constructed.
-TEST(CardinalityTest, IsDefaultConstructable) {
- Cardinality c;
-}
+TEST(CardinalityTest, IsDefaultConstructable) { Cardinality c; }
// Tests that Cardinality objects are copyable.
TEST(CardinalityTest, IsCopyable) {
@@ -119,8 +116,7 @@ TEST(AnyNumber, Works) {
stringstream ss;
c.DescribeTo(&ss);
- EXPECT_PRED_FORMAT2(IsSubstring, "called any number of times",
- ss.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called any number of times", ss.str());
}
TEST(AnyNumberTest, HasCorrectBounds) {
@@ -132,9 +128,11 @@ TEST(AnyNumberTest, HasCorrectBounds) {
// Tests AtLeast(n).
TEST(AtLeastTest, OnNegativeNumber) {
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- AtLeast(-1);
- }, "The invocation lower bound must be >= 0");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ AtLeast(-1);
+ },
+ "The invocation lower bound must be >= 0");
}
TEST(AtLeastTest, OnZero) {
@@ -147,8 +145,7 @@ TEST(AtLeastTest, OnZero) {
stringstream ss;
c.DescribeTo(&ss);
- EXPECT_PRED_FORMAT2(IsSubstring, "any number of times",
- ss.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "any number of times", ss.str());
}
TEST(AtLeastTest, OnPositiveNumber) {
@@ -164,18 +161,15 @@ TEST(AtLeastTest, OnPositiveNumber) {
stringstream ss1;
AtLeast(1).DescribeTo(&ss1);
- EXPECT_PRED_FORMAT2(IsSubstring, "at least once",
- ss1.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "at least once", ss1.str());
stringstream ss2;
c.DescribeTo(&ss2);
- EXPECT_PRED_FORMAT2(IsSubstring, "at least twice",
- ss2.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "at least twice", ss2.str());
stringstream ss3;
AtLeast(3).DescribeTo(&ss3);
- EXPECT_PRED_FORMAT2(IsSubstring, "at least 3 times",
- ss3.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "at least 3 times", ss3.str());
}
TEST(AtLeastTest, HasCorrectBounds) {
@@ -187,9 +181,11 @@ TEST(AtLeastTest, HasCorrectBounds) {
// Tests AtMost(n).
TEST(AtMostTest, OnNegativeNumber) {
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- AtMost(-1);
- }, "The invocation upper bound must be >= 0");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ AtMost(-1);
+ },
+ "The invocation upper bound must be >= 0");
}
TEST(AtMostTest, OnZero) {
@@ -202,8 +198,7 @@ TEST(AtMostTest, OnZero) {
stringstream ss;
c.DescribeTo(&ss);
- EXPECT_PRED_FORMAT2(IsSubstring, "never called",
- ss.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str());
}
TEST(AtMostTest, OnPositiveNumber) {
@@ -219,18 +214,15 @@ TEST(AtMostTest, OnPositiveNumber) {
stringstream ss1;
AtMost(1).DescribeTo(&ss1);
- EXPECT_PRED_FORMAT2(IsSubstring, "called at most once",
- ss1.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called at most once", ss1.str());
stringstream ss2;
c.DescribeTo(&ss2);
- EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice",
- ss2.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", ss2.str());
stringstream ss3;
AtMost(3).DescribeTo(&ss3);
- EXPECT_PRED_FORMAT2(IsSubstring, "called at most 3 times",
- ss3.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called at most 3 times", ss3.str());
}
TEST(AtMostTest, HasCorrectBounds) {
@@ -242,22 +234,28 @@ TEST(AtMostTest, HasCorrectBounds) {
// Tests Between(m, n).
TEST(BetweenTest, OnNegativeStart) {
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- Between(-1, 2);
- }, "The invocation lower bound must be >= 0, but is actually -1");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ Between(-1, 2);
+ },
+ "The invocation lower bound must be >= 0, but is actually -1");
}
TEST(BetweenTest, OnNegativeEnd) {
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- Between(1, -2);
- }, "The invocation upper bound must be >= 0, but is actually -2");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ Between(1, -2);
+ },
+ "The invocation upper bound must be >= 0, but is actually -2");
}
TEST(BetweenTest, OnStartBiggerThanEnd) {
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- Between(2, 1);
- }, "The invocation upper bound (1) must be >= "
- "the invocation lower bound (2)");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ Between(2, 1);
+ },
+ "The invocation upper bound (1) must be >= "
+ "the invocation lower bound (2)");
}
TEST(BetweenTest, OnZeroStartAndZeroEnd) {
@@ -271,8 +269,7 @@ TEST(BetweenTest, OnZeroStartAndZeroEnd) {
stringstream ss;
c.DescribeTo(&ss);
- EXPECT_PRED_FORMAT2(IsSubstring, "never called",
- ss.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str());
}
TEST(BetweenTest, OnZeroStartAndNonZeroEnd) {
@@ -289,8 +286,7 @@ TEST(BetweenTest, OnZeroStartAndNonZeroEnd) {
stringstream ss;
c.DescribeTo(&ss);
- EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice",
- ss.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", ss.str());
}
TEST(BetweenTest, OnSameStartAndEnd) {
@@ -307,8 +303,7 @@ TEST(BetweenTest, OnSameStartAndEnd) {
stringstream ss;
c.DescribeTo(&ss);
- EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times",
- ss.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", ss.str());
}
TEST(BetweenTest, OnDifferentStartAndEnd) {
@@ -328,8 +323,7 @@ TEST(BetweenTest, OnDifferentStartAndEnd) {
stringstream ss;
c.DescribeTo(&ss);
- EXPECT_PRED_FORMAT2(IsSubstring, "called between 3 and 5 times",
- ss.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called between 3 and 5 times", ss.str());
}
TEST(BetweenTest, HasCorrectBounds) {
@@ -341,9 +335,11 @@ TEST(BetweenTest, HasCorrectBounds) {
// Tests Exactly(n).
TEST(ExactlyTest, OnNegativeNumber) {
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- Exactly(-1);
- }, "The invocation lower bound must be >= 0");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ Exactly(-1);
+ },
+ "The invocation lower bound must be >= 0");
}
TEST(ExactlyTest, OnZero) {
@@ -356,8 +352,7 @@ TEST(ExactlyTest, OnZero) {
stringstream ss;
c.DescribeTo(&ss);
- EXPECT_PRED_FORMAT2(IsSubstring, "never called",
- ss.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str());
}
TEST(ExactlyTest, OnPositiveNumber) {
@@ -370,18 +365,15 @@ TEST(ExactlyTest, OnPositiveNumber) {
stringstream ss1;
Exactly(1).DescribeTo(&ss1);
- EXPECT_PRED_FORMAT2(IsSubstring, "called once",
- ss1.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called once", ss1.str());
stringstream ss2;
c.DescribeTo(&ss2);
- EXPECT_PRED_FORMAT2(IsSubstring, "called twice",
- ss2.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called twice", ss2.str());
stringstream ss3;
Exactly(3).DescribeTo(&ss3);
- EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times",
- ss3.str());
+ EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", ss3.str());
}
TEST(ExactlyTest, HasCorrectBounds) {
diff --git a/googlemock/test/gmock-function-mocker_test.cc b/googlemock/test/gmock-function-mocker_test.cc
index cf76fa9..dc750a3 100644
--- a/googlemock/test/gmock-function-mocker_test.cc
+++ b/googlemock/test/gmock-function-mocker_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests the function mocker classes.
@@ -37,7 +36,7 @@
// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but
// we are getting compiler errors if we use basetyps.h, hence including
// objbase.h for definition of STDMETHOD.
-# include <objbase.h>
+#include <objbase.h>
#endif // GTEST_OS_WINDOWS
#include <functional>
@@ -65,7 +64,7 @@ using testing::Return;
using testing::ReturnRef;
using testing::TypedEq;
-template<typename T>
+template <typename T>
class TemplatedCopyable {
public:
TemplatedCopyable() {}
@@ -82,7 +81,7 @@ class FooInterface {
virtual int Nullary() = 0;
virtual bool Unary(int x) = 0;
- virtual long Binary(short x, int y) = 0; // NOLINT
+ virtual long Binary(short x, int y) = 0; // NOLINT
virtual int Decimal(bool b, char c, short d, int e, long f, // NOLINT
float g, double h, unsigned i, char* j,
const std::string& k) = 0;
@@ -133,8 +132,8 @@ class FooInterface {
// signature. This was fixed in Visual Studio 2008. However, the compiler
// still emits a warning that alerts about this change in behavior.
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable : 4373)
+#pragma warning(push)
+#pragma warning(disable : 4373)
#endif
class MockFoo : public FooInterface {
public:
@@ -279,7 +278,7 @@ class LegacyMockFoo : public FooInterface {
};
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
template <class T>
@@ -595,10 +594,8 @@ TYPED_TEST(TemplateMockTest, Works) {
.WillOnce(Return(0));
EXPECT_CALL(mock, Push(_));
int n = 5;
- EXPECT_CALL(mock, GetTop())
- .WillOnce(ReturnRef(n));
- EXPECT_CALL(mock, Pop())
- .Times(AnyNumber());
+ EXPECT_CALL(mock, GetTop()).WillOnce(ReturnRef(n));
+ EXPECT_CALL(mock, Pop()).Times(AnyNumber());
EXPECT_EQ(0, mock.GetSize());
mock.Push(5);
@@ -612,10 +609,8 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
TypeParam mock;
const std::map<int, int> a_map;
- EXPECT_CALL(mock, ReturnTypeWithComma())
- .WillOnce(Return(a_map));
- EXPECT_CALL(mock, ReturnTypeWithComma(1))
- .WillOnce(Return(a_map));
+ EXPECT_CALL(mock, ReturnTypeWithComma()).WillOnce(Return(a_map));
+ EXPECT_CALL(mock, ReturnTypeWithComma(1)).WillOnce(Return(a_map));
EXPECT_EQ(a_map, mock.ReturnTypeWithComma());
EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));
@@ -685,10 +680,8 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) {
.WillOnce(Return(0));
EXPECT_CALL(mock, Push(_));
int n = 5;
- EXPECT_CALL(mock, GetTop())
- .WillOnce(ReturnRef(n));
- EXPECT_CALL(mock, Pop())
- .Times(AnyNumber());
+ EXPECT_CALL(mock, GetTop()).WillOnce(ReturnRef(n));
+ EXPECT_CALL(mock, Pop()).Times(AnyNumber());
EXPECT_EQ(0, mock.GetSize());
mock.Push(5);
@@ -747,9 +740,9 @@ TYPED_TEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {
EXPECT_TRUE(mock.Overloaded(true, 1));
}
-#define MY_MOCK_METHODS2_ \
- MOCK_CONST_METHOD1(Overloaded, int(int n)); \
- MOCK_METHOD1(Overloaded, int(int n))
+#define MY_MOCK_METHODS2_ \
+ MOCK_CONST_METHOD1(Overloaded, int(int n)); \
+ MOCK_METHOD1(Overloaded, int(int n))
class MockOverloadedOnConstness {
public:
@@ -779,9 +772,7 @@ TEST(MockMethodMockFunctionTest, WorksForVoidNullary) {
TEST(MockMethodMockFunctionTest, WorksForNonVoidNullary) {
MockFunction<int()> foo;
- EXPECT_CALL(foo, Call())
- .WillOnce(Return(1))
- .WillOnce(Return(2));
+ EXPECT_CALL(foo, Call()).WillOnce(Return(1)).WillOnce(Return(2));
EXPECT_EQ(1, foo.Call());
EXPECT_EQ(2, foo.Call());
}
@@ -794,19 +785,17 @@ TEST(MockMethodMockFunctionTest, WorksForVoidUnary) {
TEST(MockMethodMockFunctionTest, WorksForNonVoidBinary) {
MockFunction<int(bool, int)> foo;
- EXPECT_CALL(foo, Call(false, 42))
- .WillOnce(Return(1))
- .WillOnce(Return(2));
- EXPECT_CALL(foo, Call(true, Ge(100)))
- .WillOnce(Return(3));
+ EXPECT_CALL(foo, Call(false, 42)).WillOnce(Return(1)).WillOnce(Return(2));
+ EXPECT_CALL(foo, Call(true, Ge(100))).WillOnce(Return(3));
EXPECT_EQ(1, foo.Call(false, 42));
EXPECT_EQ(2, foo.Call(false, 42));
EXPECT_EQ(3, foo.Call(true, 120));
}
TEST(MockMethodMockFunctionTest, WorksFor10Arguments) {
- MockFunction<int(bool a0, char a1, int a2, int a3, int a4,
- int a5, int a6, char a7, int a8, bool a9)> foo;
+ MockFunction<int(bool a0, char a1, int a2, int a3, int a4, int a5, int a6,
+ char a7, int a8, bool a9)>
+ foo;
EXPECT_CALL(foo, Call(_, 'a', _, _, _, _, _, _, _, _))
.WillOnce(Return(1))
.WillOnce(Return(2));
@@ -816,9 +805,7 @@ TEST(MockMethodMockFunctionTest, WorksFor10Arguments) {
TEST(MockMethodMockFunctionTest, AsStdFunction) {
MockFunction<int(int)> foo;
- auto call = [](const std::function<int(int)> &f, int i) {
- return f(i);
- };
+ auto call = [](const std::function<int(int)>& f, int i) { return f(i); };
EXPECT_CALL(foo, Call(1)).WillOnce(Return(-1));
EXPECT_CALL(foo, Call(2)).WillOnce(Return(-2));
EXPECT_EQ(-1, call(foo.AsStdFunction(), 1));
@@ -836,10 +823,8 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionReturnsReference) {
}
TEST(MockMethodMockFunctionTest, AsStdFunctionWithReferenceParameter) {
- MockFunction<int(int &)> foo;
- auto call = [](const std::function<int(int& )> &f, int &i) {
- return f(i);
- };
+ MockFunction<int(int&)> foo;
+ auto call = [](const std::function<int(int&)>& f, int& i) { return f(i); };
int i = 42;
EXPECT_CALL(foo, Call(i)).WillOnce(Return(-1));
EXPECT_EQ(-1, call(foo.AsStdFunction(), i));
@@ -888,8 +873,7 @@ TYPED_TEST(
}
template <typename F>
-struct AlternateCallable {
-};
+struct AlternateCallable {};
TYPED_TEST(MockMethodMockFunctionSignatureTest,
IsMockFunctionTemplateArgumentDeducedForAlternateCallable) {
@@ -898,16 +882,14 @@ TYPED_TEST(MockMethodMockFunctionSignatureTest,
EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
}
-TYPED_TEST(
- MockMethodMockFunctionSignatureTest,
- IsMockFunctionCallMethodSignatureTheSameForAlternateCallable) {
+TYPED_TEST(MockMethodMockFunctionSignatureTest,
+ IsMockFunctionCallMethodSignatureTheSameForAlternateCallable) {
using ForRawSignature = decltype(&MockFunction<TypeParam>::Call);
using ForStdFunction =
decltype(&MockFunction<std::function<TypeParam>>::Call);
EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value));
}
-
struct MockMethodSizes0 {
MOCK_METHOD(void, func, ());
};
@@ -925,22 +907,21 @@ struct MockMethodSizes4 {
};
struct LegacyMockMethodSizes0 {
- MOCK_METHOD0(func, void());
+ MOCK_METHOD0(func, void());
};
struct LegacyMockMethodSizes1 {
- MOCK_METHOD1(func, void(int));
+ MOCK_METHOD1(func, void(int));
};
struct LegacyMockMethodSizes2 {
- MOCK_METHOD2(func, void(int, int));
+ MOCK_METHOD2(func, void(int, int));
};
struct LegacyMockMethodSizes3 {
- MOCK_METHOD3(func, void(int, int, int));
+ MOCK_METHOD3(func, void(int, int, int));
};
struct LegacyMockMethodSizes4 {
- MOCK_METHOD4(func, void(int, int, int, int));
+ MOCK_METHOD4(func, void(int, int, int, int));
};
-
TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) {
EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes1));
EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes2));
diff --git a/googlemock/test/gmock-internal-utils_test.cc b/googlemock/test/gmock-internal-utils_test.cc
index 800ee8a..932bece 100644
--- a/googlemock/test/gmock-internal-utils_test.cc
+++ b/googlemock/test/gmock-internal-utils_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests the internal utilities.
@@ -58,7 +57,7 @@
#undef GTEST_IMPLEMENTATION_
#if GTEST_OS_CYGWIN
-# include <sys/types.h> // For ssize_t. NOLINT
+#include <sys/types.h> // For ssize_t. NOLINT
#endif
namespace proto2 {
@@ -155,19 +154,19 @@ TEST(KindOfTest, Bool) {
}
TEST(KindOfTest, Integer) {
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(char)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(signed char)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned char)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(short)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned short)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(int)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned int)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(long)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(long long)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(char)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(signed char)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned char)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(short)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned short)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(int)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned int)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(long)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(long long)); // NOLINT
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long long)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(wchar_t)); // NOLINT
- EXPECT_EQ(kInteger, GMOCK_KIND_OF_(size_t)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(wchar_t)); // NOLINT
+ EXPECT_EQ(kInteger, GMOCK_KIND_OF_(size_t)); // NOLINT
#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN
// ssize_t is not defined on Windows and possibly some other OSes.
EXPECT_EQ(kInteger, GMOCK_KIND_OF_(ssize_t)); // NOLINT
@@ -175,15 +174,15 @@ TEST(KindOfTest, Integer) {
}
TEST(KindOfTest, FloatingPoint) {
- EXPECT_EQ(kFloatingPoint, GMOCK_KIND_OF_(float)); // NOLINT
- EXPECT_EQ(kFloatingPoint, GMOCK_KIND_OF_(double)); // NOLINT
+ EXPECT_EQ(kFloatingPoint, GMOCK_KIND_OF_(float)); // NOLINT
+ EXPECT_EQ(kFloatingPoint, GMOCK_KIND_OF_(double)); // NOLINT
EXPECT_EQ(kFloatingPoint, GMOCK_KIND_OF_(long double)); // NOLINT
}
TEST(KindOfTest, Other) {
- EXPECT_EQ(kOther, GMOCK_KIND_OF_(void*)); // NOLINT
+ EXPECT_EQ(kOther, GMOCK_KIND_OF_(void*)); // NOLINT
EXPECT_EQ(kOther, GMOCK_KIND_OF_(char**)); // NOLINT
- EXPECT_EQ(kOther, GMOCK_KIND_OF_(Base)); // NOLINT
+ EXPECT_EQ(kOther, GMOCK_KIND_OF_(Base)); // NOLINT
}
// Tests LosslessArithmeticConvertible<T, U>.
@@ -214,26 +213,26 @@ TEST(LosslessArithmeticConvertibleTest, IntegerToInteger) {
EXPECT_TRUE((LosslessArithmeticConvertible<unsigned char, int>::value));
// Unsigned => larger unsigned is fine.
- EXPECT_TRUE((LosslessArithmeticConvertible<
- unsigned short, uint64_t>::value)); // NOLINT
+ EXPECT_TRUE((LosslessArithmeticConvertible<unsigned short,
+ uint64_t>::value)); // NOLINT
// Signed => unsigned is not fine.
- EXPECT_FALSE((LosslessArithmeticConvertible<
- short, uint64_t>::value)); // NOLINT
- EXPECT_FALSE((LosslessArithmeticConvertible<
- signed char, unsigned int>::value)); // NOLINT
+ EXPECT_FALSE(
+ (LosslessArithmeticConvertible<short, uint64_t>::value)); // NOLINT
+ EXPECT_FALSE((LosslessArithmeticConvertible<signed char,
+ unsigned int>::value)); // NOLINT
// Same size and same signedness: fine too.
- EXPECT_TRUE((LosslessArithmeticConvertible<
- unsigned char, unsigned char>::value));
+ EXPECT_TRUE(
+ (LosslessArithmeticConvertible<unsigned char, unsigned char>::value));
EXPECT_TRUE((LosslessArithmeticConvertible<int, int>::value));
EXPECT_TRUE((LosslessArithmeticConvertible<wchar_t, wchar_t>::value));
- EXPECT_TRUE((LosslessArithmeticConvertible<
- unsigned long, unsigned long>::value)); // NOLINT
+ EXPECT_TRUE((LosslessArithmeticConvertible<unsigned long,
+ unsigned long>::value)); // NOLINT
// Same size, different signedness: not fine.
- EXPECT_FALSE((LosslessArithmeticConvertible<
- unsigned char, signed char>::value));
+ EXPECT_FALSE(
+ (LosslessArithmeticConvertible<unsigned char, signed char>::value));
EXPECT_FALSE((LosslessArithmeticConvertible<int, unsigned int>::value));
EXPECT_FALSE((LosslessArithmeticConvertible<uint64_t, int64_t>::value));
@@ -248,8 +247,8 @@ TEST(LosslessArithmeticConvertibleTest, IntegerToFloatingPoint) {
// the format of the latter is implementation-defined.
EXPECT_FALSE((LosslessArithmeticConvertible<char, float>::value));
EXPECT_FALSE((LosslessArithmeticConvertible<int, double>::value));
- EXPECT_FALSE((LosslessArithmeticConvertible<
- short, long double>::value)); // NOLINT
+ EXPECT_FALSE(
+ (LosslessArithmeticConvertible<short, long double>::value)); // NOLINT
}
TEST(LosslessArithmeticConvertibleTest, FloatingPointToBool) {
@@ -277,7 +276,7 @@ TEST(LosslessArithmeticConvertibleTest, FloatingPointToFloatingPoint) {
EXPECT_FALSE((LosslessArithmeticConvertible<double, float>::value));
GTEST_INTENTIONAL_CONST_COND_PUSH_()
if (sizeof(double) == sizeof(long double)) { // NOLINT
- GTEST_INTENTIONAL_CONST_COND_POP_()
+ GTEST_INTENTIONAL_CONST_COND_POP_()
// In some implementations (e.g. MSVC), double and long double
// have the same size.
EXPECT_TRUE((LosslessArithmeticConvertible<long double, double>::value));
@@ -296,7 +295,7 @@ TEST(TupleMatchesTest, WorksForSize0) {
}
TEST(TupleMatchesTest, WorksForSize1) {
- std::tuple<Matcher<int> > matchers(Eq(1));
+ std::tuple<Matcher<int>> matchers(Eq(1));
std::tuple<int> values1(1), values2(2);
EXPECT_TRUE(TupleMatches(matchers, values1));
@@ -304,7 +303,7 @@ TEST(TupleMatchesTest, WorksForSize1) {
}
TEST(TupleMatchesTest, WorksForSize2) {
- std::tuple<Matcher<int>, Matcher<char> > matchers(Eq(1), Eq('a'));
+ std::tuple<Matcher<int>, Matcher<char>> matchers(Eq(1), Eq('a'));
std::tuple<int, char> values1(1, 'a'), values2(1, 'b'), values3(2, 'a'),
values4(2, 'b');
@@ -317,7 +316,7 @@ TEST(TupleMatchesTest, WorksForSize2) {
TEST(TupleMatchesTest, WorksForSize5) {
std::tuple<Matcher<int>, Matcher<char>, Matcher<bool>,
Matcher<long>, // NOLINT
- Matcher<std::string> >
+ Matcher<std::string>>
matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq("hi"));
std::tuple<int, char, bool, long, std::string> // NOLINT
values1(1, 'a', true, 2L, "hi"), values2(1, 'a', true, 2L, "hello"),
@@ -336,13 +335,10 @@ TEST(AssertTest, SucceedsOnTrue) {
// Tests that Assert(false, ...) generates a fatal failure.
TEST(AssertTest, FailsFatallyOnFalse) {
- EXPECT_DEATH_IF_SUPPORTED({
- Assert(false, __FILE__, __LINE__, "This should fail.");
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED(
+ { Assert(false, __FILE__, __LINE__, "This should fail."); }, "");
- EXPECT_DEATH_IF_SUPPORTED({
- Assert(false, __FILE__, __LINE__);
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED({ Assert(false, __FILE__, __LINE__); }, "");
}
// Tests that Expect(true, ...) succeeds.
@@ -353,13 +349,17 @@ TEST(ExpectTest, SucceedsOnTrue) {
// Tests that Expect(false, ...) generates a non-fatal failure.
TEST(ExpectTest, FailsNonfatallyOnFalse) {
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- Expect(false, __FILE__, __LINE__, "This should fail.");
- }, "This should fail");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ Expect(false, __FILE__, __LINE__, "This should fail.");
+ },
+ "This should fail");
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- Expect(false, __FILE__, __LINE__);
- }, "Expectation failed");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ Expect(false, __FILE__, __LINE__);
+ },
+ "Expectation failed");
}
// Tests LogIsVisible().
@@ -404,11 +404,11 @@ void TestLogWithSeverity(const std::string& verbosity, LogSeverity severity,
CaptureStdout();
Log(severity, "Test log.\n", 0);
if (should_print) {
- EXPECT_THAT(GetCapturedStdout().c_str(),
- ContainsRegex(
- severity == kWarning ?
- "^\nGMOCK WARNING:\nTest log\\.\nStack trace:\n" :
- "^\nTest log\\.\nStack trace:\n"));
+ EXPECT_THAT(
+ GetCapturedStdout().c_str(),
+ ContainsRegex(severity == kWarning
+ ? "^\nGMOCK WARNING:\nTest log\\.\nStack trace:\n"
+ : "^\nTest log\\.\nStack trace:\n"));
} else {
EXPECT_STREQ("", GetCapturedStdout().c_str());
}
@@ -455,13 +455,13 @@ TEST(LogTest, NoSkippingStackFrameInOptMode) {
EXPECT_THAT(log, HasSubstr(expected_message));
int skip_count = atoi(log.substr(expected_message.size()).c_str());
-# if defined(NDEBUG)
+#if defined(NDEBUG)
// In opt mode, no stack frame should be skipped.
const int expected_skip_count = 0;
-# else
+#else
// In dbg mode, the stack frames should be skipped.
const int expected_skip_count = 100;
-# endif
+#endif
// Note that each inner implementation layer will +1 the number to remove
// itself from the trace. This means that the value is a little higher than
@@ -503,7 +503,7 @@ TEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsInvalid) {
// Verifies that Log() behaves correctly for the given verbosity level
// and log severity.
-std::string GrabOutput(void(*logger)(), const char* verbosity) {
+std::string GrabOutput(void (*logger)(), const char* verbosity) {
const std::string saved_flag = GMOCK_FLAG_GET(verbose);
GMOCK_FLAG_SET(verbose, verbosity);
CaptureStdout();
@@ -538,7 +538,7 @@ TEST(ExpectCallTest, DoesNotLogWhenVerbosityIsWarning) {
// Verifies that EXPECT_CALL doesn't log
// if the --gmock_verbose flag is set to "error".
-TEST(ExpectCallTest, DoesNotLogWhenVerbosityIsError) {
+TEST(ExpectCallTest, DoesNotLogWhenVerbosityIsError) {
EXPECT_STREQ("", GrabOutput(ExpectCallLogger, kErrorVerbosity).c_str());
}
@@ -582,9 +582,9 @@ TEST(OnCallTest, LogsAnythingArgument) {
TEST(StlContainerViewTest, WorksForStlContainer) {
StaticAssertTypeEq<std::vector<int>,
- StlContainerView<std::vector<int> >::type>();
+ StlContainerView<std::vector<int>>::type>();
StaticAssertTypeEq<const std::vector<double>&,
- StlContainerView<std::vector<double> >::const_reference>();
+ StlContainerView<std::vector<double>>::const_reference>();
typedef std::vector<char> Chars;
Chars v1;
@@ -597,17 +597,16 @@ TEST(StlContainerViewTest, WorksForStlContainer) {
}
TEST(StlContainerViewTest, WorksForStaticNativeArray) {
- StaticAssertTypeEq<NativeArray<int>,
- StlContainerView<int[3]>::type>();
+ StaticAssertTypeEq<NativeArray<int>, StlContainerView<int[3]>::type>();
StaticAssertTypeEq<NativeArray<double>,
- StlContainerView<const double[4]>::type>();
+ StlContainerView<const double[4]>::type>();
StaticAssertTypeEq<NativeArray<char[3]>,
- StlContainerView<const char[2][3]>::type>();
+ StlContainerView<const char[2][3]>::type>();
StaticAssertTypeEq<const NativeArray<int>,
- StlContainerView<int[2]>::const_reference>();
+ StlContainerView<int[2]>::const_reference>();
- int a1[3] = { 0, 1, 2 };
+ int a1[3] = {0, 1, 2};
NativeArray<int> a2 = StlContainerView<int[3]>::ConstReference(a1);
EXPECT_EQ(3U, a2.size());
EXPECT_EQ(a1, a2.begin());
@@ -625,24 +624,24 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) {
TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
StaticAssertTypeEq<NativeArray<int>,
- StlContainerView<std::tuple<const int*, size_t> >::type>();
+ StlContainerView<std::tuple<const int*, size_t>>::type>();
StaticAssertTypeEq<
NativeArray<double>,
- StlContainerView<std::tuple<std::shared_ptr<double>, int> >::type>();
+ StlContainerView<std::tuple<std::shared_ptr<double>, int>>::type>();
StaticAssertTypeEq<
const NativeArray<int>,
- StlContainerView<std::tuple<const int*, int> >::const_reference>();
+ StlContainerView<std::tuple<const int*, int>>::const_reference>();
- int a1[3] = { 0, 1, 2 };
+ int a1[3] = {0, 1, 2};
const int* const p1 = a1;
NativeArray<int> a2 =
- StlContainerView<std::tuple<const int*, int> >::ConstReference(
+ StlContainerView<std::tuple<const int*, int>>::ConstReference(
std::make_tuple(p1, 3));
EXPECT_EQ(3U, a2.size());
EXPECT_EQ(a1, a2.begin());
- const NativeArray<int> a3 = StlContainerView<std::tuple<int*, size_t> >::Copy(
+ const NativeArray<int> a3 = StlContainerView<std::tuple<int*, size_t>>::Copy(
std::make_tuple(static_cast<int*>(a1), 3));
ASSERT_EQ(3U, a3.size());
EXPECT_EQ(0, a3.begin()[0]);
diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc
index 6d480e0..06a5634 100644
--- a/googlemock/test/gmock-matchers_test.cc
+++ b/googlemock/test/gmock-matchers_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests some commonly used argument matchers.
@@ -35,9 +34,9 @@
// Silence warning C4244: 'initializing': conversion from 'int' to 'short',
// possible loss of data and C4100, unreferenced local parameter
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4244)
-# pragma warning(disable:4100)
+#pragma warning(push)
+#pragma warning(disable : 4244)
+#pragma warning(disable : 4100)
#endif
#include "gmock/gmock-matchers.h"
@@ -256,9 +255,7 @@ TEST(MatcherInterfaceTest, CanBeImplementedUsingNewAPI) {
}
// Tests default-constructing a matcher.
-TEST(MatcherTest, CanBeDefaultConstructed) {
- Matcher<double> m;
-}
+TEST(MatcherTest, CanBeDefaultConstructed) { Matcher<double> m; }
// Tests that Matcher<T> can be constructed from a MatcherInterface<T>*.
TEST(MatcherTest, CanBeConstructedFromMatcherInterface) {
@@ -315,8 +312,7 @@ TEST(MatcherTest, IsCopyable) {
// Tests that Matcher<T>::DescribeTo() calls
// MatcherInterface<T>::DescribeTo().
TEST(MatcherTest, CanDescribeItself) {
- EXPECT_EQ("is an even number",
- Describe(Matcher<int>(new EvenMatcherImpl)));
+ EXPECT_EQ("is an even number", Describe(Matcher<int>(new EvenMatcherImpl)));
}
// Tests Matcher<T>::MatchAndExplain().
@@ -421,8 +417,7 @@ const int g_bar = 1;
class ReferencesBarOrIsZeroImpl {
public:
template <typename T>
- bool MatchAndExplain(const T& x,
- MatchResultListener* /* listener */) const {
+ bool MatchAndExplain(const T& x, MatchResultListener* /* listener */) const {
const void* p = &x;
return p == &g_bar || x == 0;
}
@@ -462,9 +457,7 @@ class PolymorphicIsEvenImpl {
public:
void DescribeTo(ostream* os) const { *os << "is even"; }
- void DescribeNegationTo(ostream* os) const {
- *os << "is odd";
- }
+ void DescribeNegationTo(ostream* os) const { *os << "is odd"; }
template <typename T>
bool MatchAndExplain(const T& x, MatchResultListener* listener) const {
@@ -522,14 +515,13 @@ class IntValue {
explicit IntValue(int a_value) : value_(a_value) {}
int value() const { return value_; }
+
private:
int value_;
};
// For testing casting matchers between compatible types.
-bool IsPositiveIntValue(const IntValue& foo) {
- return foo.value() > 0;
-}
+bool IsPositiveIntValue(const IntValue& foo) { return foo.value() > 0; }
// Tests that MatcherCast<T>(m) works when m is a Matcher<U> where T
// can be statically converted to U.
@@ -709,6 +701,7 @@ class Base {
public:
virtual ~Base() {}
Base() {}
+
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(Base);
};
@@ -860,9 +853,7 @@ TEST(ATest, WorksForDerivedClass) {
}
// Tests that A<T>() describes itself properly.
-TEST(ATest, CanDescribeSelf) {
- EXPECT_EQ("is anything", Describe(A<bool>()));
-}
+TEST(ATest, CanDescribeSelf) { EXPECT_EQ("is anything", Describe(A<bool>())); }
// Tests that An<T>() matches any value of type T.
TEST(AnTest, MatchesAnyValue) {
@@ -880,9 +871,7 @@ TEST(AnTest, MatchesAnyValue) {
}
// Tests that An<T>() describes itself properly.
-TEST(AnTest, CanDescribeSelf) {
- EXPECT_EQ("is anything", Describe(An<int>()));
-}
+TEST(AnTest, CanDescribeSelf) { EXPECT_EQ("is anything", Describe(An<int>())); }
// Tests that _ can be used as a matcher for any type and matches any
// value of that type.
@@ -926,6 +915,7 @@ class Unprintable {
bool operator==(const Unprintable& /* rhs */) const { return true; }
// -Wunused-private-field: dummy accessor for `c_`.
char dummy_c() { return c_; }
+
private:
char c_;
};
@@ -978,8 +968,8 @@ struct Type {
TEST(TypedEqTest, HasSpecifiedType) {
// Verfies that the type of TypedEq<T>(v) is Matcher<T>.
- Type<Matcher<int> >::IsTypeOf(TypedEq<int>(5));
- Type<Matcher<double> >::IsTypeOf(TypedEq<double>(5));
+ Type<Matcher<int>>::IsTypeOf(TypedEq<int>(5));
+ Type<Matcher<double>>::IsTypeOf(TypedEq<double>(5));
}
// Tests that Ge(v) matches anything >= v.
@@ -1121,7 +1111,7 @@ TEST(IsNullTest, StdFunction) {
const Matcher<std::function<void()>> m = IsNull();
EXPECT_TRUE(m.Matches(std::function<void()>()));
- EXPECT_FALSE(m.Matches([]{}));
+ EXPECT_FALSE(m.Matches([] {}));
}
// Tests that IsNull() describes itself properly.
@@ -1166,7 +1156,7 @@ TEST(NotNullTest, ReferenceToConstLinkedPtr) {
TEST(NotNullTest, StdFunction) {
const Matcher<std::function<void()>> m = NotNull();
- EXPECT_TRUE(m.Matches([]{}));
+ EXPECT_TRUE(m.Matches([] {}));
EXPECT_FALSE(m.Matches(std::function<void()>()));
}
@@ -1281,7 +1271,7 @@ TEST(StrEqTest, MatchesEqualString) {
TEST(StrEqTest, CanDescribeSelf) {
Matcher<std::string> m = StrEq("Hi-\'\"?\\\a\b\f\n\r\t\v\xD3");
EXPECT_EQ("is equal to \"Hi-\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\xD3\"",
- Describe(m));
+ Describe(m));
std::string str("01204500800");
str[3] = '\0';
@@ -1459,7 +1449,7 @@ TEST(KeyTest, CanDescribeSelf) {
}
TEST(KeyTest, ExplainsResult) {
- Matcher<pair<int, bool> > m = Key(GreaterThan(10));
+ Matcher<pair<int, bool>> m = Key(GreaterThan(10));
EXPECT_EQ("whose first field is a value which is 5 less than 10",
Explain(m, make_pair(5, true)));
EXPECT_EQ("whose first field is a value which is 5 more than 10",
@@ -1542,32 +1532,35 @@ TEST(KeyTest, InsideContainsUsingMultimap) {
TEST(PairTest, Typing) {
// Test verifies the following type conversions can be compiled.
Matcher<const pair<const char*, int>&> m1 = Pair("foo", 42);
- Matcher<const pair<const char*, int> > m2 = Pair("foo", 42);
- Matcher<pair<const char*, int> > m3 = Pair("foo", 42);
+ Matcher<const pair<const char*, int>> m2 = Pair("foo", 42);
+ Matcher<pair<const char*, int>> m3 = Pair("foo", 42);
- Matcher<pair<int, const std::string> > m4 = Pair(25, "42");
- Matcher<pair<const std::string, int> > m5 = Pair("25", 42);
+ Matcher<pair<int, const std::string>> m4 = Pair(25, "42");
+ Matcher<pair<const std::string, int>> m5 = Pair("25", 42);
}
TEST(PairTest, CanDescribeSelf) {
Matcher<const pair<std::string, int>&> m1 = Pair("foo", 42);
- EXPECT_EQ("has a first field that is equal to \"foo\""
- ", and has a second field that is equal to 42",
- Describe(m1));
- EXPECT_EQ("has a first field that isn't equal to \"foo\""
- ", or has a second field that isn't equal to 42",
- DescribeNegation(m1));
+ EXPECT_EQ(
+ "has a first field that is equal to \"foo\""
+ ", and has a second field that is equal to 42",
+ Describe(m1));
+ EXPECT_EQ(
+ "has a first field that isn't equal to \"foo\""
+ ", or has a second field that isn't equal to 42",
+ DescribeNegation(m1));
// Double and triple negation (1 or 2 times not and description of negation).
Matcher<const pair<int, int>&> m2 = Not(Pair(Not(13), 42));
- EXPECT_EQ("has a first field that isn't equal to 13"
- ", and has a second field that is equal to 42",
- DescribeNegation(m2));
+ EXPECT_EQ(
+ "has a first field that isn't equal to 13"
+ ", and has a second field that is equal to 42",
+ DescribeNegation(m2));
}
TEST(PairTest, CanExplainMatchResultTo) {
// If neither field matches, Pair() should explain about the first
// field.
- const Matcher<pair<int, int> > m = Pair(GreaterThan(0), GreaterThan(0));
+ const Matcher<pair<int, int>> m = Pair(GreaterThan(0), GreaterThan(0));
EXPECT_EQ("whose first field does not match, which is 1 less than 0",
Explain(m, make_pair(-1, -2)));
@@ -1582,24 +1575,27 @@ TEST(PairTest, CanExplainMatchResultTo) {
Explain(m, make_pair(-1, 2)));
// If both fields match, Pair() should explain about them both.
- EXPECT_EQ("whose both fields match, where the first field is a value "
- "which is 1 more than 0, and the second field is a value "
- "which is 2 more than 0",
- Explain(m, make_pair(1, 2)));
+ EXPECT_EQ(
+ "whose both fields match, where the first field is a value "
+ "which is 1 more than 0, and the second field is a value "
+ "which is 2 more than 0",
+ Explain(m, make_pair(1, 2)));
// If only the first match has an explanation, only this explanation should
// be printed.
- const Matcher<pair<int, int> > explain_first = Pair(GreaterThan(0), 0);
- EXPECT_EQ("whose both fields match, where the first field is a value "
- "which is 1 more than 0",
- Explain(explain_first, make_pair(1, 0)));
+ const Matcher<pair<int, int>> explain_first = Pair(GreaterThan(0), 0);
+ EXPECT_EQ(
+ "whose both fields match, where the first field is a value "
+ "which is 1 more than 0",
+ Explain(explain_first, make_pair(1, 0)));
// If only the second match has an explanation, only this explanation should
// be printed.
- const Matcher<pair<int, int> > explain_second = Pair(0, GreaterThan(0));
- EXPECT_EQ("whose both fields match, where the second field is a value "
- "which is 1 more than 0",
- Explain(explain_second, make_pair(0, 1)));
+ const Matcher<pair<int, int>> explain_second = Pair(0, GreaterThan(0));
+ EXPECT_EQ(
+ "whose both fields match, where the second field is a value "
+ "which is 1 more than 0",
+ Explain(explain_second, make_pair(0, 1)));
}
TEST(PairTest, MatchesCorrectly) {
@@ -1946,8 +1942,7 @@ TEST(ContainsRegexTest, MatchesStringContainingGivenRegex) {
EXPECT_FALSE(m2.Matches("1a"));
#if GTEST_INTERNAL_HAS_STRING_VIEW
- const Matcher<const internal::StringView&> m3 =
- ContainsRegex(new RE("a.*z"));
+ const Matcher<const internal::StringView&> m3 = ContainsRegex(new RE("a.*z"));
EXPECT_TRUE(m3.Matches(internal::StringView("azbz")));
EXPECT_TRUE(m3.Matches(internal::StringView("az1")));
EXPECT_FALSE(m3.Matches(internal::StringView("1a")));
@@ -1998,13 +1993,12 @@ TEST(StdWideStrEqTest, MatchesEqual) {
}
TEST(StdWideStrEqTest, CanDescribeSelf) {
- Matcher< ::std::wstring> m = StrEq(L"Hi-\'\"?\\\a\b\f\n\r\t\v");
+ Matcher<::std::wstring> m = StrEq(L"Hi-\'\"?\\\a\b\f\n\r\t\v");
EXPECT_EQ("is equal to L\"Hi-\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\"",
- Describe(m));
+ Describe(m));
- Matcher< ::std::wstring> m2 = StrEq(L"\xD3\x576\x8D3\xC74D");
- EXPECT_EQ("is equal to L\"\\xD3\\x576\\x8D3\\xC74D\"",
- Describe(m2));
+ Matcher<::std::wstring> m2 = StrEq(L"\xD3\x576\x8D3\xC74D");
+ EXPECT_EQ("is equal to L\"\\xD3\\x576\\x8D3\\xC74D\"", Describe(m2));
::std::wstring str(L"01204500800");
str[3] = L'\0';
@@ -2021,7 +2015,7 @@ TEST(StdWideStrNeTest, MatchesUnequalString) {
EXPECT_TRUE(m.Matches(nullptr));
EXPECT_FALSE(m.Matches(L"Hello"));
- Matcher< ::std::wstring> m2 = StrNe(::std::wstring(L"Hello"));
+ Matcher<::std::wstring> m2 = StrNe(::std::wstring(L"Hello"));
EXPECT_TRUE(m2.Matches(L"hello"));
EXPECT_FALSE(m2.Matches(L"Hello"));
}
@@ -2069,7 +2063,7 @@ TEST(StdWideStrCaseEqTest, MatchesEqualStringWith0IgnoringCase) {
}
TEST(StdWideStrCaseEqTest, CanDescribeSelf) {
- Matcher< ::std::wstring> m = StrCaseEq(L"Hi");
+ Matcher<::std::wstring> m = StrCaseEq(L"Hi");
EXPECT_EQ("is equal to (ignoring case) L\"Hi\"", Describe(m));
}
@@ -2080,7 +2074,7 @@ TEST(StdWideStrCaseNeTest, MatchesUnequalStringIgnoringCase) {
EXPECT_FALSE(m.Matches(L"Hello"));
EXPECT_FALSE(m.Matches(L"hello"));
- Matcher< ::std::wstring> m2 = StrCaseNe(::std::wstring(L"Hello"));
+ Matcher<::std::wstring> m2 = StrCaseNe(::std::wstring(L"Hello"));
EXPECT_TRUE(m2.Matches(L""));
EXPECT_FALSE(m2.Matches(L"Hello"));
}
@@ -2092,7 +2086,7 @@ TEST(StdWideStrCaseNeTest, CanDescribeSelf) {
// Tests that HasSubstr() works for matching wstring-typed values.
TEST(StdWideHasSubstrTest, WorksForStringClasses) {
- const Matcher< ::std::wstring> m1 = HasSubstr(L"foo");
+ const Matcher<::std::wstring> m1 = HasSubstr(L"foo");
EXPECT_TRUE(m1.Matches(::std::wstring(L"I love food.")));
EXPECT_FALSE(m1.Matches(::std::wstring(L"tofo")));
@@ -2116,7 +2110,7 @@ TEST(StdWideHasSubstrTest, WorksForCStrings) {
// Tests that HasSubstr(s) describes itself properly.
TEST(StdWideHasSubstrTest, CanDescribeSelf) {
- Matcher< ::std::wstring> m = HasSubstr(L"foo\n\"");
+ Matcher<::std::wstring> m = HasSubstr(L"foo\n\"");
EXPECT_EQ("has substring L\"foo\\n\\\"\"", Describe(m));
}
@@ -2586,10 +2580,10 @@ TEST(AllOfTest, MatchesWhenAllMatch) {
AllOfMatches(5, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5)));
AllOfMatches(6, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6)));
AllOfMatches(7, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7)));
- AllOfMatches(8, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7),
- Ne(8)));
- AllOfMatches(9, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7),
- Ne(8), Ne(9)));
+ AllOfMatches(8,
+ AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8)));
+ AllOfMatches(
+ 9, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8), Ne(9)));
AllOfMatches(10, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8),
Ne(9), Ne(10)));
AllOfMatches(
@@ -2602,7 +2596,6 @@ TEST(AllOfTest, MatchesWhenAllMatch) {
Ne(50)));
}
-
// Tests that AllOf(m1, ..., mn) describes itself properly.
TEST(AllOfTest, CanDescribeSelf) {
Matcher<int> m;
@@ -2694,9 +2687,10 @@ TEST(AllOfTest, ExplainsResult) {
// Successful match. All matchers need to explain.
m = AllOf(GreaterThan(10), GreaterThan(20), GreaterThan(30));
- EXPECT_EQ("which is 30 more than 10, and which is 20 more than 20, "
- "and which is 10 more than 30",
- Explain(m, 40));
+ EXPECT_EQ(
+ "which is 30 more than 10, and which is 20 more than 20, "
+ "and which is 10 more than 30",
+ Explain(m, 40));
// Failed match. The first matcher, which failed, needs to
// explain.
@@ -2786,11 +2780,10 @@ TEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {
EXPECT_THAT(Describe(m), EndsWith("or (is equal to 11)"));
AnyOfMatches(11, m);
- AnyOfMatches(50, AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
- 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
- 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
- 41, 42, 43, 44, 45, 46, 47, 48, 49, 50));
+ AnyOfMatches(50, AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
+ 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50));
AnyOfStringMatches(
50, AnyOf("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
"13", "14", "15", "16", "17", "18", "19", "20", "21", "22",
@@ -2854,14 +2847,12 @@ TEST(ElementsAreTest, HugeMatcherUnordered) {
Eq(3), Eq(9), Eq(12), Eq(11), Ne(122)));
}
-
// Tests that AnyOf(m1, ..., mn) describes itself properly.
TEST(AnyOfTest, CanDescribeSelf) {
Matcher<int> m;
m = AnyOf(Le(1), Ge(3));
- EXPECT_EQ("(is <= 1) or (is >= 3)",
- Describe(m));
+ EXPECT_EQ("(is <= 1) or (is >= 3)", Describe(m));
m = AnyOf(Lt(0), Eq(1), Eq(2));
EXPECT_EQ("(is < 0) or (is equal to 1) or (is equal to 2)", Describe(m));
@@ -2881,8 +2872,7 @@ TEST(AnyOfTest, CanDescribeSelf) {
TEST(AnyOfTest, CanDescribeNegation) {
Matcher<int> m;
m = AnyOf(Le(1), Ge(3));
- EXPECT_EQ("(isn't <= 1) and (isn't >= 3)",
- DescribeNegation(m));
+ EXPECT_EQ("(isn't <= 1) and (isn't >= 3)", DescribeNegation(m));
m = AnyOf(Lt(0), Eq(1), Eq(2));
EXPECT_EQ("(isn't < 0) and (isn't equal to 1) and (isn't equal to 2)",
@@ -2938,9 +2928,10 @@ TEST(AnyOfTest, ExplainsResult) {
// Failed match. All matchers need to explain.
m = AnyOf(GreaterThan(10), GreaterThan(20), GreaterThan(30));
- EXPECT_EQ("which is 5 less than 10, and which is 15 less than 20, "
- "and which is 25 less than 30",
- Explain(m, 5));
+ EXPECT_EQ(
+ "which is 5 less than 10, and which is 15 less than 20, "
+ "and which is 25 less than 30",
+ Explain(m, 5));
// Successful match. The first matcher, which succeeded, needs to
// explain.
@@ -2966,9 +2957,7 @@ TEST(AnyOfTest, ExplainsResult) {
// type of this function is not bool. It's OK as Truly() accepts any
// unary function or functor whose return type can be implicitly
// converted to bool.
-int IsPositive(double x) {
- return x > 0 ? 1 : 0;
-}
+int IsPositive(double x) { return x > 0 ? 1 : 0; }
// This functor returns true if the input is greater than the given
// number.
@@ -2987,9 +2976,7 @@ const int foo = 0;
// This predicate returns true if and only if the argument references foo and
// has a zero value.
-bool ReferencesFooAndIsZero(const int& n) {
- return (&n == &foo) && (n == 0);
-}
+bool ReferencesFooAndIsZero(const int& n) { return (&n == &foo) && (n == 0); }
// Tests that Truly(predicate) matches what satisfies the given
// predicate.
@@ -3016,9 +3003,7 @@ class ConvertibleToBool {
int number_;
};
-ConvertibleToBool IsNotZero(int number) {
- return ConvertibleToBool(number);
-}
+ConvertibleToBool IsNotZero(int number) { return ConvertibleToBool(number); }
// Tests that the predicate used in Truly() may return a class that's
// implicitly convertible to bool, even when the class has no
@@ -3032,8 +3017,7 @@ TEST(TrulyTest, PredicateCanReturnAClassConvertibleToBool) {
// Tests that Truly(predicate) can describe itself properly.
TEST(TrulyTest, CanDescribeSelf) {
Matcher<double> m = Truly(IsPositive);
- EXPECT_EQ("satisfies the given predicate",
- Describe(m));
+ EXPECT_EQ("satisfies the given predicate", Describe(m));
}
// Tests that Truly(predicate) works when the matcher takes its
@@ -3189,13 +3173,9 @@ class AllArgsHelper {
TEST(AllArgsTest, WorksInWithClause) {
AllArgsHelper helper;
- ON_CALL(helper, Helper(_, _))
- .With(AllArgs(Lt()))
- .WillByDefault(Return(1));
+ ON_CALL(helper, Helper(_, _)).With(AllArgs(Lt())).WillByDefault(Return(1));
EXPECT_CALL(helper, Helper(_, _));
- EXPECT_CALL(helper, Helper(_, _))
- .With(AllArgs(Gt()))
- .WillOnce(Return(2));
+ EXPECT_CALL(helper, Helper(_, _)).With(AllArgs(Gt())).WillOnce(Return(2));
EXPECT_EQ(1, helper.Helper('\1', 2));
EXPECT_EQ(2, helper.Helper('a', 1));
@@ -3259,13 +3239,14 @@ TEST(MatcherAssertionTest, WorksWhenMatcherIsNotSatisfied) {
EXPECT_FATAL_FAILURE(ASSERT_THAT(n, Gt(10)),
"Value of: n\n"
"Expected: is > 10\n"
- " Actual: 5" + OfType("unsigned short"));
+ " Actual: 5" +
+ OfType("unsigned short"));
n = 0;
- EXPECT_NONFATAL_FAILURE(
- EXPECT_THAT(n, AllOf(Le(7), Ge(5))),
- "Value of: n\n"
- "Expected: (is <= 7) and (is >= 5)\n"
- " Actual: 0" + OfType("unsigned short"));
+ EXPECT_NONFATAL_FAILURE(EXPECT_THAT(n, AllOf(Le(7), Ge(5))),
+ "Value of: n\n"
+ "Expected: (is <= 7) and (is >= 5)\n"
+ " Actual: 0" +
+ OfType("unsigned short"));
}
// Tests that ASSERT_THAT() and EXPECT_THAT() work when the argument
@@ -3301,7 +3282,8 @@ TEST(MatcherAssertionTest, WorksForMonomorphicMatcher) {
EXPECT_NONFATAL_FAILURE(EXPECT_THAT(5, is_greater_than_5),
"Value of: 5\n"
"Expected: is > 5\n"
- " Actual: 5" + OfType("int"));
+ " Actual: 5" +
+ OfType("int"));
}
// Tests floating-point matchers.
@@ -3317,11 +3299,11 @@ class FloatingPointTest : public testing::Test {
one_bits_(Floating(1).bits()),
infinity_bits_(Floating(Floating::Infinity()).bits()),
close_to_positive_zero_(
- Floating::ReinterpretBits(zero_bits_ + max_ulps_/2)),
+ Floating::ReinterpretBits(zero_bits_ + max_ulps_ / 2)),
close_to_negative_zero_(
- -Floating::ReinterpretBits(zero_bits_ + max_ulps_ - max_ulps_/2)),
+ -Floating::ReinterpretBits(zero_bits_ + max_ulps_ - max_ulps_ / 2)),
further_from_negative_zero_(-Floating::ReinterpretBits(
- zero_bits_ + max_ulps_ + 1 - max_ulps_/2)),
+ zero_bits_ + max_ulps_ + 1 - max_ulps_ / 2)),
close_to_one_(Floating::ReinterpretBits(one_bits_ + max_ulps_)),
further_from_one_(Floating::ReinterpretBits(one_bits_ + max_ulps_ + 1)),
infinity_(Floating::Infinity()),
@@ -3331,12 +3313,9 @@ class FloatingPointTest : public testing::Test {
Floating::ReinterpretBits(infinity_bits_ - max_ulps_ - 1)),
max_(Floating::Max()),
nan1_(Floating::ReinterpretBits(Floating::kExponentBitMask | 1)),
- nan2_(Floating::ReinterpretBits(Floating::kExponentBitMask | 200)) {
- }
+ nan2_(Floating::ReinterpretBits(Floating::kExponentBitMask | 200)) {}
- void TestSize() {
- EXPECT_EQ(sizeof(RawType), sizeof(Bits));
- }
+ void TestSize() { EXPECT_EQ(sizeof(RawType), sizeof(Bits)); }
// A battery of tests for FloatingEqMatcher::Matches.
// matcher_maker is a pointer to a function which creates a FloatingEqMatcher.
@@ -3388,8 +3367,8 @@ class FloatingPointTest : public testing::Test {
const Bits max_ulps_;
- const Bits zero_bits_; // The bits that represent 0.0.
- const Bits one_bits_; // The bits that represent 1.0.
+ const Bits zero_bits_; // The bits that represent 0.0.
+ const Bits one_bits_; // The bits that represent 1.0.
const Bits infinity_bits_; // The bits that represent +infinity.
// Some numbers close to 0.0.
@@ -3422,9 +3401,8 @@ class FloatingPointNearTest : public FloatingPointTest<RawType> {
// A battery of tests for FloatingEqMatcher::Matches with a fixed epsilon.
// matcher_maker is a pointer to a function which creates a FloatingEqMatcher.
- void TestNearMatches(
- testing::internal::FloatingEqMatcher<RawType>
- (*matcher_maker)(RawType, RawType)) {
+ void TestNearMatches(testing::internal::FloatingEqMatcher<RawType> (
+ *matcher_maker)(RawType, RawType)) {
Matcher<RawType> m1 = matcher_maker(0.0, 0.0);
EXPECT_TRUE(m1.Matches(0.0));
EXPECT_TRUE(m1.Matches(-0.0));
@@ -3471,8 +3449,8 @@ class FloatingPointNearTest : public FloatingPointTest<RawType> {
// The difference between max() and -max() normally overflows to infinity,
// but it should still match if the max_abs_error is also infinity.
- Matcher<RawType> m9 = matcher_maker(
- ParentType::max_, ParentType::infinity_);
+ Matcher<RawType> m9 =
+ matcher_maker(ParentType::max_, ParentType::infinity_);
EXPECT_TRUE(m8.Matches(-ParentType::max_));
// matcher_maker can produce a Matcher<const RawType&>, which is needed in
@@ -3501,9 +3479,7 @@ class FloatingPointNearTest : public FloatingPointTest<RawType> {
// Instantiate FloatingPointTest for testing floats.
typedef FloatingPointTest<float> FloatTest;
-TEST_F(FloatTest, FloatEqApproximatelyMatchesFloats) {
- TestMatches(&FloatEq);
-}
+TEST_F(FloatTest, FloatEqApproximatelyMatchesFloats) { TestMatches(&FloatEq); }
TEST_F(FloatTest, NanSensitiveFloatEqApproximatelyMatchesFloats) {
TestMatches(&NanSensitiveFloatEq);
@@ -3557,9 +3533,7 @@ TEST_F(FloatTest, NanSensitiveFloatEqCanDescribeSelf) {
// max absolute error.
typedef FloatingPointNearTest<float> FloatNearTest;
-TEST_F(FloatNearTest, FloatNearMatches) {
- TestNearMatches(&FloatNear);
-}
+TEST_F(FloatNearTest, FloatNearMatches) { TestNearMatches(&FloatNear); }
TEST_F(FloatNearTest, NanSensitiveFloatNearApproximatelyMatchesFloats) {
TestNearMatches(&NanSensitiveFloatNear);
@@ -3568,13 +3542,13 @@ TEST_F(FloatNearTest, NanSensitiveFloatNearApproximatelyMatchesFloats) {
TEST_F(FloatNearTest, FloatNearCanDescribeSelf) {
Matcher<float> m1 = FloatNear(2.0f, 0.5f);
EXPECT_EQ("is approximately 2 (absolute error <= 0.5)", Describe(m1));
- EXPECT_EQ(
- "isn't approximately 2 (absolute error > 0.5)", DescribeNegation(m1));
+ EXPECT_EQ("isn't approximately 2 (absolute error > 0.5)",
+ DescribeNegation(m1));
Matcher<float> m2 = FloatNear(0.5f, 0.5f);
EXPECT_EQ("is approximately 0.5 (absolute error <= 0.5)", Describe(m2));
- EXPECT_EQ(
- "isn't approximately 0.5 (absolute error > 0.5)", DescribeNegation(m2));
+ EXPECT_EQ("isn't approximately 0.5 (absolute error > 0.5)",
+ DescribeNegation(m2));
Matcher<float> m3 = FloatNear(nan1_, 0.0);
EXPECT_EQ("never matches", Describe(m3));
@@ -3584,13 +3558,13 @@ TEST_F(FloatNearTest, FloatNearCanDescribeSelf) {
TEST_F(FloatNearTest, NanSensitiveFloatNearCanDescribeSelf) {
Matcher<float> m1 = NanSensitiveFloatNear(2.0f, 0.5f);
EXPECT_EQ("is approximately 2 (absolute error <= 0.5)", Describe(m1));
- EXPECT_EQ(
- "isn't approximately 2 (absolute error > 0.5)", DescribeNegation(m1));
+ EXPECT_EQ("isn't approximately 2 (absolute error > 0.5)",
+ DescribeNegation(m1));
Matcher<float> m2 = NanSensitiveFloatNear(0.5f, 0.5f);
EXPECT_EQ("is approximately 0.5 (absolute error <= 0.5)", Describe(m2));
- EXPECT_EQ(
- "isn't approximately 0.5 (absolute error > 0.5)", DescribeNegation(m2));
+ EXPECT_EQ("isn't approximately 0.5 (absolute error > 0.5)",
+ DescribeNegation(m2));
Matcher<float> m3 = NanSensitiveFloatNear(nan1_, 0.1f);
EXPECT_EQ("is NaN", Describe(m3));
@@ -3672,9 +3646,7 @@ TEST_F(DoubleTest, NanSensitiveDoubleEqCanDescribeSelf) {
// max absolute error.
typedef FloatingPointNearTest<double> DoubleNearTest;
-TEST_F(DoubleNearTest, DoubleNearMatches) {
- TestNearMatches(&DoubleNear);
-}
+TEST_F(DoubleNearTest, DoubleNearMatches) { TestNearMatches(&DoubleNear); }
TEST_F(DoubleNearTest, NanSensitiveDoubleNearApproximatelyMatchesDoubles) {
TestNearMatches(&NanSensitiveDoubleNear);
@@ -3683,13 +3655,13 @@ TEST_F(DoubleNearTest, NanSensitiveDoubleNearApproximatelyMatchesDoubles) {
TEST_F(DoubleNearTest, DoubleNearCanDescribeSelf) {
Matcher<double> m1 = DoubleNear(2.0, 0.5);
EXPECT_EQ("is approximately 2 (absolute error <= 0.5)", Describe(m1));
- EXPECT_EQ(
- "isn't approximately 2 (absolute error > 0.5)", DescribeNegation(m1));
+ EXPECT_EQ("isn't approximately 2 (absolute error > 0.5)",
+ DescribeNegation(m1));
Matcher<double> m2 = DoubleNear(0.5, 0.5);
EXPECT_EQ("is approximately 0.5 (absolute error <= 0.5)", Describe(m2));
- EXPECT_EQ(
- "isn't approximately 0.5 (absolute error > 0.5)", DescribeNegation(m2));
+ EXPECT_EQ("isn't approximately 0.5 (absolute error > 0.5)",
+ DescribeNegation(m2));
Matcher<double> m3 = DoubleNear(nan1_, 0.0);
EXPECT_EQ("never matches", Describe(m3));
@@ -3713,13 +3685,13 @@ TEST_F(DoubleNearTest, ExplainsResultWhenMatchFails) {
TEST_F(DoubleNearTest, NanSensitiveDoubleNearCanDescribeSelf) {
Matcher<double> m1 = NanSensitiveDoubleNear(2.0, 0.5);
EXPECT_EQ("is approximately 2 (absolute error <= 0.5)", Describe(m1));
- EXPECT_EQ(
- "isn't approximately 2 (absolute error > 0.5)", DescribeNegation(m1));
+ EXPECT_EQ("isn't approximately 2 (absolute error > 0.5)",
+ DescribeNegation(m1));
Matcher<double> m2 = NanSensitiveDoubleNear(0.5, 0.5);
EXPECT_EQ("is approximately 0.5 (absolute error <= 0.5)", Describe(m2));
- EXPECT_EQ(
- "isn't approximately 0.5 (absolute error > 0.5)", DescribeNegation(m2));
+ EXPECT_EQ("isn't approximately 0.5 (absolute error > 0.5)",
+ DescribeNegation(m2));
Matcher<double> m3 = NanSensitiveDoubleNear(nan1_, 0.1);
EXPECT_EQ("is NaN", Describe(m3));
@@ -3763,7 +3735,7 @@ TEST(PointeeTest, RawPointerToConst) {
}
TEST(PointeeTest, ReferenceToConstRawPointer) {
- const Matcher<int* const &> m = Pointee(Ge(0));
+ const Matcher<int* const&> m = Pointee(Ge(0));
int n = 1;
EXPECT_TRUE(m.Matches(&n));
@@ -3773,7 +3745,7 @@ TEST(PointeeTest, ReferenceToConstRawPointer) {
}
TEST(PointeeTest, ReferenceToNonConstRawPointer) {
- const Matcher<double* &> m = Pointee(Ge(0));
+ const Matcher<double*&> m = Pointee(Ge(0));
double x = 1.0;
double* p = &x;
@@ -4002,7 +3974,7 @@ class ConstPropagatingPtr {
};
TEST(PointeeTest, WorksWithConstPropagatingPointers) {
- const Matcher< ConstPropagatingPtr<int> > m = Pointee(Lt(5));
+ const Matcher<ConstPropagatingPtr<int>> m = Pointee(Lt(5));
int three = 3;
const ConstPropagatingPtr<int> co(&three);
ConstPropagatingPtr<int> o(&three);
@@ -4032,8 +4004,7 @@ TEST(PointeeTest, MatchesAgainstAValue) {
TEST(PointeeTest, CanDescribeSelf) {
const Matcher<int*> m = Pointee(Gt(3));
EXPECT_EQ("points to a value that is > 3", Describe(m));
- EXPECT_EQ("does not point to a value that is > 3",
- DescribeNegation(m));
+ EXPECT_EQ("does not point to a value that is > 3", DescribeNegation(m));
}
TEST(PointeeTest, CanExplainMatchResult) {
@@ -4042,7 +4013,7 @@ TEST(PointeeTest, CanExplainMatchResult) {
EXPECT_EQ("", Explain(m, static_cast<const std::string*>(nullptr)));
const Matcher<long*> m2 = Pointee(GreaterThan(1)); // NOLINT
- long n = 3; // NOLINT
+ long n = 3; // NOLINT
EXPECT_EQ("which points to 3" + OfType("long") + ", which is 2 more than 1",
Explain(m2, &n));
}
@@ -4172,8 +4143,7 @@ TEST(FieldTest, WorksForArgumentOfSubType) {
// argument type are compatible but not the same.
TEST(FieldTest, WorksForCompatibleMatcherType) {
// The field is an int, but the inner matcher expects a signed char.
- Matcher<const AStruct&> m = Field(&AStruct::x,
- Matcher<signed char>(Ge(0)));
+ Matcher<const AStruct&> m = Field(&AStruct::x, Matcher<signed char>(Ge(0)));
AStruct a;
EXPECT_TRUE(m.Matches(a));
@@ -4301,7 +4271,8 @@ TEST(FieldForPointerTest, CanExplainMatchResult) {
m = Field(&AStruct::x, GreaterThan(0));
EXPECT_EQ("which points to an object whose given field is 1" + OfType("int") +
- ", which is 1 more than 0", Explain(m, &a));
+ ", which is 1 more than 0",
+ Explain(m, &a));
}
TEST(FieldForPointerTest, CanExplainMatchResultWithFieldName) {
@@ -4333,7 +4304,7 @@ class AClass {
// A getter that returns a reference to const.
const std::string& s() const { return s_; }
- const std::string& s_ref() const & { return s_; }
+ const std::string& s_ref() const& { return s_; }
void set_s(const std::string& new_s) { s_ = new_s; }
@@ -4353,6 +4324,7 @@ double AClass::x_ = 0.0;
class DerivedClass : public AClass {
public:
int k() const { return k_; }
+
private:
int k_;
};
@@ -4452,8 +4424,7 @@ TEST(PropertyTest, WorksForArgumentOfSubType) {
// and m's argument type are compatible but different.
TEST(PropertyTest, WorksForCompatibleMatcherType) {
// n() returns an int but the inner matcher expects a signed char.
- Matcher<const AClass&> m = Property(&AClass::n,
- Matcher<signed char>(Ge(0)));
+ Matcher<const AClass&> m = Property(&AClass::n, Matcher<signed char>(Ge(0)));
Matcher<const AClass&> m_with_name =
Property("n", &AClass::n, Matcher<signed char>(Ge(0)));
@@ -4598,7 +4569,7 @@ TEST(PropertyForPointerTest, CanExplainMatchResult) {
m = Property(&AClass::n, GreaterThan(0));
EXPECT_EQ("which points to an object whose given property is 1" +
- OfType("int") + ", which is 1 more than 0",
+ OfType("int") + ", which is 1 more than 0",
Explain(m, &a));
}
@@ -4637,10 +4608,14 @@ TEST(ResultOfTest, WorksForFunctionPointers) {
TEST(ResultOfTest, CanDescribeItself) {
Matcher<int> matcher = ResultOf(&IntToStringFunction, StrEq("foo"));
- EXPECT_EQ("is mapped by the given callable to a value that "
- "is equal to \"foo\"", Describe(matcher));
- EXPECT_EQ("is mapped by the given callable to a value that "
- "isn't equal to \"foo\"", DescribeNegation(matcher));
+ EXPECT_EQ(
+ "is mapped by the given callable to a value that "
+ "is equal to \"foo\"",
+ Describe(matcher));
+ EXPECT_EQ(
+ "is mapped by the given callable to a value that "
+ "isn't equal to \"foo\"",
+ DescribeNegation(matcher));
}
// Tests that ResultOf() can describe itself when provided a result description.
@@ -4663,7 +4638,8 @@ TEST(ResultOfTest, CanExplainMatchResult) {
matcher = ResultOf(&IntFunction, GreaterThan(85));
EXPECT_EQ("which is mapped by the given callable to 90" + OfType("int") +
- ", which is 5 more than 85", Explain(matcher, 36));
+ ", which is 5 more than 85",
+ Explain(matcher, 36));
}
// Tests that ResultOf(f, ...) compiles and works as expected when f(x)
@@ -4694,8 +4670,7 @@ TEST(ResultOfTest, WorksForReferenceToNonConstResults) {
// Test that ResultOf works with uncopyable objects
Uncopyable obj(0);
Uncopyable obj2(0);
- Matcher<Uncopyable&> matcher2 =
- ResultOf(&RefUncopyableFunction, Ref(obj));
+ Matcher<Uncopyable&> matcher2 = ResultOf(&RefUncopyableFunction, Ref(obj));
EXPECT_TRUE(matcher2.Matches(obj));
EXPECT_FALSE(matcher2.Matches(obj2));
@@ -4744,9 +4719,7 @@ TEST(ResultOfTest, WorksForFunctionReferences) {
// Tests that ResultOf(f, ...) compiles and works as expected when f is a
// function object.
struct Functor {
- std::string operator()(int input) const {
- return IntToStringFunction(input);
- }
+ std::string operator()(int input) const { return IntToStringFunction(input); }
};
TEST(ResultOfTest, WorksForFunctors) {
@@ -4763,7 +4736,7 @@ struct PolymorphicFunctor {
typedef int result_type;
int operator()(int n) { return n; }
int operator()(const char* s) { return static_cast<int>(strlen(s)); }
- std::string operator()(int *p) { return p ? "good ptr" : "null"; }
+ std::string operator()(int* p) { return p ? "good ptr" : "null"; }
};
TEST(ResultOfTest, WorksForPolymorphicFunctors) {
@@ -4832,14 +4805,11 @@ class DivisibleByImpl {
// For testing using ExplainMatchResultTo() with polymorphic matchers.
template <typename T>
bool MatchAndExplain(const T& n, MatchResultListener* listener) const {
- *listener << "which is " << (n % divider_) << " modulo "
- << divider_;
+ *listener << "which is " << (n % divider_) << " modulo " << divider_;
return (n % divider_) == 0;
}
- void DescribeTo(ostream* os) const {
- *os << "is divisible by " << divider_;
- }
+ void DescribeTo(ostream* os) const { *os << "is divisible by " << divider_; }
void DescribeNegationTo(ostream* os) const {
*os << "is not divisible by " << divider_;
@@ -4911,6 +4881,7 @@ class NotCopyable {
bool operator>=(const NotCopyable& rhs) const {
return value() >= rhs.value();
}
+
private:
int value_;
@@ -4954,13 +4925,13 @@ TEST(IsEmptyTest, WorksWithString) {
}
TEST(IsEmptyTest, CanDescribeSelf) {
- Matcher<vector<int> > m = IsEmpty();
+ Matcher<vector<int>> m = IsEmpty();
EXPECT_EQ("is empty", Describe(m));
EXPECT_EQ("isn't empty", DescribeNegation(m));
}
TEST(IsEmptyTest, ExplainsResult) {
- Matcher<vector<int> > m = IsEmpty();
+ Matcher<vector<int>> m = IsEmpty();
vector<int> container;
EXPECT_EQ("", Explain(m, container));
container.push_back(0);
@@ -5059,16 +5030,16 @@ TEST(SizeIsTest, WorksWithMinimalistCustomType) {
}
TEST(SizeIsTest, CanDescribeSelf) {
- Matcher<vector<int> > m = SizeIs(2);
+ Matcher<vector<int>> m = SizeIs(2);
EXPECT_EQ("size is equal to 2", Describe(m));
EXPECT_EQ("size isn't equal to 2", DescribeNegation(m));
}
TEST(SizeIsTest, ExplainsResult) {
- Matcher<vector<int> > m1 = SizeIs(2);
- Matcher<vector<int> > m2 = SizeIs(Lt(2u));
- Matcher<vector<int> > m3 = SizeIs(AnyOf(0, 3));
- Matcher<vector<int> > m4 = SizeIs(Gt(1u));
+ Matcher<vector<int>> m1 = SizeIs(2);
+ Matcher<vector<int>> m2 = SizeIs(Lt(2u));
+ Matcher<vector<int>> m3 = SizeIs(AnyOf(0, 3));
+ Matcher<vector<int>> m4 = SizeIs(Gt(1u));
vector<int> container;
EXPECT_EQ("whose size 0 doesn't match", Explain(m1, container));
EXPECT_EQ("whose size 0 matches", Explain(m2, container));
@@ -5089,11 +5060,7 @@ TEST(SizeIsTest, ExplainsResult) {
template <typename T>
class ContainerEqTest : public testing::Test {};
-typedef testing::Types<
- set<int>,
- vector<size_t>,
- multiset<size_t>,
- list<int> >
+typedef testing::Types<set<int>, vector<size_t>, multiset<size_t>, list<int>>
ContainerEqTestTypes;
TYPED_TEST_SUITE(ContainerEqTest, ContainerEqTestTypes);
@@ -5138,9 +5105,10 @@ TYPED_TEST(ContainerEqTest, ValueAddedAndRemoved) {
TypeParam test_set(test_vals, test_vals + 5);
const Matcher<TypeParam> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
- EXPECT_EQ("which has these unexpected elements: 46,\n"
- "and doesn't have these expected elements: 5",
- Explain(m, test_set));
+ EXPECT_EQ(
+ "which has these unexpected elements: 46,\n"
+ "and doesn't have these expected elements: 5",
+ Explain(m, test_set));
}
// Tests duplicated value -- expect no explanation.
@@ -5163,7 +5131,7 @@ TEST(ContainerEqExtraTest, MultipleValuesMissing) {
static const int test_vals[] = {2, 1, 5};
vector<int> my_set(vals, vals + 6);
vector<int> test_set(test_vals, test_vals + 3);
- const Matcher<vector<int> > m = ContainerEq(my_set);
+ const Matcher<vector<int>> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
EXPECT_EQ("which doesn't have these expected elements: 3, 8",
Explain(m, test_set));
@@ -5188,11 +5156,12 @@ TEST(ContainerEqExtraTest, MultipleValuesAddedAndRemoved) {
static const int test_vals[] = {1, 2, 3, 92, 46};
list<size_t> my_set(vals, vals + 6);
list<size_t> test_set(test_vals, test_vals + 5);
- const Matcher<const list<size_t> > m = ContainerEq(my_set);
+ const Matcher<const list<size_t>> m = ContainerEq(my_set);
EXPECT_FALSE(m.Matches(test_set));
- EXPECT_EQ("which has these unexpected elements: 92, 46,\n"
- "and doesn't have these expected elements: 5, 8",
- Explain(m, test_set));
+ EXPECT_EQ(
+ "which has these unexpected elements: 92, 46,\n"
+ "and doesn't have these expected elements: 5, 8",
+ Explain(m, test_set));
}
// Tests to see that duplicate elements are detected,
@@ -5202,7 +5171,7 @@ TEST(ContainerEqExtraTest, MultiSetOfIntDuplicateDifference) {
static const int test_vals[] = {1, 2, 3, 5, 8};
vector<int> my_set(vals, vals + 6);
vector<int> test_set(test_vals, test_vals + 5);
- const Matcher<vector<int> > m = ContainerEq(my_set);
+ const Matcher<vector<int>> m = ContainerEq(my_set);
EXPECT_TRUE(m.Matches(my_set));
EXPECT_FALSE(m.Matches(test_set));
// There is nothing to report when both sets contain all the same values.
@@ -5224,9 +5193,10 @@ TEST(ContainerEqExtraTest, WorksForMaps) {
EXPECT_TRUE(m.Matches(my_map));
EXPECT_FALSE(m.Matches(test_map));
- EXPECT_EQ("which has these unexpected elements: (0, \"aa\"),\n"
- "and doesn't have these expected elements: (0, \"a\")",
- Explain(m, test_map));
+ EXPECT_EQ(
+ "which has these unexpected elements: (0, \"aa\"),\n"
+ "and doesn't have these expected elements: (0, \"a\")",
+ Explain(m, test_map));
}
TEST(ContainerEqExtraTest, WorksForNativeArray) {
@@ -5266,15 +5236,9 @@ TEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) {
}
TEST(ContainerEqExtraTest, CopiesNativeArrayParameter) {
- std::string a1[][3] = {
- {"hi", "hello", "ciao"},
- {"bye", "see you", "ciao"}
- };
+ std::string a1[][3] = {{"hi", "hello", "ciao"}, {"bye", "see you", "ciao"}};
- std::string a2[][3] = {
- {"hi", "hello", "ciao"},
- {"bye", "see you", "ciao"}
- };
+ std::string a2[][3] = {{"hi", "hello", "ciao"}, {"bye", "see you", "ciao"}};
const Matcher<const std::string(&)[2][3]> m = ContainerEq(a2);
EXPECT_THAT(a1, m);
@@ -5295,10 +5259,10 @@ TEST(WhenSortedByTest, WorksForNonEmptyContainer) {
numbers.push_back(1);
numbers.push_back(2);
numbers.push_back(2);
- EXPECT_THAT(numbers, WhenSortedBy(greater<unsigned>(),
- ElementsAre(3, 2, 2, 1)));
- EXPECT_THAT(numbers, Not(WhenSortedBy(greater<unsigned>(),
- ElementsAre(1, 2, 2, 3))));
+ EXPECT_THAT(numbers,
+ WhenSortedBy(greater<unsigned>(), ElementsAre(3, 2, 2, 1)));
+ EXPECT_THAT(numbers,
+ Not(WhenSortedBy(greater<unsigned>(), ElementsAre(1, 2, 2, 3))));
}
TEST(WhenSortedByTest, WorksForNonVectorContainer) {
@@ -5316,21 +5280,23 @@ TEST(WhenSortedByTest, WorksForNativeArray) {
const int numbers[] = {1, 3, 2, 4};
const int sorted_numbers[] = {1, 2, 3, 4};
EXPECT_THAT(numbers, WhenSortedBy(less<int>(), ElementsAre(1, 2, 3, 4)));
- EXPECT_THAT(numbers, WhenSortedBy(less<int>(),
- ElementsAreArray(sorted_numbers)));
+ EXPECT_THAT(numbers,
+ WhenSortedBy(less<int>(), ElementsAreArray(sorted_numbers)));
EXPECT_THAT(numbers, Not(WhenSortedBy(less<int>(), ElementsAre(1, 3, 2, 4))));
}
TEST(WhenSortedByTest, CanDescribeSelf) {
- const Matcher<vector<int> > m = WhenSortedBy(less<int>(), ElementsAre(1, 2));
- EXPECT_EQ("(when sorted) has 2 elements where\n"
- "element #0 is equal to 1,\n"
- "element #1 is equal to 2",
- Describe(m));
- EXPECT_EQ("(when sorted) doesn't have 2 elements, or\n"
- "element #0 isn't equal to 1, or\n"
- "element #1 isn't equal to 2",
- DescribeNegation(m));
+ const Matcher<vector<int>> m = WhenSortedBy(less<int>(), ElementsAre(1, 2));
+ EXPECT_EQ(
+ "(when sorted) has 2 elements where\n"
+ "element #0 is equal to 1,\n"
+ "element #1 is equal to 2",
+ Describe(m));
+ EXPECT_EQ(
+ "(when sorted) doesn't have 2 elements, or\n"
+ "element #0 isn't equal to 1, or\n"
+ "element #1 isn't equal to 2",
+ DescribeNegation(m));
}
TEST(WhenSortedByTest, ExplainsMatchResult) {
@@ -5374,43 +5340,37 @@ TEST(WhenSortedTest, WorksForMapTypes) {
}
TEST(WhenSortedTest, WorksForMultiMapTypes) {
- multimap<int, int> ifib;
- ifib.insert(make_pair(8, 6));
- ifib.insert(make_pair(2, 3));
- ifib.insert(make_pair(1, 1));
- ifib.insert(make_pair(3, 4));
- ifib.insert(make_pair(1, 2));
- ifib.insert(make_pair(5, 5));
- EXPECT_THAT(ifib, WhenSorted(ElementsAre(Pair(1, 1),
- Pair(1, 2),
- Pair(2, 3),
- Pair(3, 4),
- Pair(5, 5),
- Pair(8, 6))));
- EXPECT_THAT(ifib, Not(WhenSorted(ElementsAre(Pair(8, 6),
- Pair(2, 3),
- Pair(1, 1),
- Pair(3, 4),
- Pair(1, 2),
- Pair(5, 5)))));
+ multimap<int, int> ifib;
+ ifib.insert(make_pair(8, 6));
+ ifib.insert(make_pair(2, 3));
+ ifib.insert(make_pair(1, 1));
+ ifib.insert(make_pair(3, 4));
+ ifib.insert(make_pair(1, 2));
+ ifib.insert(make_pair(5, 5));
+ EXPECT_THAT(ifib,
+ WhenSorted(ElementsAre(Pair(1, 1), Pair(1, 2), Pair(2, 3),
+ Pair(3, 4), Pair(5, 5), Pair(8, 6))));
+ EXPECT_THAT(ifib,
+ Not(WhenSorted(ElementsAre(Pair(8, 6), Pair(2, 3), Pair(1, 1),
+ Pair(3, 4), Pair(1, 2), Pair(5, 5)))));
}
TEST(WhenSortedTest, WorksForPolymorphicMatcher) {
- std::deque<int> d;
- d.push_back(2);
- d.push_back(1);
- EXPECT_THAT(d, WhenSorted(ElementsAre(1, 2)));
- EXPECT_THAT(d, Not(WhenSorted(ElementsAre(2, 1))));
+ std::deque<int> d;
+ d.push_back(2);
+ d.push_back(1);
+ EXPECT_THAT(d, WhenSorted(ElementsAre(1, 2)));
+ EXPECT_THAT(d, Not(WhenSorted(ElementsAre(2, 1))));
}
TEST(WhenSortedTest, WorksForVectorConstRefMatcher) {
- std::deque<int> d;
- d.push_back(2);
- d.push_back(1);
- Matcher<const std::vector<int>&> vector_match = ElementsAre(1, 2);
- EXPECT_THAT(d, WhenSorted(vector_match));
- Matcher<const std::vector<int>&> not_vector_match = ElementsAre(2, 1);
- EXPECT_THAT(d, Not(WhenSorted(not_vector_match)));
+ std::deque<int> d;
+ d.push_back(2);
+ d.push_back(1);
+ Matcher<const std::vector<int>&> vector_match = ElementsAre(1, 2);
+ EXPECT_THAT(d, WhenSorted(vector_match));
+ Matcher<const std::vector<int>&> not_vector_match = ElementsAre(2, 1);
+ EXPECT_THAT(d, Not(WhenSorted(not_vector_match)));
}
// Deliberately bare pseudo-container.
@@ -5419,6 +5379,7 @@ template <typename T>
class Streamlike {
private:
class ConstIter;
+
public:
typedef ConstIter const_iterator;
typedef T value_type;
@@ -5429,9 +5390,7 @@ class Streamlike {
const_iterator begin() const {
return const_iterator(this, remainder_.begin());
}
- const_iterator end() const {
- return const_iterator(this, remainder_.end());
- }
+ const_iterator end() const { return const_iterator(this, remainder_.end()); }
private:
class ConstIter {
@@ -5442,8 +5401,7 @@ class Streamlike {
using pointer = const value_type*;
using reference = const value_type&;
- ConstIter(const Streamlike* s,
- typename std::list<value_type>::iterator pos)
+ ConstIter(const Streamlike* s, typename std::list<value_type>::iterator pos)
: s_(s), pos_(pos) {}
const value_type& operator*() const { return *pos_; }
@@ -5459,6 +5417,7 @@ class Streamlike {
public:
explicit PostIncrProxy(const value_type& value) : value_(value) {}
value_type operator*() const { return value_; }
+
private:
value_type value_;
};
@@ -5525,7 +5484,7 @@ TEST(BeginEndDistanceIsTest, WorksWithNonStdList) {
}
TEST(BeginEndDistanceIsTest, CanDescribeSelf) {
- Matcher<vector<int> > m = BeginEndDistanceIs(2);
+ Matcher<vector<int>> m = BeginEndDistanceIs(2);
EXPECT_EQ("distance between begin() and end() is equal to 2", Describe(m));
EXPECT_EQ("distance between begin() and end() isn't equal to 2",
DescribeNegation(m));
@@ -5538,10 +5497,10 @@ TEST(BeginEndDistanceIsTest, WorksWithMoveOnly) {
}
TEST(BeginEndDistanceIsTest, ExplainsResult) {
- Matcher<vector<int> > m1 = BeginEndDistanceIs(2);
- Matcher<vector<int> > m2 = BeginEndDistanceIs(Lt(2));
- Matcher<vector<int> > m3 = BeginEndDistanceIs(AnyOf(0, 3));
- Matcher<vector<int> > m4 = BeginEndDistanceIs(GreaterThan(1));
+ Matcher<vector<int>> m1 = BeginEndDistanceIs(2);
+ Matcher<vector<int>> m2 = BeginEndDistanceIs(Lt(2));
+ Matcher<vector<int>> m3 = BeginEndDistanceIs(AnyOf(0, 3));
+ Matcher<vector<int>> m4 = BeginEndDistanceIs(GreaterThan(1));
vector<int> container;
EXPECT_EQ("whose distance between begin() and end() 0 doesn't match",
Explain(m1, container));
@@ -5902,8 +5861,8 @@ TEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) {
std::vector<int> s(std::begin(a), std::end(a));
do {
StringMatchResultListener listener;
- EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(a),
- s, &listener)) << listener.str();
+ EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(a), s, &listener))
+ << listener.str();
} while (std::next_permutation(s.begin(), s.end()));
}
@@ -5913,8 +5872,9 @@ TEST(UnorderedElementsAreArrayTest, VectorBool) {
std::vector<bool> expected(std::begin(a), std::end(a));
std::vector<bool> actual(std::begin(b), std::end(b));
StringMatchResultListener listener;
- EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(expected),
- actual, &listener)) << listener.str();
+ EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(expected), actual,
+ &listener))
+ << listener.str();
}
TEST(UnorderedElementsAreArrayTest, WorksForStreamlike) {
@@ -5949,7 +5909,6 @@ TEST(UnorderedElementsAreArrayTest, TakesStlContainer) {
EXPECT_THAT(actual, Not(UnorderedElementsAreArray(expected)));
}
-
TEST(UnorderedElementsAreArrayTest, TakesInitializerList) {
const int a[5] = {2, 1, 4, 5, 3};
EXPECT_THAT(a, UnorderedElementsAreArray({1, 2, 3, 4, 5}));
@@ -5964,10 +5923,10 @@ TEST(UnorderedElementsAreArrayTest, TakesInitializerListOfCStrings) {
TEST(UnorderedElementsAreArrayTest, TakesInitializerListOfSameTypedMatchers) {
const int a[5] = {2, 1, 4, 5, 3};
- EXPECT_THAT(a, UnorderedElementsAreArray(
- {Eq(1), Eq(2), Eq(3), Eq(4), Eq(5)}));
- EXPECT_THAT(a, Not(UnorderedElementsAreArray(
- {Eq(1), Eq(2), Eq(3), Eq(4), Eq(6)})));
+ EXPECT_THAT(a,
+ UnorderedElementsAreArray({Eq(1), Eq(2), Eq(3), Eq(4), Eq(5)}));
+ EXPECT_THAT(
+ a, Not(UnorderedElementsAreArray({Eq(1), Eq(2), Eq(3), Eq(4), Eq(6)})));
}
TEST(UnorderedElementsAreArrayTest,
@@ -5976,13 +5935,12 @@ TEST(UnorderedElementsAreArrayTest,
// The compiler cannot infer the type of the initializer list if its
// elements have different types. We must explicitly specify the
// unified element type in this case.
- EXPECT_THAT(a, UnorderedElementsAreArray<Matcher<int> >(
- {Eq(1), Ne(-2), Ge(3), Le(4), Eq(5)}));
- EXPECT_THAT(a, Not(UnorderedElementsAreArray<Matcher<int> >(
- {Eq(1), Ne(-2), Ge(3), Le(4), Eq(6)})));
+ EXPECT_THAT(a, UnorderedElementsAreArray<Matcher<int>>(
+ {Eq(1), Ne(-2), Ge(3), Le(4), Eq(5)}));
+ EXPECT_THAT(a, Not(UnorderedElementsAreArray<Matcher<int>>(
+ {Eq(1), Ne(-2), Ge(3), Le(4), Eq(6)})));
}
-
TEST(UnorderedElementsAreArrayTest, WorksWithMoveOnly) {
ContainerHelper helper;
EXPECT_CALL(helper,
@@ -6008,22 +5966,22 @@ TEST_F(UnorderedElementsAreTest, SucceedsWhenExpected) {
std::vector<int> s(std::begin(a), std::end(a));
do {
StringMatchResultListener listener;
- EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3),
- s, &listener)) << listener.str();
+ EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3), s, &listener))
+ << listener.str();
} while (std::next_permutation(s.begin(), s.end()));
}
TEST_F(UnorderedElementsAreTest, FailsWhenAnElementMatchesNoMatcher) {
const int a[] = {1, 2, 3};
std::vector<int> s(std::begin(a), std::end(a));
- std::vector<Matcher<int> > mv;
+ std::vector<Matcher<int>> mv;
mv.push_back(1);
mv.push_back(2);
mv.push_back(2);
// The element with value '3' matches nothing: fail fast.
StringMatchResultListener listener;
- EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAreArray(mv),
- s, &listener)) << listener.str();
+ EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAreArray(mv), s, &listener))
+ << listener.str();
}
TEST_F(UnorderedElementsAreTest, WorksForStreamlike) {
@@ -6051,15 +6009,15 @@ TEST_F(UnorderedElementsAreTest, WorksWithMoveOnly) {
// [ OK ] UnorderedElementsAreTest.Performance (4 ms)
TEST_F(UnorderedElementsAreTest, Performance) {
std::vector<int> s;
- std::vector<Matcher<int> > mv;
+ std::vector<Matcher<int>> mv;
for (int i = 0; i < 100; ++i) {
s.push_back(i);
mv.push_back(_);
}
mv[50] = Eq(0);
StringMatchResultListener listener;
- EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(mv),
- s, &listener)) << listener.str();
+ EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(mv), s, &listener))
+ << listener.str();
}
// Another variant of 'Performance' with similar expectations.
@@ -6067,7 +6025,7 @@ TEST_F(UnorderedElementsAreTest, Performance) {
// [ OK ] UnorderedElementsAreTest.PerformanceHalfStrict (4 ms)
TEST_F(UnorderedElementsAreTest, PerformanceHalfStrict) {
std::vector<int> s;
- std::vector<Matcher<int> > mv;
+ std::vector<Matcher<int>> mv;
for (int i = 0; i < 100; ++i) {
s.push_back(i);
if (i & 1) {
@@ -6077,24 +6035,24 @@ TEST_F(UnorderedElementsAreTest, PerformanceHalfStrict) {
}
}
StringMatchResultListener listener;
- EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(mv),
- s, &listener)) << listener.str();
+ EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(mv), s, &listener))
+ << listener.str();
}
TEST_F(UnorderedElementsAreTest, FailMessageCountWrong) {
std::vector<int> v;
v.push_back(4);
StringMatchResultListener listener;
- EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3),
- v, &listener)) << listener.str();
+ EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3), v, &listener))
+ << listener.str();
EXPECT_THAT(listener.str(), Eq("which has 1 element"));
}
TEST_F(UnorderedElementsAreTest, FailMessageCountWrongZero) {
std::vector<int> v;
StringMatchResultListener listener;
- EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3),
- v, &listener)) << listener.str();
+ EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3), v, &listener))
+ << listener.str();
EXPECT_THAT(listener.str(), Eq(""));
}
@@ -6103,12 +6061,11 @@ TEST_F(UnorderedElementsAreTest, FailMessageUnmatchedMatchers) {
v.push_back(1);
v.push_back(1);
StringMatchResultListener listener;
- EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2),
- v, &listener)) << listener.str();
- EXPECT_THAT(
- listener.str(),
- Eq("where the following matchers don't match any elements:\n"
- "matcher #1: is equal to 2"));
+ EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2), v, &listener))
+ << listener.str();
+ EXPECT_THAT(listener.str(),
+ Eq("where the following matchers don't match any elements:\n"
+ "matcher #1: is equal to 2"));
}
TEST_F(UnorderedElementsAreTest, FailMessageUnmatchedElements) {
@@ -6116,12 +6073,11 @@ TEST_F(UnorderedElementsAreTest, FailMessageUnmatchedElements) {
v.push_back(1);
v.push_back(2);
StringMatchResultListener listener;
- EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 1),
- v, &listener)) << listener.str();
- EXPECT_THAT(
- listener.str(),
- Eq("where the following elements don't match any matchers:\n"
- "element #1: 2"));
+ EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 1), v, &listener))
+ << listener.str();
+ EXPECT_THAT(listener.str(),
+ Eq("where the following elements don't match any matchers:\n"
+ "element #1: 2"));
}
TEST_F(UnorderedElementsAreTest, FailMessageUnmatchedMatcherAndElement) {
@@ -6129,17 +6085,16 @@ TEST_F(UnorderedElementsAreTest, FailMessageUnmatchedMatcherAndElement) {
v.push_back(2);
v.push_back(3);
StringMatchResultListener listener;
- EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2),
- v, &listener)) << listener.str();
- EXPECT_THAT(
- listener.str(),
- Eq("where"
- " the following matchers don't match any elements:\n"
- "matcher #0: is equal to 1\n"
- "and"
- " where"
- " the following elements don't match any matchers:\n"
- "element #1: 3"));
+ EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2), v, &listener))
+ << listener.str();
+ EXPECT_THAT(listener.str(),
+ Eq("where"
+ " the following matchers don't match any elements:\n"
+ "matcher #0: is equal to 1\n"
+ "and"
+ " where"
+ " the following elements don't match any matchers:\n"
+ "element #1: 3"));
}
// Test helper for formatting element, matcher index pairs in expectations.
@@ -6169,29 +6124,24 @@ TEST_F(UnorderedElementsAreTest, FailMessageImperfectMatchOnly) {
// We have to be a bit loose here, because there are 4 valid max matches.
EXPECT_THAT(
listener.str(),
- AnyOf(prefix + "{\n " + EMString(0, 0) +
- ",\n " + EMString(1, 2) + "\n}",
- prefix + "{\n " + EMString(0, 1) +
- ",\n " + EMString(1, 2) + "\n}",
- prefix + "{\n " + EMString(0, 0) +
- ",\n " + EMString(2, 2) + "\n}",
- prefix + "{\n " + EMString(0, 1) +
- ",\n " + EMString(2, 2) + "\n}"));
+ AnyOf(
+ prefix + "{\n " + EMString(0, 0) + ",\n " + EMString(1, 2) + "\n}",
+ prefix + "{\n " + EMString(0, 1) + ",\n " + EMString(1, 2) + "\n}",
+ prefix + "{\n " + EMString(0, 0) + ",\n " + EMString(2, 2) + "\n}",
+ prefix + "{\n " + EMString(0, 1) + ",\n " + EMString(2, 2) +
+ "\n}"));
}
TEST_F(UnorderedElementsAreTest, Describe) {
- EXPECT_THAT(Describe<IntVec>(UnorderedElementsAre()),
- Eq("is empty"));
- EXPECT_THAT(
- Describe<IntVec>(UnorderedElementsAre(345)),
- Eq("has 1 element and that element is equal to 345"));
- EXPECT_THAT(
- Describe<IntVec>(UnorderedElementsAre(111, 222, 333)),
- Eq("has 3 elements and there exists some permutation "
- "of elements such that:\n"
- " - element #0 is equal to 111, and\n"
- " - element #1 is equal to 222, and\n"
- " - element #2 is equal to 333"));
+ EXPECT_THAT(Describe<IntVec>(UnorderedElementsAre()), Eq("is empty"));
+ EXPECT_THAT(Describe<IntVec>(UnorderedElementsAre(345)),
+ Eq("has 1 element and that element is equal to 345"));
+ EXPECT_THAT(Describe<IntVec>(UnorderedElementsAre(111, 222, 333)),
+ Eq("has 3 elements and there exists some permutation "
+ "of elements such that:\n"
+ " - element #0 is equal to 111, and\n"
+ " - element #1 is equal to 222, and\n"
+ " - element #2 is equal to 333"));
}
TEST_F(UnorderedElementsAreTest, DescribeNegation) {
@@ -6200,13 +6150,12 @@ TEST_F(UnorderedElementsAreTest, DescribeNegation) {
EXPECT_THAT(
DescribeNegation<IntVec>(UnorderedElementsAre(345)),
Eq("doesn't have 1 element, or has 1 element that isn't equal to 345"));
- EXPECT_THAT(
- DescribeNegation<IntVec>(UnorderedElementsAre(123, 234, 345)),
- Eq("doesn't have 3 elements, or there exists no permutation "
- "of elements such that:\n"
- " - element #0 is equal to 123, and\n"
- " - element #1 is equal to 234, and\n"
- " - element #2 is equal to 345"));
+ EXPECT_THAT(DescribeNegation<IntVec>(UnorderedElementsAre(123, 234, 345)),
+ Eq("doesn't have 3 elements, or there exists no permutation "
+ "of elements such that:\n"
+ " - element #0 is equal to 123, and\n"
+ " - element #1 is equal to 234, and\n"
+ " - element #2 is equal to 345"));
}
namespace {
@@ -6219,7 +6168,7 @@ template <typename Graph>
class BacktrackingMaxBPMState {
public:
// Does not take ownership of 'g'.
- explicit BacktrackingMaxBPMState(const Graph* g) : graph_(g) { }
+ explicit BacktrackingMaxBPMState(const Graph* g) : graph_(g) {}
ElementMatcherPairs Compute() {
if (graph_->LhsSize() == 0 || graph_->RhsSize() == 0) {
@@ -6230,8 +6179,7 @@ class BacktrackingMaxBPMState {
for (size_t irhs = 0; irhs < graph_->RhsSize(); ++irhs) {
matches_.clear();
RecurseInto(irhs);
- if (best_so_far_.size() == graph_->RhsSize())
- break;
+ if (best_so_far_.size() == graph_->RhsSize()) break;
}
return best_so_far_;
}
@@ -6293,12 +6241,11 @@ const size_t BacktrackingMaxBPMState<Graph>::kUnused;
// Implement a simple backtracking algorithm to determine if it is possible
// to find one element per matcher, without reusing elements.
template <typename Graph>
-ElementMatcherPairs
-FindBacktrackingMaxBPM(const Graph& g) {
+ElementMatcherPairs FindBacktrackingMaxBPM(const Graph& g) {
return BacktrackingMaxBPMState<Graph>(&g).Compute();
}
-class BacktrackingBPMTest : public ::testing::Test { };
+class BacktrackingBPMTest : public ::testing::Test {};
// Tests the MaxBipartiteMatching algorithm with square matrices.
// The single int param is the # of nodes on each of the left and right sides.
@@ -6309,8 +6256,7 @@ TEST_P(BipartiteTest, Exhaustive) {
size_t nodes = GetParam();
MatchMatrix graph(nodes, nodes);
do {
- ElementMatcherPairs matches =
- internal::FindMaxBipartiteMatching(graph);
+ ElementMatcherPairs matches = internal::FindMaxBipartiteMatching(graph);
EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(), matches.size())
<< "graph: " << graph.DebugString();
// Check that all elements of matches are in the graph.
@@ -6335,8 +6281,7 @@ INSTANTIATE_TEST_SUITE_P(AllGraphs, BipartiteTest,
// Parameterized by a pair interpreted as (LhsSize, RhsSize).
class BipartiteNonSquareTest
- : public ::testing::TestWithParam<std::pair<size_t, size_t> > {
-};
+ : public ::testing::TestWithParam<std::pair<size_t, size_t>> {};
TEST_F(BipartiteNonSquareTest, SimpleBacktracking) {
// .......
@@ -6353,9 +6298,8 @@ TEST_F(BipartiteNonSquareTest, SimpleBacktracking) {
g.SetEdge(kEdges[i][0], kEdges[i][1], true);
}
EXPECT_THAT(FindBacktrackingMaxBPM(g),
- ElementsAre(Pair(3, 0),
- Pair(AnyOf(1, 2), 1),
- Pair(0, 2))) << g.DebugString();
+ ElementsAre(Pair(3, 0), Pair(AnyOf(1, 2), 1), Pair(0, 2)))
+ << g.DebugString();
}
// Verify a few nonsquare matrices.
@@ -6367,27 +6311,21 @@ TEST_P(BipartiteNonSquareTest, Exhaustive) {
EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(),
internal::FindMaxBipartiteMatching(graph).size())
<< "graph: " << graph.DebugString()
- << "\nbacktracking: "
- << PrintToString(FindBacktrackingMaxBPM(graph))
+ << "\nbacktracking: " << PrintToString(FindBacktrackingMaxBPM(graph))
<< "\nmax flow: "
<< PrintToString(internal::FindMaxBipartiteMatching(graph));
} while (graph.NextGraph());
}
-INSTANTIATE_TEST_SUITE_P(AllGraphs, BipartiteNonSquareTest,
- testing::Values(
- std::make_pair(1, 2),
- std::make_pair(2, 1),
- std::make_pair(3, 2),
- std::make_pair(2, 3),
- std::make_pair(4, 1),
- std::make_pair(1, 4),
- std::make_pair(4, 3),
- std::make_pair(3, 4)));
+INSTANTIATE_TEST_SUITE_P(
+ AllGraphs, BipartiteNonSquareTest,
+ testing::Values(std::make_pair(1, 2), std::make_pair(2, 1),
+ std::make_pair(3, 2), std::make_pair(2, 3),
+ std::make_pair(4, 1), std::make_pair(1, 4),
+ std::make_pair(4, 3), std::make_pair(3, 4)));
class BipartiteRandomTest
- : public ::testing::TestWithParam<std::pair<int, int> > {
-};
+ : public ::testing::TestWithParam<std::pair<int, int>> {};
// Verifies a large sample of larger graphs.
TEST_P(BipartiteRandomTest, LargerNets) {
@@ -6407,18 +6345,18 @@ TEST_P(BipartiteRandomTest, LargerNets) {
internal::FindMaxBipartiteMatching(graph).size())
<< " graph: " << graph.DebugString()
<< "\nTo reproduce the failure, rerun the test with the flag"
- " --" << GTEST_FLAG_PREFIX_ << "random_seed=" << seed;
+ " --"
+ << GTEST_FLAG_PREFIX_ << "random_seed=" << seed;
}
}
// Test argument is a std::pair<int, int> representing (nodes, iters).
INSTANTIATE_TEST_SUITE_P(Samples, BipartiteRandomTest,
- testing::Values(
- std::make_pair(5, 10000),
- std::make_pair(6, 5000),
- std::make_pair(7, 2000),
- std::make_pair(8, 500),
- std::make_pair(9, 100)));
+ testing::Values(std::make_pair(5, 10000),
+ std::make_pair(6, 5000),
+ std::make_pair(7, 2000),
+ std::make_pair(8, 500),
+ std::make_pair(9, 100)));
// Tests IsReadableTypeName().
@@ -6489,20 +6427,22 @@ TEST(MatcherTupleTest, ExplainsMatchFailure) {
ExplainMatchFailureTupleTo(
std::make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
std::make_tuple(2, 'b'), &ss2);
- EXPECT_EQ(" Expected arg #0: is > 5\n"
- " Actual: 2, which is 3 less than 5\n"
- " Expected arg #1: is equal to 'a' (97, 0x61)\n"
- " Actual: 'b' (98, 0x62)\n",
- ss2.str()); // Failed match where both arguments need explanation.
+ EXPECT_EQ(
+ " Expected arg #0: is > 5\n"
+ " Actual: 2, which is 3 less than 5\n"
+ " Expected arg #1: is equal to 'a' (97, 0x61)\n"
+ " Actual: 'b' (98, 0x62)\n",
+ ss2.str()); // Failed match where both arguments need explanation.
stringstream ss3;
ExplainMatchFailureTupleTo(
std::make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),
std::make_tuple(2, 'a'), &ss3);
- EXPECT_EQ(" Expected arg #0: is > 5\n"
- " Actual: 2, which is 3 less than 5\n",
- ss3.str()); // Failed match where only one argument needs
- // explanation.
+ EXPECT_EQ(
+ " Expected arg #0: is > 5\n"
+ " Actual: 2, which is 3 less than 5\n",
+ ss3.str()); // Failed match where only one argument needs
+ // explanation.
}
// Tests Each().
@@ -6510,7 +6450,7 @@ TEST(MatcherTupleTest, ExplainsMatchFailure) {
TEST(EachTest, ExplainsMatchResultCorrectly) {
set<int> a; // empty
- Matcher<set<int> > m = Each(2);
+ Matcher<set<int>> m = Each(2);
EXPECT_EQ("", Explain(m, a));
Matcher<const int(&)[1]> n = Each(1); // NOLINT
@@ -6533,10 +6473,10 @@ TEST(EachTest, ExplainsMatchResultCorrectly) {
}
TEST(EachTest, DescribesItselfCorrectly) {
- Matcher<vector<int> > m = Each(1);
+ Matcher<vector<int>> m = Each(1);
EXPECT_EQ("only contains elements that is equal to 1", Describe(m));
- Matcher<vector<int> > m2 = Not(m);
+ Matcher<vector<int>> m2 = Not(m);
EXPECT_EQ("contains some element that isn't equal to 1", Describe(m2));
}
@@ -6631,13 +6571,15 @@ TEST(PointwiseTest, DescribesSelf) {
rhs.push_back(2);
rhs.push_back(3);
const Matcher<const vector<int>&> m = Pointwise(IsHalfOf(), rhs);
- EXPECT_EQ("contains 3 values, where each value and its corresponding value "
- "in { 1, 2, 3 } are a pair where the first is half of the second",
- Describe(m));
- EXPECT_EQ("doesn't contain exactly 3 values, or contains a value x at some "
- "index i where x and the i-th value of { 1, 2, 3 } are a pair "
- "where the first isn't half of the second",
- DescribeNegation(m));
+ EXPECT_EQ(
+ "contains 3 values, where each value and its corresponding value "
+ "in { 1, 2, 3 } are a pair where the first is half of the second",
+ Describe(m));
+ EXPECT_EQ(
+ "doesn't contain exactly 3 values, or contains a value x at some "
+ "index i where x and the i-th value of { 1, 2, 3 } are a pair "
+ "where the first isn't half of the second",
+ DescribeNegation(m));
}
TEST(PointwiseTest, MakesCopyOfRhs) {
@@ -6646,7 +6588,7 @@ TEST(PointwiseTest, MakesCopyOfRhs) {
rhs.push_back(4);
int lhs[] = {1, 2};
- const Matcher<const int (&)[2]> m = Pointwise(IsHalfOf(), rhs);
+ const Matcher<const int(&)[2]> m = Pointwise(IsHalfOf(), rhs);
EXPECT_THAT(lhs, m);
// Changing rhs now shouldn't affect m, which made a copy of rhs.
@@ -6684,20 +6626,17 @@ TEST(PointwiseTest, WorksForVectorOfBool) {
EXPECT_THAT(lhs, Not(Pointwise(Eq(), rhs)));
}
-
TEST(PointwiseTest, WorksForRhsInitializerList) {
const vector<int> lhs{2, 4, 6};
EXPECT_THAT(lhs, Pointwise(Gt(), {1, 2, 3}));
EXPECT_THAT(lhs, Not(Pointwise(Lt(), {3, 3, 7})));
}
-
TEST(PointwiseTest, RejectsWrongSize) {
const double lhs[2] = {1, 2};
const int rhs[1] = {0};
EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs)));
- EXPECT_EQ("which contains 2 values",
- Explain(Pointwise(Gt(), rhs), lhs));
+ EXPECT_EQ("which contains 2 values", Explain(Pointwise(Gt(), rhs), lhs));
const int rhs2[3] = {0, 1, 2};
EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs2)));
@@ -6707,9 +6646,10 @@ TEST(PointwiseTest, RejectsWrongContent) {
const double lhs[3] = {1, 2, 3};
const int rhs[3] = {2, 6, 4};
EXPECT_THAT(lhs, Not(Pointwise(IsHalfOf(), rhs)));
- EXPECT_EQ("where the value pair (2, 6) at index #1 don't match, "
- "where the second/2 is 3",
- Explain(Pointwise(IsHalfOf(), rhs), lhs));
+ EXPECT_EQ(
+ "where the value pair (2, 6) at index #1 don't match, "
+ "where the second/2 is 3",
+ Explain(Pointwise(IsHalfOf(), rhs), lhs));
}
TEST(PointwiseTest, AcceptsCorrectContent) {
@@ -6776,7 +6716,7 @@ TEST(UnorderedPointwiseTest, MakesCopyOfRhs) {
rhs.push_back(4);
int lhs[] = {2, 1};
- const Matcher<const int (&)[2]> m = UnorderedPointwise(IsHalfOf(), rhs);
+ const Matcher<const int(&)[2]> m = UnorderedPointwise(IsHalfOf(), rhs);
EXPECT_THAT(lhs, m);
// Changing rhs now shouldn't affect m, which made a copy of rhs.
@@ -6804,14 +6744,12 @@ TEST(UnorderedPointwiseTest, WorksForRhsNativeArray) {
EXPECT_THAT(lhs, Not(UnorderedPointwise(Lt(), rhs)));
}
-
TEST(UnorderedPointwiseTest, WorksForRhsInitializerList) {
const vector<int> lhs{2, 4, 6};
EXPECT_THAT(lhs, UnorderedPointwise(Gt(), {5, 1, 3}));
EXPECT_THAT(lhs, Not(UnorderedPointwise(Lt(), {1, 1, 7})));
}
-
TEST(UnorderedPointwiseTest, RejectsWrongSize) {
const double lhs[2] = {1, 2};
const int rhs[1] = {0};
@@ -6827,9 +6765,10 @@ TEST(UnorderedPointwiseTest, RejectsWrongContent) {
const double lhs[3] = {1, 2, 3};
const int rhs[3] = {2, 6, 6};
EXPECT_THAT(lhs, Not(UnorderedPointwise(IsHalfOf(), rhs)));
- EXPECT_EQ("where the following elements don't match any matchers:\n"
- "element #1: 2",
- Explain(UnorderedPointwise(IsHalfOf(), rhs), lhs));
+ EXPECT_EQ(
+ "where the following elements don't match any matchers:\n"
+ "element #1: 2",
+ Explain(UnorderedPointwise(IsHalfOf(), rhs), lhs));
}
TEST(UnorderedPointwiseTest, AcceptsCorrectContentInSameOrder) {
@@ -7119,9 +7058,7 @@ TEST(ArgsTest, CanMatchTupleByReference) {
}
// Validates that arg is printed as str.
-MATCHER_P(PrintsAs, str, "") {
- return testing::PrintToString(arg) == str;
-}
+MATCHER_P(PrintsAs, str, "") { return testing::PrintToString(arg) == str; }
TEST(ArgsTest, AcceptsTenTemplateArgs) {
EXPECT_THAT(std::make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),
@@ -7133,29 +7070,32 @@ TEST(ArgsTest, AcceptsTenTemplateArgs) {
}
TEST(ArgsTest, DescirbesSelfCorrectly) {
- const Matcher<std::tuple<int, bool, char> > m = Args<2, 0>(Lt());
- EXPECT_EQ("are a tuple whose fields (#2, #0) are a pair where "
- "the first < the second",
- Describe(m));
+ const Matcher<std::tuple<int, bool, char>> m = Args<2, 0>(Lt());
+ EXPECT_EQ(
+ "are a tuple whose fields (#2, #0) are a pair where "
+ "the first < the second",
+ Describe(m));
}
TEST(ArgsTest, DescirbesNestedArgsCorrectly) {
const Matcher<const std::tuple<int, bool, char, int>&> m =
Args<0, 2, 3>(Args<2, 0>(Lt()));
- EXPECT_EQ("are a tuple whose fields (#0, #2, #3) are a tuple "
- "whose fields (#2, #0) are a pair where the first < the second",
- Describe(m));
+ EXPECT_EQ(
+ "are a tuple whose fields (#0, #2, #3) are a tuple "
+ "whose fields (#2, #0) are a pair where the first < the second",
+ Describe(m));
}
TEST(ArgsTest, DescribesNegationCorrectly) {
- const Matcher<std::tuple<int, char> > m = Args<1, 0>(Gt());
- EXPECT_EQ("are a tuple whose fields (#1, #0) aren't a pair "
- "where the first > the second",
- DescribeNegation(m));
+ const Matcher<std::tuple<int, char>> m = Args<1, 0>(Gt());
+ EXPECT_EQ(
+ "are a tuple whose fields (#1, #0) aren't a pair "
+ "where the first > the second",
+ DescribeNegation(m));
}
TEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) {
- const Matcher<std::tuple<bool, int, int> > m = Args<1, 2>(Eq());
+ const Matcher<std::tuple<bool, int, int>> m = Args<1, 2>(Eq());
EXPECT_EQ("whose fields (#1, #2) are (42, 42)",
Explain(m, std::make_tuple(false, 42, 42)));
EXPECT_EQ("whose fields (#1, #2) are (42, 43)",
@@ -7163,7 +7103,7 @@ TEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) {
}
// For testing Args<>'s explanation.
-class LessThanMatcher : public MatcherInterface<std::tuple<char, int> > {
+class LessThanMatcher : public MatcherInterface<std::tuple<char, int>> {
public:
void DescribeTo(::std::ostream* /*os*/) const override {}
@@ -7178,12 +7118,12 @@ class LessThanMatcher : public MatcherInterface<std::tuple<char, int> > {
}
};
-Matcher<std::tuple<char, int> > LessThan() {
+Matcher<std::tuple<char, int>> LessThan() {
return MakeMatcher(new LessThanMatcher);
}
TEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) {
- const Matcher<std::tuple<char, int, int> > m = Args<0, 2>(LessThan());
+ const Matcher<std::tuple<char, int, int>> m = Args<0, 2>(LessThan());
EXPECT_EQ(
"whose fields (#0, #2) are ('a' (97, 0x61), 42), "
"where the first value is 55 more than the second",
@@ -8698,5 +8638,5 @@ TEST(ThrowsPredicateCompilesTest, MessageMatcherAcceptsNonMatcher) {
} // namespace testing
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
diff --git a/googlemock/test/gmock-more-actions_test.cc b/googlemock/test/gmock-more-actions_test.cc
index fdc8c70..b9b66bf 100644
--- a/googlemock/test/gmock-more-actions_test.cc
+++ b/googlemock/test/gmock-more-actions_test.cc
@@ -145,7 +145,7 @@ class Foo {
std::string Binary(const std::string& str, char c) const { return str + c; }
- int Ternary(int x, bool y, char z) { return value_ + x + y*z; }
+ int Ternary(int x, bool y, char z) { return value_ + x + y * z; }
int SumOf4(int a, int b, int c, int d) const {
return a + b + c + d + value_;
@@ -291,8 +291,7 @@ TEST(InvokeTest, FunctionWithUnusedParameters) {
std::make_tuple(10, 2, 5.6, std::string("hi"));
EXPECT_EQ(12, a1.Perform(dummy));
- Action<int(int, int, bool, int*)> a2 =
- Invoke(SumOfFirst2);
+ Action<int(int, int, bool, int*)> a2 = Invoke(SumOfFirst2);
EXPECT_EQ(
23, a2.Perform(std::make_tuple(20, 3, true, static_cast<int*>(nullptr))));
}
@@ -303,8 +302,7 @@ TEST(InvokeTest, MethodWithUnusedParameters) {
Action<int(std::string, bool, int, int)> a1 = Invoke(&foo, &Foo::SumOfLast2);
EXPECT_EQ(12, a1.Perform(std::make_tuple(CharPtr("hi"), true, 10, 2)));
- Action<int(char, double, int, int)> a2 =
- Invoke(&foo, &Foo::SumOfLast2);
+ Action<int(char, double, int, int)> a2 = Invoke(&foo, &Foo::SumOfLast2);
EXPECT_EQ(23, a2.Perform(std::make_tuple('a', 2.5, 20, 3)));
}
@@ -362,7 +360,8 @@ TEST(InvokeMethodTest, MethodThatTakes4Arguments) {
// Tests using Invoke() with a 5-argument method.
TEST(InvokeMethodTest, MethodThatTakes5Arguments) {
Foo foo;
- Action<int(int, int, int, int, int)> a = Invoke(&foo, &Foo::SumOf5); // NOLINT
+ Action<int(int, int, int, int, int)> a =
+ Invoke(&foo, &Foo::SumOf5); // NOLINT
EXPECT_EQ(12345, a.Perform(std::make_tuple(10000, 2000, 300, 40, 5)));
}
@@ -523,15 +522,12 @@ TEST(SetArgRefereeActionTest, WorksWithExtraArguments) {
// the bool provided to the constructor to true when destroyed.
class DeletionTester {
public:
- explicit DeletionTester(bool* is_deleted)
- : is_deleted_(is_deleted) {
+ explicit DeletionTester(bool* is_deleted) : is_deleted_(is_deleted) {
// Make sure the bit is set to false.
*is_deleted_ = false;
}
- ~DeletionTester() {
- *is_deleted_ = true;
- }
+ ~DeletionTester() { *is_deleted_ = true; }
private:
bool* is_deleted_;
@@ -540,7 +536,7 @@ class DeletionTester {
TEST(DeleteArgActionTest, OneArg) {
bool is_deleted = false;
DeletionTester* t = new DeletionTester(&is_deleted);
- const Action<void(DeletionTester*)> a1 = DeleteArg<0>(); // NOLINT
+ const Action<void(DeletionTester*)> a1 = DeleteArg<0>(); // NOLINT
EXPECT_FALSE(is_deleted);
a1.Perform(std::make_tuple(t));
EXPECT_TRUE(is_deleted);
@@ -549,8 +545,9 @@ TEST(DeleteArgActionTest, OneArg) {
TEST(DeleteArgActionTest, TenArgs) {
bool is_deleted = false;
DeletionTester* t = new DeletionTester(&is_deleted);
- const Action<void(bool, int, int, const char*, bool,
- int, int, int, int, DeletionTester*)> a1 = DeleteArg<9>();
+ const Action<void(bool, int, int, const char*, bool, int, int, int, int,
+ DeletionTester*)>
+ a1 = DeleteArg<9>();
EXPECT_FALSE(is_deleted);
a1.Perform(std::make_tuple(true, 5, 6, CharPtr("hi"), false, 7, 8, 9, 10, t));
EXPECT_TRUE(is_deleted);
@@ -608,7 +605,7 @@ TEST(ThrowActionTest, Times0) {
// pointed to by the N-th (0-based) argument to values in range [first, last).
TEST(SetArrayArgumentTest, SetsTheNthArray) {
using MyFunction = void(bool, int*, char*);
- int numbers[] = { 1, 2, 3 };
+ int numbers[] = {1, 2, 3};
Action<MyFunction> a = SetArrayArgument<1>(numbers, numbers + 3);
int n[4] = {};
@@ -644,7 +641,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArray) {
// Tests SetArrayArgument<N>(first, last) where first == last.
TEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) {
using MyFunction = void(bool, int*);
- int numbers[] = { 1, 2, 3 };
+ int numbers[] = {1, 2, 3};
Action<MyFunction> a = SetArrayArgument<1>(numbers, numbers);
int n[4] = {};
@@ -660,10 +657,10 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) {
// (but not equal) to the argument type.
TEST(SetArrayArgumentTest, SetsTheNthArrayWithConvertibleType) {
using MyFunction = void(bool, int*);
- char chars[] = { 97, 98, 99 };
+ char chars[] = {97, 98, 99};
Action<MyFunction> a = SetArrayArgument<1>(chars, chars + 3);
- int codes[4] = { 111, 222, 333, 444 };
+ int codes[4] = {111, 222, 333, 444};
int* pcodes = codes;
a.Perform(std::make_tuple(true, pcodes));
EXPECT_EQ(97, codes[0]);
diff --git a/googlemock/test/gmock-nice-strict_test.cc b/googlemock/test/gmock-nice-strict_test.cc
index 319b18d..21130d4 100644
--- a/googlemock/test/gmock-nice-strict_test.cc
+++ b/googlemock/test/gmock-nice-strict_test.cc
@@ -31,6 +31,7 @@
#include <string>
#include <utility>
+
#include "gmock/gmock.h"
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
@@ -102,7 +103,8 @@ class MockBar {
MockBar(char a1, char a2, std::string a3, std::string a4, int a5, int a6,
const std::string& a7, const std::string& a8, bool a9, bool a10) {
str_ = std::string() + a1 + a2 + a3 + a4 + static_cast<char>(a5) +
- static_cast<char>(a6) + a7 + a8 + (a9 ? 'T' : 'F') + (a10 ? 'T' : 'F');
+ static_cast<char>(a6) + a7 + a8 + (a9 ? 'T' : 'F') +
+ (a10 ? 'T' : 'F');
}
virtual ~MockBar() {}
@@ -118,7 +120,6 @@ class MockBar {
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar);
};
-
class MockBaz {
public:
class MoveOnly {
@@ -161,8 +162,7 @@ TEST(RawMockTest, WarningForUninterestingCallAfterDeath) {
MockFoo* const raw_foo = new MockFoo;
- ON_CALL(*raw_foo, DoThis())
- .WillByDefault(Invoke(raw_foo, &MockFoo::Delete));
+ ON_CALL(*raw_foo, DoThis()).WillByDefault(Invoke(raw_foo, &MockFoo::Delete));
CaptureStdout();
raw_foo->DoThis();
@@ -280,8 +280,8 @@ TEST(NiceMockTest, NonDefaultConstructor) {
// Tests that NiceMock works with a mock class that has a 10-ary
// non-default constructor.
TEST(NiceMockTest, NonDefaultConstructor10) {
- NiceMock<MockBar> nice_bar('a', 'b', "c", "d", 'e', 'f',
- "g", "h", true, false);
+ NiceMock<MockBar> nice_bar('a', 'b', "c", "d", 'e', 'f', "g", "h", true,
+ false);
EXPECT_EQ("abcdefghTF", nice_bar.str());
nice_bar.This();
@@ -390,8 +390,8 @@ TEST(NaggyMockTest, NonDefaultConstructor) {
// Tests that NaggyMock works with a mock class that has a 10-ary
// non-default constructor.
TEST(NaggyMockTest, NonDefaultConstructor10) {
- NaggyMock<MockBar> naggy_bar('0', '1', "2", "3", '4', '5',
- "6", "7", true, false);
+ NaggyMock<MockBar> naggy_bar('0', '1', "2", "3", '4', '5', "6", "7", true,
+ false);
EXPECT_EQ("01234567TF", naggy_bar.str());
naggy_bar.This();
@@ -490,8 +490,8 @@ TEST(StrictMockTest, NonDefaultConstructor) {
// Tests that StrictMock works with a mock class that has a 10-ary
// non-default constructor.
TEST(StrictMockTest, NonDefaultConstructor10) {
- StrictMock<MockBar> strict_bar('a', 'b', "c", "d", 'e', 'f',
- "g", "h", true, false);
+ StrictMock<MockBar> strict_bar('a', 'b', "c", "d", 'e', 'f', "g", "h", true,
+ false);
EXPECT_EQ("abcdefghTF", strict_bar.str());
EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true),
diff --git a/googlemock/test/gmock-port_test.cc b/googlemock/test/gmock-port_test.cc
index a2c2be2..c31af82 100644
--- a/googlemock/test/gmock-port_test.cc
+++ b/googlemock/test/gmock-port_test.cc
@@ -27,12 +27,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests the internal cross-platform support utilities.
#include "gmock/internal/gmock-port.h"
+
#include "gtest/gtest.h"
// NOTE: if this file is left without tests for some reason, put a dummy
diff --git a/googlemock/test/gmock-pp-string_test.cc b/googlemock/test/gmock-pp-string_test.cc
index 6f66cf1..53c80f4 100644
--- a/googlemock/test/gmock-pp-string_test.cc
+++ b/googlemock/test/gmock-pp-string_test.cc
@@ -30,11 +30,10 @@
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests the internal preprocessor macro library.
-#include "gmock/internal/gmock-pp.h"
-
#include <string>
#include "gmock/gmock.h"
+#include "gmock/internal/gmock-pp.h"
namespace testing {
namespace {
diff --git a/googlemock/test/gmock-spec-builders_test.cc b/googlemock/test/gmock-spec-builders_test.cc
index 7f29b61..b59676f 100644
--- a/googlemock/test/gmock-spec-builders_test.cc
+++ b/googlemock/test/gmock-spec-builders_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests the spec builder syntax.
@@ -41,8 +40,8 @@
#include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h"
-#include "gtest/gtest.h"
#include "gtest/gtest-spi.h"
+#include "gtest/gtest.h"
#include "gtest/internal/gtest-port.h"
namespace testing {
@@ -52,9 +51,7 @@ namespace internal {
class ExpectationTester {
public:
// Sets the call count of the given expectation to the given number.
- void SetCallCount(int n, ExpectationBase* exp) {
- exp->call_count_ = n;
- }
+ void SetCallCount(int n, ExpectationBase* exp) { exp->call_count_ = n; }
};
} // namespace internal
@@ -125,8 +122,7 @@ TEST(MockMethodTest, CanInstantiateWithIncompleteArgType) {
// use the mock, as long as Google Mock knows how to print the
// argument.
MockIncomplete incomplete;
- EXPECT_CALL(incomplete, ByRefFunc(_))
- .Times(AnyNumber());
+ EXPECT_CALL(incomplete, ByRefFunc(_)).Times(AnyNumber());
}
// The definition of the printer for the argument type doesn't have to
@@ -162,7 +158,7 @@ class MockB {
MockB() {}
MOCK_CONST_METHOD0(DoB, int()); // NOLINT
- MOCK_METHOD1(DoB, int(int n)); // NOLINT
+ MOCK_METHOD1(DoB, int(int n)); // NOLINT
private:
GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB);
@@ -253,41 +249,42 @@ TEST(OnCallSyntaxTest, EvaluatesSecondArgumentOnce) {
TEST(OnCallSyntaxTest, WithIsOptional) {
MockA a;
- ON_CALL(a, DoA(5))
- .WillByDefault(Return());
- ON_CALL(a, DoA(_))
- .With(_)
- .WillByDefault(Return());
+ ON_CALL(a, DoA(5)).WillByDefault(Return());
+ ON_CALL(a, DoA(_)).With(_).WillByDefault(Return());
}
TEST(OnCallSyntaxTest, WithCanAppearAtMostOnce) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- ON_CALL(a, ReturnResult(_))
- .With(_)
- .With(_)
- .WillByDefault(Return(Result()));
- }, ".With() cannot appear more than once in an ON_CALL()");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ ON_CALL(a, ReturnResult(_))
+ .With(_)
+ .With(_)
+ .WillByDefault(Return(Result()));
+ },
+ ".With() cannot appear more than once in an ON_CALL()");
}
TEST(OnCallSyntaxTest, WillByDefaultIsMandatory) {
MockA a;
- EXPECT_DEATH_IF_SUPPORTED({
- ON_CALL(a, DoA(5));
- a.DoA(5);
- }, "");
+ EXPECT_DEATH_IF_SUPPORTED(
+ {
+ ON_CALL(a, DoA(5));
+ a.DoA(5);
+ },
+ "");
}
TEST(OnCallSyntaxTest, WillByDefaultCanAppearAtMostOnce) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- ON_CALL(a, DoA(5))
- .WillByDefault(Return())
- .WillByDefault(Return());
- }, ".WillByDefault() must appear exactly once in an ON_CALL()");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ ON_CALL(a, DoA(5)).WillByDefault(Return()).WillByDefault(Return());
+ },
+ ".WillByDefault() must appear exactly once in an ON_CALL()");
}
// Tests that EXPECT_CALL evaluates its arguments exactly once as
@@ -315,21 +312,18 @@ TEST(ExpectCallSyntaxTest, EvaluatesSecondArgumentOnce) {
TEST(ExpectCallSyntaxTest, WithIsOptional) {
MockA a;
- EXPECT_CALL(a, DoA(5))
- .Times(0);
- EXPECT_CALL(a, DoA(6))
- .With(_)
- .Times(0);
+ EXPECT_CALL(a, DoA(5)).Times(0);
+ EXPECT_CALL(a, DoA(6)).With(_).Times(0);
}
TEST(ExpectCallSyntaxTest, WithCanAppearAtMostOnce) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(6))
- .With(_)
- .With(_);
- }, ".With() cannot appear more than once in an EXPECT_CALL()");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(6)).With(_).With(_);
+ },
+ ".With() cannot appear more than once in an EXPECT_CALL()");
a.DoA(6);
}
@@ -337,19 +331,19 @@ TEST(ExpectCallSyntaxTest, WithCanAppearAtMostOnce) {
TEST(ExpectCallSyntaxTest, WithMustBeFirstClause) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(1))
- .Times(1)
- .With(_);
- }, ".With() must be the first clause in an EXPECT_CALL()");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(1)).Times(1).With(_);
+ },
+ ".With() must be the first clause in an EXPECT_CALL()");
a.DoA(1);
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(2))
- .WillOnce(Return())
- .With(_);
- }, ".With() must be the first clause in an EXPECT_CALL()");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(2)).WillOnce(Return()).With(_);
+ },
+ ".With() must be the first clause in an EXPECT_CALL()");
a.DoA(2);
}
@@ -357,12 +351,9 @@ TEST(ExpectCallSyntaxTest, WithMustBeFirstClause) {
TEST(ExpectCallSyntaxTest, TimesCanBeInferred) {
MockA a;
- EXPECT_CALL(a, DoA(1))
- .WillOnce(Return());
+ EXPECT_CALL(a, DoA(1)).WillOnce(Return());
- EXPECT_CALL(a, DoA(2))
- .WillOnce(Return())
- .WillRepeatedly(Return());
+ EXPECT_CALL(a, DoA(2)).WillOnce(Return()).WillRepeatedly(Return());
a.DoA(1);
a.DoA(2);
@@ -372,11 +363,11 @@ TEST(ExpectCallSyntaxTest, TimesCanBeInferred) {
TEST(ExpectCallSyntaxTest, TimesCanAppearAtMostOnce) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(1))
- .Times(1)
- .Times(2);
- }, ".Times() cannot appear more than once in an EXPECT_CALL()");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(1)).Times(1).Times(2);
+ },
+ ".Times() cannot appear more than once in an EXPECT_CALL()");
a.DoA(1);
a.DoA(1);
@@ -386,11 +377,11 @@ TEST(ExpectCallSyntaxTest, TimesMustBeBeforeInSequence) {
MockA a;
Sequence s;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(1))
- .InSequence(s)
- .Times(1);
- }, ".Times() may only appear *before* ");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(1)).InSequence(s).Times(1);
+ },
+ ".Times() may only appear *before* ");
a.DoA(1);
}
@@ -400,8 +391,7 @@ TEST(ExpectCallSyntaxTest, InSequenceIsOptional) {
Sequence s;
EXPECT_CALL(a, DoA(1));
- EXPECT_CALL(a, DoA(2))
- .InSequence(s);
+ EXPECT_CALL(a, DoA(2)).InSequence(s);
a.DoA(1);
a.DoA(2);
@@ -411,9 +401,7 @@ TEST(ExpectCallSyntaxTest, InSequenceCanAppearMultipleTimes) {
MockA a;
Sequence s1, s2;
- EXPECT_CALL(a, DoA(1))
- .InSequence(s1, s2)
- .InSequence(s1);
+ EXPECT_CALL(a, DoA(1)).InSequence(s1, s2).InSequence(s1);
a.DoA(1);
}
@@ -422,13 +410,12 @@ TEST(ExpectCallSyntaxTest, InSequenceMustBeBeforeAfter) {
MockA a;
Sequence s;
- Expectation e = EXPECT_CALL(a, DoA(1))
- .Times(AnyNumber());
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(2))
- .After(e)
- .InSequence(s);
- }, ".InSequence() cannot appear after ");
+ Expectation e = EXPECT_CALL(a, DoA(1)).Times(AnyNumber());
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(2)).After(e).InSequence(s);
+ },
+ ".InSequence() cannot appear after ");
a.DoA(2);
}
@@ -437,11 +424,11 @@ TEST(ExpectCallSyntaxTest, InSequenceMustBeBeforeWillOnce) {
MockA a;
Sequence s;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(1))
- .WillOnce(Return())
- .InSequence(s);
- }, ".InSequence() cannot appear after ");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(1)).WillOnce(Return()).InSequence(s);
+ },
+ ".InSequence() cannot appear after ");
a.DoA(1);
}
@@ -450,11 +437,9 @@ TEST(ExpectCallSyntaxTest, AfterMustBeBeforeWillOnce) {
MockA a;
Expectation e = EXPECT_CALL(a, DoA(1));
- EXPECT_NONFATAL_FAILURE({
- EXPECT_CALL(a, DoA(2))
- .WillOnce(Return())
- .After(e);
- }, ".After() cannot appear after ");
+ EXPECT_NONFATAL_FAILURE(
+ { EXPECT_CALL(a, DoA(2)).WillOnce(Return()).After(e); },
+ ".After() cannot appear after ");
a.DoA(1);
a.DoA(2);
@@ -464,8 +449,7 @@ TEST(ExpectCallSyntaxTest, WillIsOptional) {
MockA a;
EXPECT_CALL(a, DoA(1));
- EXPECT_CALL(a, DoA(2))
- .WillOnce(Return());
+ EXPECT_CALL(a, DoA(2)).WillOnce(Return());
a.DoA(1);
a.DoA(2);
@@ -484,11 +468,11 @@ TEST(ExpectCallSyntaxTest, WillCanAppearMultipleTimes) {
TEST(ExpectCallSyntaxTest, WillMustBeBeforeWillRepeatedly) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(1))
- .WillRepeatedly(Return())
- .WillOnce(Return());
- }, ".WillOnce() cannot appear after ");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(1)).WillRepeatedly(Return()).WillOnce(Return());
+ },
+ ".WillOnce() cannot appear after ");
a.DoA(1);
}
@@ -496,11 +480,8 @@ TEST(ExpectCallSyntaxTest, WillMustBeBeforeWillRepeatedly) {
TEST(ExpectCallSyntaxTest, WillRepeatedlyIsOptional) {
MockA a;
- EXPECT_CALL(a, DoA(1))
- .WillOnce(Return());
- EXPECT_CALL(a, DoA(2))
- .WillOnce(Return())
- .WillRepeatedly(Return());
+ EXPECT_CALL(a, DoA(1)).WillOnce(Return());
+ EXPECT_CALL(a, DoA(2)).WillOnce(Return()).WillRepeatedly(Return());
a.DoA(1);
a.DoA(2);
@@ -510,30 +491,30 @@ TEST(ExpectCallSyntaxTest, WillRepeatedlyIsOptional) {
TEST(ExpectCallSyntaxTest, WillRepeatedlyCannotAppearMultipleTimes) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(1))
- .WillRepeatedly(Return())
- .WillRepeatedly(Return());
- }, ".WillRepeatedly() cannot appear more than once in an "
- "EXPECT_CALL()");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(1)).WillRepeatedly(Return()).WillRepeatedly(
+ Return());
+ },
+ ".WillRepeatedly() cannot appear more than once in an "
+ "EXPECT_CALL()");
}
TEST(ExpectCallSyntaxTest, WillRepeatedlyMustBeBeforeRetiresOnSaturation) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(1))
- .RetiresOnSaturation()
- .WillRepeatedly(Return());
- }, ".WillRepeatedly() cannot appear after ");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(1)).RetiresOnSaturation().WillRepeatedly(Return());
+ },
+ ".WillRepeatedly() cannot appear after ");
}
TEST(ExpectCallSyntaxTest, RetiresOnSaturationIsOptional) {
MockA a;
EXPECT_CALL(a, DoA(1));
- EXPECT_CALL(a, DoA(1))
- .RetiresOnSaturation();
+ EXPECT_CALL(a, DoA(1)).RetiresOnSaturation();
a.DoA(1);
a.DoA(1);
@@ -542,11 +523,11 @@ TEST(ExpectCallSyntaxTest, RetiresOnSaturationIsOptional) {
TEST(ExpectCallSyntaxTest, RetiresOnSaturationCannotAppearMultipleTimes) {
MockA a;
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- EXPECT_CALL(a, DoA(1))
- .RetiresOnSaturation()
- .RetiresOnSaturation();
- }, ".RetiresOnSaturation() cannot appear more than once");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ EXPECT_CALL(a, DoA(1)).RetiresOnSaturation().RetiresOnSaturation();
+ },
+ ".RetiresOnSaturation() cannot appear more than once");
a.DoA(1);
}
@@ -557,16 +538,20 @@ TEST(ExpectCallSyntaxTest, DefaultCardinalityIsOnce) {
EXPECT_CALL(a, DoA(1));
a.DoA(1);
}
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- MockA a;
- EXPECT_CALL(a, DoA(1));
- }, "to be called once");
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- MockA a;
- EXPECT_CALL(a, DoA(1));
- a.DoA(1);
- a.DoA(1);
- }, "to be called once");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ MockA a;
+ EXPECT_CALL(a, DoA(1));
+ },
+ "to be called once");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ MockA a;
+ EXPECT_CALL(a, DoA(1));
+ a.DoA(1);
+ a.DoA(1);
+ },
+ "to be called once");
}
#if GTEST_HAS_STREAM_REDIRECTION
@@ -579,13 +564,9 @@ TEST(ExpectCallSyntaxTest, DoesNotWarnOnAdequateActionCount) {
MockB b;
// It's always fine to omit WillOnce() entirely.
- EXPECT_CALL(b, DoB())
- .Times(0);
- EXPECT_CALL(b, DoB(1))
- .Times(AtMost(1));
- EXPECT_CALL(b, DoB(2))
- .Times(1)
- .WillRepeatedly(Return(1));
+ EXPECT_CALL(b, DoB()).Times(0);
+ EXPECT_CALL(b, DoB(1)).Times(AtMost(1));
+ EXPECT_CALL(b, DoB(2)).Times(1).WillRepeatedly(Return(1));
// It's fine for the number of WillOnce()s to equal the upper bound.
EXPECT_CALL(b, DoB(3))
@@ -595,10 +576,8 @@ TEST(ExpectCallSyntaxTest, DoesNotWarnOnAdequateActionCount) {
// It's fine for the number of WillOnce()s to be smaller than the
// upper bound when there is a WillRepeatedly().
- EXPECT_CALL(b, DoB(4))
- .Times(AtMost(3))
- .WillOnce(Return(1))
- .WillRepeatedly(Return(2));
+ EXPECT_CALL(b, DoB(4)).Times(AtMost(3)).WillOnce(Return(1)).WillRepeatedly(
+ Return(2));
// Satisfies the above expectations.
b.DoB(2);
@@ -615,13 +594,9 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooManyActions) {
MockB b;
// Warns when the number of WillOnce()s is larger than the upper bound.
- EXPECT_CALL(b, DoB())
- .Times(0)
- .WillOnce(Return(1)); // #1
- EXPECT_CALL(b, DoB())
- .Times(AtMost(1))
- .WillOnce(Return(1))
- .WillOnce(Return(2)); // #2
+ EXPECT_CALL(b, DoB()).Times(0).WillOnce(Return(1)); // #1
+ EXPECT_CALL(b, DoB()).Times(AtMost(1)).WillOnce(Return(1)).WillOnce(
+ Return(2)); // #2
EXPECT_CALL(b, DoB(1))
.Times(1)
.WillOnce(Return(1))
@@ -630,41 +605,34 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooManyActions) {
// Warns when the number of WillOnce()s equals the upper bound and
// there is a WillRepeatedly().
- EXPECT_CALL(b, DoB())
- .Times(0)
- .WillRepeatedly(Return(1)); // #4
- EXPECT_CALL(b, DoB(2))
- .Times(1)
- .WillOnce(Return(1))
- .WillRepeatedly(Return(2)); // #5
+ EXPECT_CALL(b, DoB()).Times(0).WillRepeatedly(Return(1)); // #4
+ EXPECT_CALL(b, DoB(2)).Times(1).WillOnce(Return(1)).WillRepeatedly(
+ Return(2)); // #5
// Satisfies the above expectations.
b.DoB(1);
b.DoB(2);
}
const std::string output = GetCapturedStdout();
- EXPECT_PRED_FORMAT2(
- IsSubstring,
- "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
- "Expected to be never called, but has 1 WillOnce().",
- output); // #1
- EXPECT_PRED_FORMAT2(
- IsSubstring,
- "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
- "Expected to be called at most once, "
- "but has 2 WillOnce()s.",
- output); // #2
+ EXPECT_PRED_FORMAT2(IsSubstring,
+ "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
+ "Expected to be never called, but has 1 WillOnce().",
+ output); // #1
+ EXPECT_PRED_FORMAT2(IsSubstring,
+ "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
+ "Expected to be called at most once, "
+ "but has 2 WillOnce()s.",
+ output); // #2
EXPECT_PRED_FORMAT2(
IsSubstring,
"Too many actions specified in EXPECT_CALL(b, DoB(1))...\n"
"Expected to be called once, but has 2 WillOnce()s.",
output); // #3
- EXPECT_PRED_FORMAT2(
- IsSubstring,
- "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
- "Expected to be never called, but has 0 WillOnce()s "
- "and a WillRepeatedly().",
- output); // #4
+ EXPECT_PRED_FORMAT2(IsSubstring,
+ "Too many actions specified in EXPECT_CALL(b, DoB())...\n"
+ "Expected to be never called, but has 0 WillOnce()s "
+ "and a WillRepeatedly().",
+ output); // #4
EXPECT_PRED_FORMAT2(
IsSubstring,
"Too many actions specified in EXPECT_CALL(b, DoB(2))...\n"
@@ -678,19 +646,16 @@ TEST(ExpectCallSyntaxTest, WarnsOnTooManyActions) {
TEST(ExpectCallSyntaxTest, WarnsOnTooFewActions) {
MockB b;
- EXPECT_CALL(b, DoB())
- .Times(Between(2, 3))
- .WillOnce(Return(1));
+ EXPECT_CALL(b, DoB()).Times(Between(2, 3)).WillOnce(Return(1));
CaptureStdout();
b.DoB();
const std::string output = GetCapturedStdout();
- EXPECT_PRED_FORMAT2(
- IsSubstring,
- "Too few actions specified in EXPECT_CALL(b, DoB())...\n"
- "Expected to be called between 2 and 3 times, "
- "but has only 1 WillOnce().",
- output);
+ EXPECT_PRED_FORMAT2(IsSubstring,
+ "Too few actions specified in EXPECT_CALL(b, DoB())...\n"
+ "Expected to be called between 2 and 3 times, "
+ "but has only 1 WillOnce().",
+ output);
b.DoB();
}
@@ -718,10 +683,12 @@ TEST(ExpectCallSyntaxTest, WarningIsErrorWithFlag) {
warning_output);
GMOCK_FLAG_SET(default_mock_behavior, kFail);
- EXPECT_NONFATAL_FAILURE({
- MockA a;
- a.DoA(0);
- }, "Uninteresting mock function call");
+ EXPECT_NONFATAL_FAILURE(
+ {
+ MockA a;
+ a.DoA(0);
+ },
+ "Uninteresting mock function call");
// Out of bounds values are converted to kWarn
GMOCK_FLAG_SET(default_mock_behavior, -1);
@@ -765,8 +732,7 @@ TEST(OnCallTest, TakesBuiltInDefaultActionWhenNoOnCall) {
// matches the invocation.
TEST(OnCallTest, TakesBuiltInDefaultActionWhenNoOnCallMatches) {
MockB b;
- ON_CALL(b, DoB(1))
- .WillByDefault(Return(1));
+ ON_CALL(b, DoB(1)).WillByDefault(Return(1));
EXPECT_CALL(b, DoB(_));
EXPECT_EQ(0, b.DoB(2));
@@ -775,12 +741,9 @@ TEST(OnCallTest, TakesBuiltInDefaultActionWhenNoOnCallMatches) {
// Tests that the last matching ON_CALL() action is taken.
TEST(OnCallTest, PicksLastMatchingOnCall) {
MockB b;
- ON_CALL(b, DoB(_))
- .WillByDefault(Return(3));
- ON_CALL(b, DoB(2))
- .WillByDefault(Return(2));
- ON_CALL(b, DoB(1))
- .WillByDefault(Return(1));
+ ON_CALL(b, DoB(_)).WillByDefault(Return(3));
+ ON_CALL(b, DoB(2)).WillByDefault(Return(2));
+ ON_CALL(b, DoB(1)).WillByDefault(Return(1));
EXPECT_CALL(b, DoB(_));
EXPECT_EQ(2, b.DoB(2));
@@ -804,25 +767,24 @@ TEST(ExpectCallTest, AllowsAnyCallWhenNoSpec) {
// Tests that the last matching EXPECT_CALL() fires.
TEST(ExpectCallTest, PicksLastMatchingExpectCall) {
MockB b;
- EXPECT_CALL(b, DoB(_))
- .WillRepeatedly(Return(2));
- EXPECT_CALL(b, DoB(1))
- .WillRepeatedly(Return(1));
+ EXPECT_CALL(b, DoB(_)).WillRepeatedly(Return(2));
+ EXPECT_CALL(b, DoB(1)).WillRepeatedly(Return(1));
EXPECT_EQ(1, b.DoB(1));
}
// Tests lower-bound violation.
TEST(ExpectCallTest, CatchesTooFewCalls) {
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- MockB b;
- EXPECT_CALL(b, DoB(5))
- .Times(AtLeast(2));
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ MockB b;
+ EXPECT_CALL(b, DoB(5)).Times(AtLeast(2));
- b.DoB(5);
- }, "Actual function call count doesn't match EXPECT_CALL(b, DoB(5))...\n"
- " Expected: to be called at least twice\n"
- " Actual: called once - unsatisfied and active");
+ b.DoB(5);
+ },
+ "Actual function call count doesn't match EXPECT_CALL(b, DoB(5))...\n"
+ " Expected: to be called at least twice\n"
+ " Actual: called once - unsatisfied and active");
}
// Tests that the cardinality can be inferred when no Times(...) is
@@ -830,28 +792,24 @@ TEST(ExpectCallTest, CatchesTooFewCalls) {
TEST(ExpectCallTest, InfersCardinalityWhenThereIsNoWillRepeatedly) {
{
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1))
- .WillOnce(Return(2));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1)).WillOnce(Return(2));
EXPECT_EQ(1, b.DoB());
EXPECT_EQ(2, b.DoB());
}
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1))
- .WillOnce(Return(2));
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ MockB b;
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1)).WillOnce(Return(2));
- EXPECT_EQ(1, b.DoB());
- }, "to be called twice");
+ EXPECT_EQ(1, b.DoB());
+ },
+ "to be called twice");
{ // NOLINT
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1))
- .WillOnce(Return(2));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1)).WillOnce(Return(2));
EXPECT_EQ(1, b.DoB());
EXPECT_EQ(2, b.DoB());
@@ -862,40 +820,34 @@ TEST(ExpectCallTest, InfersCardinalityWhenThereIsNoWillRepeatedly) {
TEST(ExpectCallTest, InfersCardinality1WhenThereIsWillRepeatedly) {
{
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1))
- .WillRepeatedly(Return(2));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1)).WillRepeatedly(Return(2));
EXPECT_EQ(1, b.DoB());
}
{ // NOLINT
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1))
- .WillRepeatedly(Return(2));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1)).WillRepeatedly(Return(2));
EXPECT_EQ(1, b.DoB());
EXPECT_EQ(2, b.DoB());
EXPECT_EQ(2, b.DoB());
}
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1))
- .WillRepeatedly(Return(2));
- }, "to be called at least once");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ MockB b;
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1)).WillRepeatedly(Return(2));
+ },
+ "to be called at least once");
}
// Tests that the n-th action is taken for the n-th matching
// invocation.
TEST(ExpectCallTest, NthMatchTakesNthAction) {
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1))
- .WillOnce(Return(2))
- .WillOnce(Return(3));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1)).WillOnce(Return(2)).WillOnce(
+ Return(3));
EXPECT_EQ(1, b.DoB());
EXPECT_EQ(2, b.DoB());
@@ -906,9 +858,7 @@ TEST(ExpectCallTest, NthMatchTakesNthAction) {
// list is exhausted.
TEST(ExpectCallTest, TakesRepeatedActionWhenWillListIsExhausted) {
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1))
- .WillRepeatedly(Return(2));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1)).WillRepeatedly(Return(2));
EXPECT_EQ(1, b.DoB());
EXPECT_EQ(2, b.DoB());
@@ -921,8 +871,7 @@ TEST(ExpectCallTest, TakesRepeatedActionWhenWillListIsExhausted) {
// exhausted and there is no WillRepeatedly().
TEST(ExpectCallTest, TakesDefaultActionWhenWillListIsExhausted) {
MockB b;
- EXPECT_CALL(b, DoB(_))
- .Times(1);
+ EXPECT_CALL(b, DoB(_)).Times(1);
EXPECT_CALL(b, DoB())
.Times(AnyNumber())
.WillOnce(Return(1))
@@ -984,8 +933,7 @@ TEST(UninterestingCallTest, DoesDefaultAction) {
// When there is an ON_CALL() statement, the action specified by it
// should be taken.
MockA a;
- ON_CALL(a, Binary(_, _))
- .WillByDefault(Return(true));
+ ON_CALL(a, Binary(_, _)).WillByDefault(Return(true));
EXPECT_TRUE(a.Binary(1, 2));
// When there is no ON_CALL(), the default value for the return type
@@ -999,8 +947,7 @@ TEST(UnexpectedCallTest, DoesDefaultAction) {
// When there is an ON_CALL() statement, the action specified by it
// should be taken.
MockA a;
- ON_CALL(a, Binary(_, _))
- .WillByDefault(Return(true));
+ ON_CALL(a, Binary(_, _)).WillByDefault(Return(true));
EXPECT_CALL(a, Binary(0, 0));
a.Binary(0, 0);
bool result = false;
@@ -1011,11 +958,9 @@ TEST(UnexpectedCallTest, DoesDefaultAction) {
// When there is no ON_CALL(), the default value for the return type
// should be returned.
MockB b;
- EXPECT_CALL(b, DoB(0))
- .Times(0);
+ EXPECT_CALL(b, DoB(0)).Times(0);
int n = -1;
- EXPECT_NONFATAL_FAILURE(n = b.DoB(1),
- "Unexpected mock function call");
+ EXPECT_NONFATAL_FAILURE(n = b.DoB(1), "Unexpected mock function call");
EXPECT_EQ(0, n);
}
@@ -1092,14 +1037,12 @@ TEST(UnexpectedCallTest, GeneartesFailureForNonVoidFunction) {
// match the call.
TEST(UnexpectedCallTest, RetiredExpectation) {
MockB b;
- EXPECT_CALL(b, DoB(1))
- .RetiresOnSaturation();
+ EXPECT_CALL(b, DoB(1)).RetiresOnSaturation();
b.DoB(1);
- EXPECT_NONFATAL_FAILURE(
- b.DoB(1),
- " Expected: the expectation is active\n"
- " Actual: it is retired");
+ EXPECT_NONFATAL_FAILURE(b.DoB(1),
+ " Expected: the expectation is active\n"
+ " Actual: it is retired");
}
// Tests that Google Mock explains that an expectation that doesn't
@@ -1108,10 +1051,9 @@ TEST(UnexpectedCallTest, UnmatchedArguments) {
MockB b;
EXPECT_CALL(b, DoB(1));
- EXPECT_NONFATAL_FAILURE(
- b.DoB(2),
- " Expected arg #0: is equal to 1\n"
- " Actual: 2\n");
+ EXPECT_NONFATAL_FAILURE(b.DoB(2),
+ " Expected arg #0: is equal to 1\n"
+ " Actual: 2\n");
b.DoB(1);
}
@@ -1120,15 +1062,10 @@ TEST(UnexpectedCallTest, UnmatchedArguments) {
TEST(UnexpectedCallTest, UnsatisifiedPrerequisites) {
Sequence s1, s2;
MockB b;
- EXPECT_CALL(b, DoB(1))
- .InSequence(s1);
- EXPECT_CALL(b, DoB(2))
- .Times(AnyNumber())
- .InSequence(s1);
- EXPECT_CALL(b, DoB(3))
- .InSequence(s2);
- EXPECT_CALL(b, DoB(4))
- .InSequence(s1, s2);
+ EXPECT_CALL(b, DoB(1)).InSequence(s1);
+ EXPECT_CALL(b, DoB(2)).Times(AnyNumber()).InSequence(s1);
+ EXPECT_CALL(b, DoB(3)).InSequence(s2);
+ EXPECT_CALL(b, DoB(4)).InSequence(s1, s2);
::testing::TestPartResultArray failures;
{
@@ -1146,23 +1083,27 @@ TEST(UnexpectedCallTest, UnsatisifiedPrerequisites) {
// Verifies that the failure message contains the two unsatisfied
// pre-requisites but not the satisfied one.
#if GTEST_USES_PCRE
- EXPECT_THAT(r.message(), ContainsRegex(
- // PCRE has trouble using (.|\n) to match any character, but
- // supports the (?s) prefix for using . to match any character.
- "(?s)the following immediate pre-requisites are not satisfied:\n"
- ".*: pre-requisite #0\n"
- ".*: pre-requisite #1"));
+ EXPECT_THAT(
+ r.message(),
+ ContainsRegex(
+ // PCRE has trouble using (.|\n) to match any character, but
+ // supports the (?s) prefix for using . to match any character.
+ "(?s)the following immediate pre-requisites are not satisfied:\n"
+ ".*: pre-requisite #0\n"
+ ".*: pre-requisite #1"));
#elif GTEST_USES_POSIX_RE
- EXPECT_THAT(r.message(), ContainsRegex(
- // POSIX RE doesn't understand the (?s) prefix, but has no trouble
- // with (.|\n).
- "the following immediate pre-requisites are not satisfied:\n"
- "(.|\n)*: pre-requisite #0\n"
- "(.|\n)*: pre-requisite #1"));
+ EXPECT_THAT(r.message(),
+ ContainsRegex(
+ // POSIX RE doesn't understand the (?s) prefix, but has no
+ // trouble with (.|\n).
+ "the following immediate pre-requisites are not satisfied:\n"
+ "(.|\n)*: pre-requisite #0\n"
+ "(.|\n)*: pre-requisite #1"));
#else
// We can only use Google Test's own simple regex.
- EXPECT_THAT(r.message(), ContainsRegex(
- "the following immediate pre-requisites are not satisfied:"));
+ EXPECT_THAT(r.message(),
+ ContainsRegex(
+ "the following immediate pre-requisites are not satisfied:"));
EXPECT_THAT(r.message(), ContainsRegex(": pre-requisite #0"));
EXPECT_THAT(r.message(), ContainsRegex(": pre-requisite #1"));
#endif // GTEST_USES_PCRE
@@ -1191,8 +1132,7 @@ TEST(ExcessiveCallTest, DoesDefaultAction) {
// When there is an ON_CALL() statement, the action specified by it
// should be taken.
MockA a;
- ON_CALL(a, Binary(_, _))
- .WillByDefault(Return(true));
+ ON_CALL(a, Binary(_, _)).WillByDefault(Return(true));
EXPECT_CALL(a, Binary(0, 0));
a.Binary(0, 0);
bool result = false;
@@ -1203,8 +1143,7 @@ TEST(ExcessiveCallTest, DoesDefaultAction) {
// When there is no ON_CALL(), the default value for the return type
// should be returned.
MockB b;
- EXPECT_CALL(b, DoB(0))
- .Times(0);
+ EXPECT_CALL(b, DoB(0)).Times(0);
int n = -1;
EXPECT_NONFATAL_FAILURE(n = b.DoB(0),
"Mock function called more times than expected");
@@ -1215,8 +1154,7 @@ TEST(ExcessiveCallTest, DoesDefaultAction) {
// the failure message contains the argument values.
TEST(ExcessiveCallTest, GeneratesFailureForVoidFunction) {
MockA a;
- EXPECT_CALL(a, DoA(_))
- .Times(0);
+ EXPECT_CALL(a, DoA(_)).Times(0);
EXPECT_NONFATAL_FAILURE(
a.DoA(9),
"Mock function called more times than expected - returning directly.\n"
@@ -1252,9 +1190,11 @@ TEST(InSequenceTest, AllExpectationInScopeAreInSequence) {
EXPECT_CALL(a, DoA(2));
}
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- a.DoA(2);
- }, "Unexpected mock function call");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ a.DoA(2);
+ },
+ "Unexpected mock function call");
a.DoA(1);
a.DoA(2);
@@ -1274,10 +1214,12 @@ TEST(InSequenceTest, NestedInSequence) {
}
}
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- a.DoA(1);
- a.DoA(3);
- }, "Unexpected mock function call");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ a.DoA(1);
+ a.DoA(3);
+ },
+ "Unexpected mock function call");
a.DoA(2);
a.DoA(3);
@@ -1293,9 +1235,11 @@ TEST(InSequenceTest, ExpectationsOutOfScopeAreNotAffected) {
}
EXPECT_CALL(a, DoA(3));
- EXPECT_NONFATAL_FAILURE({ // NOLINT
- a.DoA(2);
- }, "Unexpected mock function call");
+ EXPECT_NONFATAL_FAILURE(
+ { // NOLINT
+ a.DoA(2);
+ },
+ "Unexpected mock function call");
a.DoA(3);
a.DoA(1);
@@ -1309,8 +1253,7 @@ TEST(SequenceTest, AnyOrderIsOkByDefault) {
MockB b;
EXPECT_CALL(a, DoA(1));
- EXPECT_CALL(b, DoB())
- .Times(AnyNumber());
+ EXPECT_CALL(b, DoB()).Times(AnyNumber());
a.DoA(1);
b.DoB();
@@ -1321,8 +1264,7 @@ TEST(SequenceTest, AnyOrderIsOkByDefault) {
MockB b;
EXPECT_CALL(a, DoA(1));
- EXPECT_CALL(b, DoB())
- .Times(AnyNumber());
+ EXPECT_CALL(b, DoB()).Times(AnyNumber());
b.DoB();
a.DoA(1);
@@ -1333,16 +1275,12 @@ TEST(SequenceTest, AnyOrderIsOkByDefault) {
// is specified.
TEST(SequenceTest, CallsMustBeInStrictOrderWhenSaidSo1) {
MockA a;
- ON_CALL(a, ReturnResult(_))
- .WillByDefault(Return(Result()));
+ ON_CALL(a, ReturnResult(_)).WillByDefault(Return(Result()));
Sequence s;
- EXPECT_CALL(a, ReturnResult(1))
- .InSequence(s);
- EXPECT_CALL(a, ReturnResult(2))
- .InSequence(s);
- EXPECT_CALL(a, ReturnResult(3))
- .InSequence(s);
+ EXPECT_CALL(a, ReturnResult(1)).InSequence(s);
+ EXPECT_CALL(a, ReturnResult(2)).InSequence(s);
+ EXPECT_CALL(a, ReturnResult(3)).InSequence(s);
a.ReturnResult(1);
@@ -1357,14 +1295,11 @@ TEST(SequenceTest, CallsMustBeInStrictOrderWhenSaidSo1) {
// is specified.
TEST(SequenceTest, CallsMustBeInStrictOrderWhenSaidSo2) {
MockA a;
- ON_CALL(a, ReturnResult(_))
- .WillByDefault(Return(Result()));
+ ON_CALL(a, ReturnResult(_)).WillByDefault(Return(Result()));
Sequence s;
- EXPECT_CALL(a, ReturnResult(1))
- .InSequence(s);
- EXPECT_CALL(a, ReturnResult(2))
- .InSequence(s);
+ EXPECT_CALL(a, ReturnResult(1)).InSequence(s);
+ EXPECT_CALL(a, ReturnResult(2)).InSequence(s);
// May only be called after a.ReturnResult(1).
EXPECT_NONFATAL_FAILURE(a.ReturnResult(2), "Unexpected mock function call");
@@ -1377,8 +1312,7 @@ TEST(SequenceTest, CallsMustBeInStrictOrderWhenSaidSo2) {
class PartialOrderTest : public testing::Test {
protected:
PartialOrderTest() {
- ON_CALL(a_, ReturnResult(_))
- .WillByDefault(Return(Result()));
+ ON_CALL(a_, ReturnResult(_)).WillByDefault(Return(Result()));
// Specifies this partial ordering:
//
@@ -1386,16 +1320,10 @@ class PartialOrderTest : public testing::Test {
// a.ReturnResult(2) * n ==> a.ReturnResult(3)
// b.DoB() * 2 ==>
Sequence x, y;
- EXPECT_CALL(a_, ReturnResult(1))
- .InSequence(x);
- EXPECT_CALL(b_, DoB())
- .Times(2)
- .InSequence(y);
- EXPECT_CALL(a_, ReturnResult(2))
- .Times(AnyNumber())
- .InSequence(x, y);
- EXPECT_CALL(a_, ReturnResult(3))
- .InSequence(x);
+ EXPECT_CALL(a_, ReturnResult(1)).InSequence(x);
+ EXPECT_CALL(b_, DoB()).Times(2).InSequence(y);
+ EXPECT_CALL(a_, ReturnResult(2)).Times(AnyNumber()).InSequence(x, y);
+ EXPECT_CALL(a_, ReturnResult(3)).InSequence(x);
}
MockA a_;
@@ -1447,13 +1375,9 @@ TEST(SequenceTest, Retirement) {
MockA a;
Sequence s;
- EXPECT_CALL(a, DoA(1))
- .InSequence(s);
- EXPECT_CALL(a, DoA(_))
- .InSequence(s)
- .RetiresOnSaturation();
- EXPECT_CALL(a, DoA(1))
- .InSequence(s);
+ EXPECT_CALL(a, DoA(1)).InSequence(s);
+ EXPECT_CALL(a, DoA(_)).InSequence(s).RetiresOnSaturation();
+ EXPECT_CALL(a, DoA(1)).InSequence(s);
a.DoA(1);
a.DoA(2);
@@ -1518,12 +1442,12 @@ TEST(ExpectationSetTest, ConstructorsWork) {
Expectation e1;
const Expectation e2;
- ExpectationSet es1; // Default ctor.
+ ExpectationSet es1; // Default ctor.
ExpectationSet es2 = EXPECT_CALL(a, DoA(1)); // Ctor from EXPECT_CALL.
- ExpectationSet es3 = e1; // Ctor from Expectation.
- ExpectationSet es4(e1); // Ctor from Expectation; alternative syntax.
- ExpectationSet es5 = e2; // Ctor from const Expectation.
- ExpectationSet es6(e2); // Ctor from const Expectation; alternative syntax.
+ ExpectationSet es3 = e1; // Ctor from Expectation.
+ ExpectationSet es4(e1); // Ctor from Expectation; alternative syntax.
+ ExpectationSet es5 = e2; // Ctor from const Expectation.
+ ExpectationSet es6(e2); // Ctor from const Expectation; alternative syntax.
ExpectationSet es7 = es2; // Copy ctor.
EXPECT_EQ(0, es1.size());
@@ -1595,7 +1519,7 @@ TEST(ExpectationSetTest, IsEnumerable) {
EXPECT_TRUE(it != es.end());
EXPECT_THAT(*it, Eq(Expectation()));
++it;
- EXPECT_TRUE(it== es.end());
+ EXPECT_TRUE(it == es.end());
}
// Tests the .After() clause.
@@ -1605,8 +1529,7 @@ TEST(AfterTest, SucceedsWhenPartialOrderIsSatisfied) {
ExpectationSet es;
es += EXPECT_CALL(a, DoA(1));
es += EXPECT_CALL(a, DoA(2));
- EXPECT_CALL(a, DoA(3))
- .After(es);
+ EXPECT_CALL(a, DoA(3)).After(es);
a.DoA(1);
a.DoA(2);
@@ -1619,9 +1542,7 @@ TEST(AfterTest, SucceedsWhenTotalOrderIsSatisfied) {
// The following also verifies that const Expectation objects work
// too. Do not remove the const modifiers.
const Expectation e1 = EXPECT_CALL(a, DoA(1));
- const Expectation e2 = EXPECT_CALL(b, DoB())
- .Times(2)
- .After(e1);
+ const Expectation e2 = EXPECT_CALL(b, DoB()).Times(2).After(e1);
EXPECT_CALL(a, DoA(2)).After(e2);
a.DoA(1);
@@ -1638,10 +1559,8 @@ TEST(AfterTest, CallsMustBeInStrictOrderWhenSpecifiedSo1) {
// Define ordering:
// a.DoA(1) ==> b.DoB() ==> a.DoA(2)
Expectation e1 = EXPECT_CALL(a, DoA(1));
- Expectation e2 = EXPECT_CALL(b, DoB())
- .After(e1);
- EXPECT_CALL(a, DoA(2))
- .After(e2);
+ Expectation e2 = EXPECT_CALL(b, DoB()).After(e1);
+ EXPECT_CALL(a, DoA(2)).After(e2);
a.DoA(1);
@@ -1660,11 +1579,8 @@ TEST(AfterTest, CallsMustBeInStrictOrderWhenSpecifiedSo2) {
// Define ordering:
// a.DoA(1) ==> b.DoB() * 2 ==> a.DoA(2)
Expectation e1 = EXPECT_CALL(a, DoA(1));
- Expectation e2 = EXPECT_CALL(b, DoB())
- .Times(2)
- .After(e1);
- EXPECT_CALL(a, DoA(2))
- .After(e2);
+ Expectation e2 = EXPECT_CALL(b, DoB()).Times(2).After(e1);
+ EXPECT_CALL(a, DoA(2)).After(e2);
a.DoA(1);
b.DoB();
@@ -1679,16 +1595,14 @@ TEST(AfterTest, CallsMustBeInStrictOrderWhenSpecifiedSo2) {
// Calls must satisfy the partial order when specified so.
TEST(AfterTest, CallsMustSatisfyPartialOrderWhenSpecifiedSo) {
MockA a;
- ON_CALL(a, ReturnResult(_))
- .WillByDefault(Return(Result()));
+ ON_CALL(a, ReturnResult(_)).WillByDefault(Return(Result()));
// Define ordering:
// a.DoA(1) ==>
// a.DoA(2) ==> a.ReturnResult(3)
Expectation e = EXPECT_CALL(a, DoA(1));
const ExpectationSet es = EXPECT_CALL(a, DoA(2));
- EXPECT_CALL(a, ReturnResult(3))
- .After(e, es);
+ EXPECT_CALL(a, ReturnResult(3)).After(e, es);
// May only be called last.
EXPECT_NONFATAL_FAILURE(a.ReturnResult(3), "Unexpected mock function call");
@@ -1707,8 +1621,7 @@ TEST(AfterTest, CallsMustSatisfyPartialOrderWhenSpecifiedSo2) {
// a.DoA(2) ==> a.DoA(3)
Expectation e = EXPECT_CALL(a, DoA(1));
const ExpectationSet es = EXPECT_CALL(a, DoA(2));
- EXPECT_CALL(a, DoA(3))
- .After(e, es);
+ EXPECT_CALL(a, DoA(3)).After(e, es);
a.DoA(2);
@@ -1725,9 +1638,7 @@ TEST(AfterTest, CanBeUsedWithInSequence) {
Sequence s;
Expectation e = EXPECT_CALL(a, DoA(1));
EXPECT_CALL(a, DoA(2)).InSequence(s);
- EXPECT_CALL(a, DoA(3))
- .InSequence(s)
- .After(e);
+ EXPECT_CALL(a, DoA(3)).InSequence(s).After(e);
a.DoA(1);
@@ -1744,10 +1655,7 @@ TEST(AfterTest, CanBeCalledManyTimes) {
Expectation e1 = EXPECT_CALL(a, DoA(1));
Expectation e2 = EXPECT_CALL(a, DoA(2));
Expectation e3 = EXPECT_CALL(a, DoA(3));
- EXPECT_CALL(a, DoA(4))
- .After(e1)
- .After(e2)
- .After(e3);
+ EXPECT_CALL(a, DoA(4)).After(e1).After(e2).After(e3);
a.DoA(3);
a.DoA(1);
@@ -1763,8 +1671,7 @@ TEST(AfterTest, AcceptsUpToFiveArguments) {
Expectation e3 = EXPECT_CALL(a, DoA(3));
ExpectationSet es1 = EXPECT_CALL(a, DoA(4));
ExpectationSet es2 = EXPECT_CALL(a, DoA(5));
- EXPECT_CALL(a, DoA(6))
- .After(e1, e2, e3, es1, es2);
+ EXPECT_CALL(a, DoA(6)).After(e1, e2, e3, es1, es2);
a.DoA(5);
a.DoA(2);
@@ -1777,8 +1684,7 @@ TEST(AfterTest, AcceptsUpToFiveArguments) {
// .After() allows input to contain duplicated Expectations.
TEST(AfterTest, AcceptsDuplicatedInput) {
MockA a;
- ON_CALL(a, ReturnResult(_))
- .WillByDefault(Return(Result()));
+ ON_CALL(a, ReturnResult(_)).WillByDefault(Return(Result()));
// Define ordering:
// DoA(1) ==>
@@ -1788,8 +1694,7 @@ TEST(AfterTest, AcceptsDuplicatedInput) {
ExpectationSet es;
es += e1;
es += e2;
- EXPECT_CALL(a, ReturnResult(3))
- .After(e1, e2, es, e1);
+ EXPECT_CALL(a, ReturnResult(3)).After(e1, e2, es, e1);
a.DoA(1);
@@ -1806,8 +1711,7 @@ TEST(AfterTest, ChangesToExpectationSetHaveNoEffectAfterwards) {
MockA a;
ExpectationSet es1 = EXPECT_CALL(a, DoA(1));
Expectation e2 = EXPECT_CALL(a, DoA(2));
- EXPECT_CALL(a, DoA(3))
- .After(es1);
+ EXPECT_CALL(a, DoA(3)).After(es1);
es1 += e2;
a.DoA(1);
@@ -1826,14 +1730,11 @@ TEST(DeletingMockEarlyTest, Success1) {
{
InSequence dummy;
- EXPECT_CALL(*b1, DoB(_))
- .WillOnce(Return(1));
+ EXPECT_CALL(*b1, DoB(_)).WillOnce(Return(1));
EXPECT_CALL(*a, Binary(_, _))
.Times(AnyNumber())
.WillRepeatedly(Return(true));
- EXPECT_CALL(*b2, DoB(_))
- .Times(AnyNumber())
- .WillRepeatedly(Return(2));
+ EXPECT_CALL(*b2, DoB(_)).Times(AnyNumber()).WillRepeatedly(Return(2));
}
EXPECT_EQ(1, b1->DoB(1));
@@ -1854,13 +1755,9 @@ TEST(DeletingMockEarlyTest, Success2) {
{
InSequence dummy;
- EXPECT_CALL(*b1, DoB(_))
- .WillOnce(Return(1));
- EXPECT_CALL(*a, Binary(_, _))
- .Times(AnyNumber());
- EXPECT_CALL(*b2, DoB(_))
- .Times(AnyNumber())
- .WillRepeatedly(Return(2));
+ EXPECT_CALL(*b1, DoB(_)).WillOnce(Return(1));
+ EXPECT_CALL(*a, Binary(_, _)).Times(AnyNumber());
+ EXPECT_CALL(*b2, DoB(_)).Times(AnyNumber()).WillRepeatedly(Return(2));
}
delete a; // a is trivially satisfied.
@@ -1875,14 +1772,14 @@ TEST(DeletingMockEarlyTest, Success2) {
// Suppresses warning on unreferenced formal parameter in MSVC with
// -W4.
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
+#pragma warning(push)
+#pragma warning(disable : 4100)
#endif
ACTION_P(Delete, ptr) { delete ptr; }
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
TEST(DeletingMockEarlyTest, CanDeleteSelfInActionReturningVoid) {
@@ -1893,8 +1790,7 @@ TEST(DeletingMockEarlyTest, CanDeleteSelfInActionReturningVoid) {
TEST(DeletingMockEarlyTest, CanDeleteSelfInActionReturningValue) {
MockA* const a = new MockA;
- EXPECT_CALL(*a, ReturnResult(_))
- .WillOnce(DoAll(Delete(a), Return(Result())));
+ EXPECT_CALL(*a, ReturnResult(_)).WillOnce(DoAll(Delete(a), Return(Result())));
a->ReturnResult(42); // This will cause a to be deleted.
}
@@ -1906,19 +1802,13 @@ TEST(DeletingMockEarlyTest, Failure1) {
{
InSequence dummy;
- EXPECT_CALL(*b1, DoB(_))
- .WillOnce(Return(1));
- EXPECT_CALL(*a, Binary(_, _))
- .Times(AnyNumber());
- EXPECT_CALL(*b2, DoB(_))
- .Times(AnyNumber())
- .WillRepeatedly(Return(2));
+ EXPECT_CALL(*b1, DoB(_)).WillOnce(Return(1));
+ EXPECT_CALL(*a, Binary(_, _)).Times(AnyNumber());
+ EXPECT_CALL(*b2, DoB(_)).Times(AnyNumber()).WillRepeatedly(Return(2));
}
delete a; // a is trivially satisfied.
- EXPECT_NONFATAL_FAILURE({
- b2->DoB(2);
- }, "Unexpected mock function call");
+ EXPECT_NONFATAL_FAILURE({ b2->DoB(2); }, "Unexpected mock function call");
EXPECT_EQ(1, b1->DoB(1));
delete b1;
delete b2;
@@ -1933,18 +1823,13 @@ TEST(DeletingMockEarlyTest, Failure2) {
{
InSequence dummy;
EXPECT_CALL(*b1, DoB(_));
- EXPECT_CALL(*a, Binary(_, _))
- .Times(AnyNumber());
- EXPECT_CALL(*b2, DoB(_))
- .Times(AnyNumber());
+ EXPECT_CALL(*a, Binary(_, _)).Times(AnyNumber());
+ EXPECT_CALL(*b2, DoB(_)).Times(AnyNumber());
}
- EXPECT_NONFATAL_FAILURE(delete b1,
- "Actual: never called");
- EXPECT_NONFATAL_FAILURE(a->Binary(0, 1),
- "Unexpected mock function call");
- EXPECT_NONFATAL_FAILURE(b2->DoB(1),
- "Unexpected mock function call");
+ EXPECT_NONFATAL_FAILURE(delete b1, "Actual: never called");
+ EXPECT_NONFATAL_FAILURE(a->Binary(0, 1), "Unexpected mock function call");
+ EXPECT_NONFATAL_FAILURE(b2->DoB(1), "Unexpected mock function call");
delete a;
delete b2;
}
@@ -1969,23 +1854,16 @@ class EvenNumberCardinality : public CardinalityInterface {
}
};
-Cardinality EvenNumber() {
- return Cardinality(new EvenNumberCardinality);
-}
+Cardinality EvenNumber() { return Cardinality(new EvenNumberCardinality); }
TEST(ExpectationBaseTest,
AllPrerequisitesAreSatisfiedWorksForNonMonotonicCardinality) {
MockA* a = new MockA;
Sequence s;
- EXPECT_CALL(*a, DoA(1))
- .Times(EvenNumber())
- .InSequence(s);
- EXPECT_CALL(*a, DoA(2))
- .Times(AnyNumber())
- .InSequence(s);
- EXPECT_CALL(*a, DoA(3))
- .Times(AnyNumber());
+ EXPECT_CALL(*a, DoA(1)).Times(EvenNumber()).InSequence(s);
+ EXPECT_CALL(*a, DoA(2)).Times(AnyNumber()).InSequence(s);
+ EXPECT_CALL(*a, DoA(3)).Times(AnyNumber());
a->DoA(3);
a->DoA(1);
@@ -1996,8 +1874,7 @@ TEST(ExpectationBaseTest,
// The following tests verify the message generated when a mock
// function is called.
-struct Printable {
-};
+struct Printable {};
inline void operator<<(::std::ostream& os, const Printable&) {
os << "Printable";
@@ -2064,7 +1941,7 @@ TEST(FunctionCallMessageTest,
EXPECT_PRED_FORMAT2(IsSubstring, "GMOCK WARNING", output);
EXPECT_PRED_FORMAT2(IsSubstring, "Stack trace:", output);
-# ifndef NDEBUG
+#ifndef NDEBUG
// We check the stack trace content in dbg-mode only, as opt-mode
// may inline the call we are interested in seeing.
@@ -2080,7 +1957,7 @@ TEST(FunctionCallMessageTest,
const std::string output2 = GetCapturedStdout();
EXPECT_PRED_FORMAT2(IsSubstring, "NonVoidMethod(", output2);
-# endif // NDEBUG
+#endif // NDEBUG
}
// Tests that an uninteresting mock function call on a naggy mock
@@ -2096,7 +1973,8 @@ TEST(FunctionCallMessageTest,
IsSubstring,
"Uninteresting mock function call - returning default value.\n"
" Function call: DoB()\n"
- " Returns: 0\n", output1.c_str());
+ " Returns: 0\n",
+ output1.c_str());
// Makes sure the return value is printed.
// A void mock function.
@@ -2104,12 +1982,12 @@ TEST(FunctionCallMessageTest,
CaptureStdout();
c.VoidMethod(false, 5, "Hi", nullptr, Printable(), Unprintable());
const std::string output2 = GetCapturedStdout();
- EXPECT_THAT(output2.c_str(),
- ContainsRegex(
- "Uninteresting mock function call - returning directly\\.\n"
- " Function call: VoidMethod"
- "\\(false, 5, \"Hi\", NULL, @.+ "
- "Printable, 4-byte object <00-00 00-00>\\)"));
+ EXPECT_THAT(
+ output2.c_str(),
+ ContainsRegex("Uninteresting mock function call - returning directly\\.\n"
+ " Function call: VoidMethod"
+ "\\(false, 5, \"Hi\", NULL, @.+ "
+ "Printable, 4-byte object <00-00 00-00>\\)"));
// A void function has no return value to print.
}
@@ -2126,14 +2004,14 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture {
const std::string& function_name) {
if (should_print) {
EXPECT_THAT(output.c_str(), HasSubstr(expected_substring));
-# ifndef NDEBUG
+#ifndef NDEBUG
// We check the stack trace content in dbg-mode only, as opt-mode
// may inline the call we are interested in seeing.
EXPECT_THAT(output.c_str(), HasSubstr(function_name));
-# else
+#else
// Suppresses 'unused function parameter' warnings.
static_cast<void>(function_name);
-# endif // NDEBUG
+#endif // NDEBUG
} else {
EXPECT_STREQ("", output.c_str());
}
@@ -2143,31 +2021,26 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture {
void TestExpectedCall(bool should_print) {
MockA a;
EXPECT_CALL(a, DoA(5));
- EXPECT_CALL(a, Binary(_, 1))
- .WillOnce(Return(true));
+ EXPECT_CALL(a, Binary(_, 1)).WillOnce(Return(true));
// A void-returning function.
CaptureStdout();
a.DoA(5);
- VerifyOutput(
- GetCapturedStdout(),
- should_print,
- "Mock function call matches EXPECT_CALL(a, DoA(5))...\n"
- " Function call: DoA(5)\n"
- "Stack trace:\n",
- "DoA");
+ VerifyOutput(GetCapturedStdout(), should_print,
+ "Mock function call matches EXPECT_CALL(a, DoA(5))...\n"
+ " Function call: DoA(5)\n"
+ "Stack trace:\n",
+ "DoA");
// A non-void-returning function.
CaptureStdout();
a.Binary(2, 1);
- VerifyOutput(
- GetCapturedStdout(),
- should_print,
- "Mock function call matches EXPECT_CALL(a, Binary(_, 1))...\n"
- " Function call: Binary(2, 1)\n"
- " Returns: true\n"
- "Stack trace:\n",
- "Binary");
+ VerifyOutput(GetCapturedStdout(), should_print,
+ "Mock function call matches EXPECT_CALL(a, Binary(_, 1))...\n"
+ " Function call: Binary(2, 1)\n"
+ " Returns: true\n"
+ "Stack trace:\n",
+ "Binary");
}
// Tests how the flag affects uninteresting calls on a naggy mock.
@@ -2185,27 +2058,23 @@ class GMockVerboseFlagTest : public VerboseFlagPreservingFixture {
// A void-returning function.
CaptureStdout();
a.DoA(5);
- VerifyOutput(
- GetCapturedStdout(),
- should_print,
- "\nGMOCK WARNING:\n"
- "Uninteresting mock function call - returning directly.\n"
- " Function call: DoA(5)\n" +
- note,
- "DoA");
+ VerifyOutput(GetCapturedStdout(), should_print,
+ "\nGMOCK WARNING:\n"
+ "Uninteresting mock function call - returning directly.\n"
+ " Function call: DoA(5)\n" +
+ note,
+ "DoA");
// A non-void-returning function.
CaptureStdout();
a.Binary(2, 1);
- VerifyOutput(
- GetCapturedStdout(),
- should_print,
- "\nGMOCK WARNING:\n"
- "Uninteresting mock function call - returning default value.\n"
- " Function call: Binary(2, 1)\n"
- " Returns: false\n" +
- note,
- "Binary");
+ VerifyOutput(GetCapturedStdout(), should_print,
+ "\nGMOCK WARNING:\n"
+ "Uninteresting mock function call - returning default value.\n"
+ " Function call: Binary(2, 1)\n"
+ " Returns: false\n" +
+ note,
+ "Binary");
}
};
@@ -2270,22 +2139,19 @@ class GMockLogTest : public VerboseFlagPreservingFixture {
TEST_F(GMockLogTest, DoesNotPrintGoodCallInternallyIfVerbosityIsWarning) {
GMOCK_FLAG_SET(verbose, kWarningVerbosity);
- EXPECT_CALL(helper_, Foo(_))
- .WillOnce(Return(PrintMeNot()));
+ EXPECT_CALL(helper_, Foo(_)).WillOnce(Return(PrintMeNot()));
helper_.Foo(PrintMeNot()); // This is an expected call.
}
TEST_F(GMockLogTest, DoesNotPrintGoodCallInternallyIfVerbosityIsError) {
GMOCK_FLAG_SET(verbose, kErrorVerbosity);
- EXPECT_CALL(helper_, Foo(_))
- .WillOnce(Return(PrintMeNot()));
+ EXPECT_CALL(helper_, Foo(_)).WillOnce(Return(PrintMeNot()));
helper_.Foo(PrintMeNot()); // This is an expected call.
}
TEST_F(GMockLogTest, DoesNotPrintWarningInternallyIfVerbosityIsError) {
GMOCK_FLAG_SET(verbose, kErrorVerbosity);
- ON_CALL(helper_, Foo(_))
- .WillByDefault(Return(PrintMeNot()));
+ ON_CALL(helper_, Foo(_)).WillByDefault(Return(PrintMeNot()));
helper_.Foo(PrintMeNot()); // This should generate a warning.
}
@@ -2346,8 +2212,7 @@ TEST(VerifyAndClearExpectationsTest, NoMethodHasExpectations) {
// verification succeeds.
TEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndSucceed) {
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1));
b.DoB();
ASSERT_TRUE(Mock::VerifyAndClearExpectations(&b));
@@ -2362,8 +2227,7 @@ TEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndSucceed) {
// verification fails.
TEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndFail) {
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1));
bool result = true;
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
"Actual: never called");
@@ -2379,10 +2243,8 @@ TEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndFail) {
// when all of its methods have expectations.
TEST(VerifyAndClearExpectationsTest, AllMethodsHaveExpectations) {
MockB b;
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(1));
- EXPECT_CALL(b, DoB(_))
- .WillOnce(Return(2));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(1));
+ EXPECT_CALL(b, DoB(_)).WillOnce(Return(2));
b.DoB();
b.DoB(1);
ASSERT_TRUE(Mock::VerifyAndClearExpectations(&b));
@@ -2397,10 +2259,8 @@ TEST(VerifyAndClearExpectationsTest, AllMethodsHaveExpectations) {
// when a method has more than one expectation.
TEST(VerifyAndClearExpectationsTest, AMethodHasManyExpectations) {
MockB b;
- EXPECT_CALL(b, DoB(0))
- .WillOnce(Return(1));
- EXPECT_CALL(b, DoB(_))
- .WillOnce(Return(2));
+ EXPECT_CALL(b, DoB(0)).WillOnce(Return(1));
+ EXPECT_CALL(b, DoB(_)).WillOnce(Return(2));
b.DoB(1);
bool result = true;
EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),
@@ -2421,8 +2281,7 @@ TEST(VerifyAndClearExpectationsTest, CanCallManyTimes) {
b.DoB();
Mock::VerifyAndClearExpectations(&b);
- EXPECT_CALL(b, DoB(_))
- .WillOnce(Return(1));
+ EXPECT_CALL(b, DoB(_)).WillOnce(Return(1));
b.DoB(1);
Mock::VerifyAndClearExpectations(&b);
Mock::VerifyAndClearExpectations(&b);
@@ -2446,8 +2305,7 @@ TEST(VerifyAndClearTest, NoMethodHasDefaultActions) {
// but not all of its methods have default actions.
TEST(VerifyAndClearTest, SomeMethodsHaveDefaultActions) {
MockB b;
- ON_CALL(b, DoB())
- .WillByDefault(Return(1));
+ ON_CALL(b, DoB()).WillByDefault(Return(1));
Mock::VerifyAndClear(&b);
@@ -2459,10 +2317,8 @@ TEST(VerifyAndClearTest, SomeMethodsHaveDefaultActions) {
// its methods have default actions.
TEST(VerifyAndClearTest, AllMethodsHaveDefaultActions) {
MockB b;
- ON_CALL(b, DoB())
- .WillByDefault(Return(1));
- ON_CALL(b, DoB(_))
- .WillByDefault(Return(2));
+ ON_CALL(b, DoB()).WillByDefault(Return(1));
+ ON_CALL(b, DoB(_)).WillByDefault(Return(2));
Mock::VerifyAndClear(&b);
@@ -2477,10 +2333,8 @@ TEST(VerifyAndClearTest, AllMethodsHaveDefaultActions) {
// method has more than one ON_CALL() set on it.
TEST(VerifyAndClearTest, AMethodHasManyDefaultActions) {
MockB b;
- ON_CALL(b, DoB(0))
- .WillByDefault(Return(1));
- ON_CALL(b, DoB(_))
- .WillByDefault(Return(2));
+ ON_CALL(b, DoB(0)).WillByDefault(Return(1));
+ ON_CALL(b, DoB(_)).WillByDefault(Return(2));
Mock::VerifyAndClear(&b);
@@ -2494,13 +2348,11 @@ TEST(VerifyAndClearTest, AMethodHasManyDefaultActions) {
// times.
TEST(VerifyAndClearTest, CanCallManyTimes) {
MockB b;
- ON_CALL(b, DoB())
- .WillByDefault(Return(1));
+ ON_CALL(b, DoB()).WillByDefault(Return(1));
Mock::VerifyAndClear(&b);
Mock::VerifyAndClear(&b);
- ON_CALL(b, DoB(_))
- .WillByDefault(Return(1));
+ ON_CALL(b, DoB(_)).WillByDefault(Return(1));
Mock::VerifyAndClear(&b);
EXPECT_EQ(0, b.DoB());
@@ -2510,10 +2362,8 @@ TEST(VerifyAndClearTest, CanCallManyTimes) {
// Tests that VerifyAndClear() works when the verification succeeds.
TEST(VerifyAndClearTest, Success) {
MockB b;
- ON_CALL(b, DoB())
- .WillByDefault(Return(1));
- EXPECT_CALL(b, DoB(1))
- .WillOnce(Return(2));
+ ON_CALL(b, DoB()).WillByDefault(Return(1));
+ EXPECT_CALL(b, DoB(1)).WillOnce(Return(2));
b.DoB();
b.DoB(1);
@@ -2528,10 +2378,8 @@ TEST(VerifyAndClearTest, Success) {
// Tests that VerifyAndClear() works when the verification fails.
TEST(VerifyAndClearTest, Failure) {
MockB b;
- ON_CALL(b, DoB(_))
- .WillByDefault(Return(1));
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(2));
+ ON_CALL(b, DoB(_)).WillByDefault(Return(1));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(2));
b.DoB(1);
bool result = true;
@@ -2549,12 +2397,9 @@ TEST(VerifyAndClearTest, Failure) {
// expectations are set on a const mock object.
TEST(VerifyAndClearTest, Const) {
MockB b;
- ON_CALL(Const(b), DoB())
- .WillByDefault(Return(1));
+ ON_CALL(Const(b), DoB()).WillByDefault(Return(1));
- EXPECT_CALL(Const(b), DoB())
- .WillOnce(DoDefault())
- .WillOnce(Return(2));
+ EXPECT_CALL(Const(b), DoB()).WillOnce(DoDefault()).WillOnce(Return(2));
b.DoB();
b.DoB();
@@ -2570,18 +2415,14 @@ TEST(VerifyAndClearTest, Const) {
// object after VerifyAndClear() has been called on it.
TEST(VerifyAndClearTest, CanSetDefaultActionsAndExpectationsAfterwards) {
MockB b;
- ON_CALL(b, DoB())
- .WillByDefault(Return(1));
- EXPECT_CALL(b, DoB(_))
- .WillOnce(Return(2));
+ ON_CALL(b, DoB()).WillByDefault(Return(1));
+ EXPECT_CALL(b, DoB(_)).WillOnce(Return(2));
b.DoB(1);
Mock::VerifyAndClear(&b);
- EXPECT_CALL(b, DoB())
- .WillOnce(Return(3));
- ON_CALL(b, DoB(_))
- .WillByDefault(Return(4));
+ EXPECT_CALL(b, DoB()).WillOnce(Return(3));
+ ON_CALL(b, DoB(_)).WillByDefault(Return(4));
EXPECT_EQ(3, b.DoB());
EXPECT_EQ(4, b.DoB(1));
@@ -2594,19 +2435,13 @@ TEST(VerifyAndClearTest, DoesNotAffectOtherMockObjects) {
MockB b1;
MockB b2;
- ON_CALL(a, Binary(_, _))
- .WillByDefault(Return(true));
- EXPECT_CALL(a, Binary(_, _))
- .WillOnce(DoDefault())
- .WillOnce(Return(false));
+ ON_CALL(a, Binary(_, _)).WillByDefault(Return(true));
+ EXPECT_CALL(a, Binary(_, _)).WillOnce(DoDefault()).WillOnce(Return(false));
- ON_CALL(b1, DoB())
- .WillByDefault(Return(1));
- EXPECT_CALL(b1, DoB(_))
- .WillOnce(Return(2));
+ ON_CALL(b1, DoB()).WillByDefault(Return(1));
+ EXPECT_CALL(b1, DoB(_)).WillOnce(Return(2));
- ON_CALL(b2, DoB())
- .WillByDefault(Return(3));
+ ON_CALL(b2, DoB()).WillByDefault(Return(3));
EXPECT_CALL(b2, DoB(_));
b2.DoB(0);
@@ -2647,8 +2482,7 @@ TEST(VerifyAndClearTest,
ReferenceHoldingMock test_mock;
// ON_CALL stores a reference to a inside test_mock.
- ON_CALL(test_mock, AcceptReference(_))
- .WillByDefault(SetArgPointee<0>(a));
+ ON_CALL(test_mock, AcceptReference(_)).WillByDefault(SetArgPointee<0>(a));
// Throw away the reference to the mock that we have in a. After this, the
// only reference to it is stored by test_mock.
@@ -2669,9 +2503,8 @@ TEST(VerifyAndClearTest,
TEST(SynchronizationTest, CanCallMockMethodInAction) {
MockA a;
MockC c;
- ON_CALL(a, DoA(_))
- .WillByDefault(IgnoreResult(InvokeWithoutArgs(&c,
- &MockC::NonVoidMethod)));
+ ON_CALL(a, DoA(_)).WillByDefault(
+ IgnoreResult(InvokeWithoutArgs(&c, &MockC::NonVoidMethod)));
EXPECT_CALL(a, DoA(1));
EXPECT_CALL(a, DoA(1))
.WillOnce(Invoke(&a, &MockA::DoA))
@@ -2760,9 +2593,9 @@ TEST(ParameterlessExpectationsTest,
// from it. This might be necessary on some platforms which require
// specific setup and teardown.
#if GMOCK_RENAME_MAIN
-int gmock_main(int argc, char **argv) {
+int gmock_main(int argc, char** argv) {
#else
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
#endif // GMOCK_RENAME_MAIN
testing::InitGoogleMock(&argc, argv);
// Ensures that the tests pass no matter what value of
diff --git a/googlemock/test/gmock_ex_test.cc b/googlemock/test/gmock_ex_test.cc
index 72eb43f..44e5e35 100644
--- a/googlemock/test/gmock_ex_test.cc
+++ b/googlemock/test/gmock_ex_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Tests Google Mock's functionality that depends on exceptions.
#include "gmock/gmock.h"
@@ -75,6 +74,5 @@ TEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {
}
}
-
} // unnamed namespace
#endif
diff --git a/googlemock/test/gmock_leak_test_.cc b/googlemock/test/gmock_leak_test_.cc
index 2e095ab..ad6f6d6 100644
--- a/googlemock/test/gmock_leak_test_.cc
+++ b/googlemock/test/gmock_leak_test_.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This program is for verifying that a leaked mock object can be
diff --git a/googlemock/test/gmock_link2_test.cc b/googlemock/test/gmock_link2_test.cc
index d27ce17..cd3d690 100644
--- a/googlemock/test/gmock_link2_test.cc
+++ b/googlemock/test/gmock_link2_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file is for verifying that various Google Mock constructs do not
diff --git a/googlemock/test/gmock_link_test.cc b/googlemock/test/gmock_link_test.cc
index e7c54cc..f51e398 100644
--- a/googlemock/test/gmock_link_test.cc
+++ b/googlemock/test/gmock_link_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file is for verifying that various Google Mock constructs do not
diff --git a/googlemock/test/gmock_link_test.h b/googlemock/test/gmock_link_test.h
index 5734b2e..dc9bd85 100644
--- a/googlemock/test/gmock_link_test.h
+++ b/googlemock/test/gmock_link_test.h
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests that:
@@ -118,7 +117,7 @@
#include "gmock/gmock.h"
#if !GTEST_OS_WINDOWS_MOBILE
-# include <errno.h>
+#include <errno.h>
#endif
#include <iostream>
@@ -200,14 +199,14 @@ class Interface {
virtual char* StringFromString(char* str) = 0;
virtual int IntFromString(char* str) = 0;
virtual int& IntRefFromString(char* str) = 0;
- virtual void VoidFromFunc(void(*func)(char* str)) = 0;
+ virtual void VoidFromFunc(void (*func)(char* str)) = 0;
virtual void VoidFromIntRef(int& n) = 0; // NOLINT
virtual void VoidFromFloat(float n) = 0;
virtual void VoidFromDouble(double n) = 0;
virtual void VoidFromVector(const std::vector<int>& v) = 0;
};
-class Mock: public Interface {
+class Mock : public Interface {
public:
Mock() {}
@@ -215,7 +214,7 @@ class Mock: public Interface {
MOCK_METHOD1(StringFromString, char*(char* str));
MOCK_METHOD1(IntFromString, int(char* str));
MOCK_METHOD1(IntRefFromString, int&(char* str));
- MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str)));
+ MOCK_METHOD1(VoidFromFunc, void(void (*func)(char* str)));
MOCK_METHOD1(VoidFromIntRef, void(int& n)); // NOLINT
MOCK_METHOD1(VoidFromFloat, void(float n));
MOCK_METHOD1(VoidFromDouble, void(double n));
@@ -301,8 +300,8 @@ TEST(LinkTest, TestSetArrayArgument) {
char ch = 'x';
char ch2 = 'y';
- EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,
- &ch2 + 1));
+ EXPECT_CALL(mock, VoidFromString(_))
+ .WillOnce(SetArrayArgument<0>(&ch2, &ch2 + 1));
mock.VoidFromString(&ch);
}
@@ -339,8 +338,8 @@ TEST(LinkTest, TestInvokeWithoutArgs) {
EXPECT_CALL(mock, VoidFromString(_))
.WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))
- .WillOnce(InvokeWithoutArgs(&test_invoke_helper,
- &InvokeHelper::VoidFromVoid));
+ .WillOnce(
+ InvokeWithoutArgs(&test_invoke_helper, &InvokeHelper::VoidFromVoid));
mock.VoidFromString(nullptr);
mock.VoidFromString(nullptr);
}
@@ -424,14 +423,14 @@ TEST(LinkTest, TestThrow) {
// is expanded and macro expansion cannot contain #pragma. Therefore
// we suppress them here.
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
+#pragma warning(push)
+#pragma warning(disable : 4100)
#endif
// Tests the linkage of actions created using ACTION macro.
namespace {
ACTION(Return1) { return 1; }
-}
+} // namespace
TEST(LinkTest, TestActionMacro) {
Mock mock;
@@ -443,7 +442,7 @@ TEST(LinkTest, TestActionMacro) {
// Tests the linkage of actions created using ACTION_P macro.
namespace {
ACTION_P(ReturnArgument, ret_value) { return ret_value; }
-}
+} // namespace
TEST(LinkTest, TestActionPMacro) {
Mock mock;
@@ -457,10 +456,10 @@ namespace {
ACTION_P2(ReturnEqualsEitherOf, first, second) {
return arg0 == first || arg0 == second;
}
-}
+} // namespace
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
TEST(LinkTest, TestActionP2Macro) {
@@ -492,8 +491,7 @@ TEST(LinkTest, TestMatchersEq) {
const char* p = "x";
ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return());
- ON_CALL(mock, VoidFromString(const_cast<char*>("y")))
- .WillByDefault(Return());
+ ON_CALL(mock, VoidFromString(const_cast<char*>("y"))).WillByDefault(Return());
}
// Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers.
@@ -592,7 +590,7 @@ TEST(LinkTest, TestMatcherElementsAre) {
// Tests the linkage of the ElementsAreArray matcher.
TEST(LinkTest, TestMatcherElementsAreArray) {
Mock mock;
- char arr[] = { 'a', 'b' };
+ char arr[] = {'a', 'b'};
ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());
}
diff --git a/googlemock/test/gmock_output_test_.cc b/googlemock/test/gmock_output_test_.cc
index b1dac45..b4abbc9 100644
--- a/googlemock/test/gmock_output_test_.cc
+++ b/googlemock/test/gmock_output_test_.cc
@@ -27,21 +27,20 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Tests Google Mock's output in various scenarios. This ensures that
// Google Mock's messages are readable and useful.
-#include "gmock/gmock.h"
-
#include <stdio.h>
+
#include <string>
+#include "gmock/gmock.h"
#include "gtest/gtest.h"
// Silence C4100 (unreferenced formal parameter)
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable:4100)
+#pragma warning(push)
+#pragma warning(disable : 4100)
#endif
using testing::_;
@@ -90,9 +89,7 @@ TEST_F(GMockOutputTest, ExpectedCallToVoidFunction) {
}
TEST_F(GMockOutputTest, ExplicitActionsRunOut) {
- EXPECT_CALL(foo_, Bar2(_, _))
- .Times(2)
- .WillOnce(Return(false));
+ EXPECT_CALL(foo_, Bar2(_, _)).Times(2).WillOnce(Return(false));
foo_.Bar2(2, 2);
foo_.Bar2(1, 1); // Explicit actions in EXPECT_CALL run out.
}
@@ -134,8 +131,7 @@ TEST_F(GMockOutputTest, UninterestingCallToVoidFunction) {
}
TEST_F(GMockOutputTest, RetiredExpectation) {
- EXPECT_CALL(foo_, Bar2(_, _))
- .RetiresOnSaturation();
+ EXPECT_CALL(foo_, Bar2(_, _)).RetiresOnSaturation();
EXPECT_CALL(foo_, Bar2(0, 0));
foo_.Bar2(1, 1);
@@ -160,12 +156,9 @@ TEST_F(GMockOutputTest, UnsatisfiedPrerequisite) {
TEST_F(GMockOutputTest, UnsatisfiedPrerequisites) {
Sequence s1, s2;
- EXPECT_CALL(foo_, Bar(_, 0, _))
- .InSequence(s1);
- EXPECT_CALL(foo_, Bar2(0, 0))
- .InSequence(s2);
- EXPECT_CALL(foo_, Bar2(1, _))
- .InSequence(s1, s2);
+ EXPECT_CALL(foo_, Bar(_, 0, _)).InSequence(s1);
+ EXPECT_CALL(foo_, Bar2(0, 0)).InSequence(s2);
+ EXPECT_CALL(foo_, Bar2(1, _)).InSequence(s1, s2);
foo_.Bar2(1, 0); // Has two immediate unsatisfied pre-requisites
foo_.Bar("Hi", 0, 0);
@@ -179,8 +172,7 @@ TEST_F(GMockOutputTest, UnsatisfiedWith) {
TEST_F(GMockOutputTest, UnsatisfiedExpectation) {
EXPECT_CALL(foo_, Bar(_, _, _));
- EXPECT_CALL(foo_, Bar2(0, _))
- .Times(2);
+ EXPECT_CALL(foo_, Bar2(0, _)).Times(2);
foo_.Bar2(0, 1);
}
@@ -194,26 +186,22 @@ TEST_F(GMockOutputTest, MismatchArguments) {
}
TEST_F(GMockOutputTest, MismatchWith) {
- EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))
- .With(Ge());
+ EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1))).With(Ge());
foo_.Bar2(2, 3); // Mismatch With()
foo_.Bar2(2, 1);
}
TEST_F(GMockOutputTest, MismatchArgumentsAndWith) {
- EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))
- .With(Ge());
+ EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1))).With(Ge());
foo_.Bar2(1, 3); // Mismatch arguments and mismatch With()
foo_.Bar2(2, 1);
}
TEST_F(GMockOutputTest, UnexpectedCallWithDefaultAction) {
- ON_CALL(foo_, Bar2(_, _))
- .WillByDefault(Return(true)); // Default action #1
- ON_CALL(foo_, Bar2(1, _))
- .WillByDefault(Return(false)); // Default action #2
+ ON_CALL(foo_, Bar2(_, _)).WillByDefault(Return(true)); // Default action #1
+ ON_CALL(foo_, Bar2(1, _)).WillByDefault(Return(false)); // Default action #2
EXPECT_CALL(foo_, Bar2(2, 2));
foo_.Bar2(1, 0); // Unexpected call, takes default action #2.
@@ -222,10 +210,8 @@ TEST_F(GMockOutputTest, UnexpectedCallWithDefaultAction) {
}
TEST_F(GMockOutputTest, ExcessiveCallWithDefaultAction) {
- ON_CALL(foo_, Bar2(_, _))
- .WillByDefault(Return(true)); // Default action #1
- ON_CALL(foo_, Bar2(1, _))
- .WillByDefault(Return(false)); // Default action #2
+ ON_CALL(foo_, Bar2(_, _)).WillByDefault(Return(true)); // Default action #1
+ ON_CALL(foo_, Bar2(1, _)).WillByDefault(Return(false)); // Default action #2
EXPECT_CALL(foo_, Bar2(2, 2));
EXPECT_CALL(foo_, Bar2(1, 1));
@@ -237,22 +223,17 @@ TEST_F(GMockOutputTest, ExcessiveCallWithDefaultAction) {
}
TEST_F(GMockOutputTest, UninterestingCallWithDefaultAction) {
- ON_CALL(foo_, Bar2(_, _))
- .WillByDefault(Return(true)); // Default action #1
- ON_CALL(foo_, Bar2(1, _))
- .WillByDefault(Return(false)); // Default action #2
+ ON_CALL(foo_, Bar2(_, _)).WillByDefault(Return(true)); // Default action #1
+ ON_CALL(foo_, Bar2(1, _)).WillByDefault(Return(false)); // Default action #2
foo_.Bar2(2, 2); // Uninteresting call, takes default action #1.
foo_.Bar2(1, 1); // Uninteresting call, takes default action #2.
}
TEST_F(GMockOutputTest, ExplicitActionsRunOutWithDefaultAction) {
- ON_CALL(foo_, Bar2(_, _))
- .WillByDefault(Return(true)); // Default action #1
+ ON_CALL(foo_, Bar2(_, _)).WillByDefault(Return(true)); // Default action #1
- EXPECT_CALL(foo_, Bar2(_, _))
- .Times(2)
- .WillOnce(Return(false));
+ EXPECT_CALL(foo_, Bar2(_, _)).Times(2).WillOnce(Return(false));
foo_.Bar2(2, 2);
foo_.Bar2(1, 1); // Explicit actions in EXPECT_CALL run out.
}
@@ -293,7 +274,7 @@ void TestCatchesLeakedMocksInAdHocTests() {
// foo is deliberately leaked.
}
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv);
// Ensures that the tests pass no matter what value of
// --gmock_catch_leaked_mocks and --gmock_verbose the user specifies.
@@ -305,5 +286,5 @@ int main(int argc, char **argv) {
}
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
diff --git a/googlemock/test/gmock_stress_test.cc b/googlemock/test/gmock_stress_test.cc
index 20725d6..9e42cd9 100644
--- a/googlemock/test/gmock_stress_test.cc
+++ b/googlemock/test/gmock_stress_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Tests that Google Mock constructs can be used in a large number of
// threads concurrently.
@@ -49,7 +48,7 @@ const int kRepeat = 50;
class MockFoo {
public:
- MOCK_METHOD1(Bar, int(int n)); // NOLINT
+ MOCK_METHOD1(Bar, int(int n)); // NOLINT
MOCK_METHOD2(Baz, char(const char* s1, const std::string& s2)); // NOLINT
};
@@ -62,21 +61,16 @@ void JoinAndDelete(ThreadWithParam<T>* t) {
struct Dummy {};
-
// Tests that different mock objects can be used in their respective
// threads. This should generate no Google Test failure.
void TestConcurrentMockObjects(Dummy /* dummy */) {
// Creates a mock and does some typical operations on it.
MockFoo foo;
- ON_CALL(foo, Bar(_))
- .WillByDefault(Return(1));
- ON_CALL(foo, Baz(_, _))
- .WillByDefault(Return('b'));
- ON_CALL(foo, Baz(_, "you"))
- .WillByDefault(Return('a'));
-
- EXPECT_CALL(foo, Bar(0))
- .Times(AtMost(3));
+ ON_CALL(foo, Bar(_)).WillByDefault(Return(1));
+ ON_CALL(foo, Baz(_, _)).WillByDefault(Return('b'));
+ ON_CALL(foo, Baz(_, "you")).WillByDefault(Return('a'));
+
+ EXPECT_CALL(foo, Bar(0)).Times(AtMost(3));
EXPECT_CALL(foo, Baz(_, _));
EXPECT_CALL(foo, Baz("hi", "you"))
.WillOnce(Return('z'))
@@ -119,22 +113,19 @@ void Helper1(Helper1Param param) {
void TestConcurrentCallsOnSameObject(Dummy /* dummy */) {
MockFoo foo;
- ON_CALL(foo, Bar(_))
- .WillByDefault(Return(1));
- EXPECT_CALL(foo, Baz(_, "b"))
- .Times(kRepeat)
- .WillRepeatedly(Return('a'));
+ ON_CALL(foo, Bar(_)).WillByDefault(Return(1));
+ EXPECT_CALL(foo, Baz(_, "b")).Times(kRepeat).WillRepeatedly(Return('a'));
EXPECT_CALL(foo, Baz(_, "c")); // Expected to be unsatisfied.
// This chunk of code should generate kRepeat failures about
// excessive calls, and 2*kRepeat failures about unexpected calls.
int count1 = 0;
- const Helper1Param param = { &foo, &count1 };
+ const Helper1Param param = {&foo, &count1};
ThreadWithParam<Helper1Param>* const t =
new ThreadWithParam<Helper1Param>(Helper1, param, nullptr);
int count2 = 0;
- const Helper1Param param2 = { &foo, &count2 };
+ const Helper1Param param2 = {&foo, &count2};
Helper1(param2);
JoinAndDelete(t);
@@ -162,22 +153,18 @@ void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) {
{
InSequence dummy;
EXPECT_CALL(foo, Bar(0));
- EXPECT_CALL(foo, Bar(1))
- .InSequence(s1, s2);
+ EXPECT_CALL(foo, Bar(1)).InSequence(s1, s2);
}
EXPECT_CALL(foo, Bar(2))
- .Times(2*kRepeat)
+ .Times(2 * kRepeat)
.InSequence(s1)
.RetiresOnSaturation();
- EXPECT_CALL(foo, Bar(3))
- .Times(2*kRepeat)
- .InSequence(s2);
+ EXPECT_CALL(foo, Bar(3)).Times(2 * kRepeat).InSequence(s2);
{
InSequence dummy;
- EXPECT_CALL(foo, Bar(2))
- .InSequence(s1, s2);
+ EXPECT_CALL(foo, Bar(2)).InSequence(s1, s2);
EXPECT_CALL(foo, Bar(4));
}
@@ -196,12 +183,12 @@ void TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) {
// Tests using Google Mock constructs in many threads concurrently.
TEST(StressTest, CanUseGMockWithThreads) {
void (*test_routines[])(Dummy dummy) = {
- &TestConcurrentMockObjects,
- &TestConcurrentCallsOnSameObject,
- &TestPartiallyOrderedExpectationsWithThreads,
+ &TestConcurrentMockObjects,
+ &TestConcurrentCallsOnSameObject,
+ &TestPartiallyOrderedExpectationsWithThreads,
};
- const int kRoutines = sizeof(test_routines)/sizeof(test_routines[0]);
+ const int kRoutines = sizeof(test_routines) / sizeof(test_routines[0]);
const int kCopiesOfEachRoutine = kMaxTestThreads / kRoutines;
const int kTestThreads = kCopiesOfEachRoutine * kRoutines;
ThreadWithParam<Dummy>* threads[kTestThreads] = {};
@@ -220,7 +207,7 @@ TEST(StressTest, CanUseGMockWithThreads) {
// Ensures that the correct number of failures have been reported.
const TestInfo* const info = UnitTest::GetInstance()->current_test_info();
const TestResult& result = *info->result();
- const int kExpectedFailures = (3*kRepeat + 1)*kCopiesOfEachRoutine;
+ const int kExpectedFailures = (3 * kRepeat + 1) * kCopiesOfEachRoutine;
GTEST_CHECK_(kExpectedFailures == result.total_part_count())
<< "Expected " << kExpectedFailures << " failures, but got "
<< result.total_part_count();
@@ -229,7 +216,7 @@ TEST(StressTest, CanUseGMockWithThreads) {
} // namespace
} // namespace testing
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
testing::InitGoogleMock(&argc, argv);
const int exit_code = RUN_ALL_TESTS(); // Expected to fail.
diff --git a/googlemock/test/gmock_test.cc b/googlemock/test/gmock_test.cc
index 9a2bd93..8f1bd5d 100644
--- a/googlemock/test/gmock_test.cc
+++ b/googlemock/test/gmock_test.cc
@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
// Google Mock - a framework for writing C++ mock classes.
//
// This file tests code in gmock.cc.
@@ -35,6 +34,7 @@
#include "gmock/gmock.h"
#include <string>
+
#include "gtest/gtest.h"
#include "gtest/internal/custom/gtest.h"