Commit b007c54f authored by Abseil Team's avatar Abseil Team Committed by Copybara-Service
Browse files

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
parent 8a422b83
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
#ifndef _WIN32_WCE #ifndef _WIN32_WCE
# include <errno.h> #include <errno.h>
#endif #endif
#include <algorithm> #include <algorithm>
...@@ -147,8 +147,8 @@ ...@@ -147,8 +147,8 @@
#include "gmock/internal/gmock-pp.h" #include "gmock/internal/gmock-pp.h"
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) #pragma warning(push)
# pragma warning(disable:4100) #pragma warning(disable : 4100)
#endif #endif
namespace testing { namespace testing {
...@@ -196,9 +196,7 @@ class BuiltInDefaultValue { ...@@ -196,9 +196,7 @@ class BuiltInDefaultValue {
public: public:
// This function returns true if and only if type T has a built-in default // This function returns true if and only if type T has a built-in default
// value. // value.
static bool Exists() { static bool Exists() { return ::std::is_default_constructible<T>::value; }
return ::std::is_default_constructible<T>::value;
}
static T Get() { static T Get() {
return BuiltInDefaultValueGetter< return BuiltInDefaultValueGetter<
...@@ -862,7 +860,9 @@ class DoDefaultAction { ...@@ -862,7 +860,9 @@ class DoDefaultAction {
// This template type conversion operator allows DoDefault() to be // This template type conversion operator allows DoDefault() to be
// used in any function. // used in any function.
template <typename F> 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 // Implements the Assign action to set a given pointer referent to a
...@@ -890,8 +890,7 @@ template <typename T> ...@@ -890,8 +890,7 @@ template <typename T>
class SetErrnoAndReturnAction { class SetErrnoAndReturnAction {
public: public:
SetErrnoAndReturnAction(int errno_value, T result) SetErrnoAndReturnAction(int errno_value, T result)
: errno_(errno_value), : errno_(errno_value), result_(result) {}
result_(result) {}
template <typename Result, typename ArgumentTuple> template <typename Result, typename ArgumentTuple>
Result Perform(const ArgumentTuple& /* args */) const { Result Perform(const ArgumentTuple& /* args */) const {
errno = errno_; errno = errno_;
...@@ -1002,8 +1001,8 @@ class IgnoreResultAction { ...@@ -1002,8 +1001,8 @@ class IgnoreResultAction {
private: private:
// Type OriginalFunction is the same as F except that its return // Type OriginalFunction is the same as F except that its return
// type is IgnoredValue. // type is IgnoredValue.
typedef typename internal::Function<F>::MakeResultIgnoredValue typedef
OriginalFunction; typename internal::Function<F>::MakeResultIgnoredValue OriginalFunction;
const Action<OriginalFunction> action_; const Action<OriginalFunction> action_;
}; };
...@@ -1020,8 +1019,8 @@ struct WithArgsAction { ...@@ -1020,8 +1019,8 @@ struct WithArgsAction {
template <typename R, typename... Args> template <typename R, typename... Args>
operator Action<R(Args...)>() const { // NOLINT operator Action<R(Args...)>() const { // NOLINT
using TupleType = std::tuple<Args...>; using TupleType = std::tuple<Args...>;
Action<R(typename std::tuple_element<I, TupleType>::type...)> Action<R(typename std::tuple_element<I, TupleType>::type...)> converted(
converted(action); action);
return [converted](Args... args) -> R { return [converted](Args... args) -> R {
return converted.Perform(std::forward_as_tuple( return converted.Perform(std::forward_as_tuple(
...@@ -1212,8 +1211,8 @@ internal::DoAllAction<typename std::decay<Action>::type...> DoAll( ...@@ -1212,8 +1211,8 @@ internal::DoAllAction<typename std::decay<Action>::type...> DoAll(
// multiple arguments. For convenience, we also provide // multiple arguments. For convenience, we also provide
// WithArgs<k>(an_action) (defined below) as a synonym. // WithArgs<k>(an_action) (defined below) as a synonym.
template <size_t k, typename InnerAction> template <size_t k, typename InnerAction>
internal::WithArgsAction<typename std::decay<InnerAction>::type, k> internal::WithArgsAction<typename std::decay<InnerAction>::type, k> WithArg(
WithArg(InnerAction&& action) { InnerAction&& action) {
return {std::forward<InnerAction>(action)}; return {std::forward<InnerAction>(action)};
} }
...@@ -1232,8 +1231,8 @@ WithArgs(InnerAction&& action) { ...@@ -1232,8 +1231,8 @@ WithArgs(InnerAction&& action) {
// argument. In other words, it adapts an action accepting no // argument. In other words, it adapts an action accepting no
// argument to one that accepts (and ignores) arguments. // argument to one that accepts (and ignores) arguments.
template <typename InnerAction> template <typename InnerAction>
internal::WithArgsAction<typename std::decay<InnerAction>::type> internal::WithArgsAction<typename std::decay<InnerAction>::type> WithoutArgs(
WithoutArgs(InnerAction&& action) { InnerAction&& action) {
return {std::forward<InnerAction>(action)}; return {std::forward<InnerAction>(action)};
} }
...@@ -1319,7 +1318,7 @@ internal::SetArgumentPointeeAction<N, T> SetArgumentPointee(T value) { ...@@ -1319,7 +1318,7 @@ internal::SetArgumentPointeeAction<N, T> SetArgumentPointee(T value) {
// Creates an action that sets a pointer referent to a given value. // Creates an action that sets a pointer referent to a given value.
template <typename T1, typename T2> 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)); return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));
} }
...@@ -1327,8 +1326,8 @@ PolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 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. // Creates an action that sets errno and returns the appropriate error.
template <typename T> template <typename T>
PolymorphicAction<internal::SetErrnoAndReturnAction<T> > PolymorphicAction<internal::SetErrnoAndReturnAction<T>> SetErrnoAndReturn(
SetErrnoAndReturn(int errval, T result) { int errval, T result) {
return MakePolymorphicAction( return MakePolymorphicAction(
internal::SetErrnoAndReturnAction<T>(errval, result)); internal::SetErrnoAndReturnAction<T>(errval, result));
} }
...@@ -1482,7 +1481,8 @@ struct ExcessiveArg {}; ...@@ -1482,7 +1481,8 @@ struct ExcessiveArg {};
// Builds an implementation of an Action<> for some particular signature, using // Builds an implementation of an Action<> for some particular signature, using
// a class defined by an ACTION* macro. // a class defined by an ACTION* macro.
template <typename F, typename Impl> struct ActionImpl; template <typename F, typename Impl>
struct ActionImpl;
template <typename Impl> template <typename Impl>
struct ImplBase { struct ImplBase {
...@@ -1502,7 +1502,7 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type { ...@@ -1502,7 +1502,7 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
using args_type = std::tuple<Args...>; using args_type = std::tuple<Args...>;
ActionImpl() = default; // Only defined if appropriate for Base. 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 { R operator()(Args&&... arg) const {
static constexpr size_t kMaxArgs = static constexpr size_t kMaxArgs =
...@@ -1521,10 +1521,12 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type { ...@@ -1521,10 +1521,12 @@ struct ActionImpl<R(Args...), Impl> : ImplBase<Impl>::type {
// args_type get passed, followed by a dummy of unspecified type for the // args_type get passed, followed by a dummy of unspecified type for the
// remainder up to 10 explicit args. // remainder up to 10 explicit args.
static constexpr ExcessiveArg kExcessArg{}; static constexpr ExcessiveArg kExcessArg{};
return static_cast<const Impl&>(*this).template gmock_PerformImpl< return static_cast<const Impl&>(*this)
.template gmock_PerformImpl<
/*function_type=*/function_type, /*return_type=*/R, /*function_type=*/function_type, /*return_type=*/R,
/*args_type=*/args_type, /*args_type=*/args_type,
/*argN_type=*/typename std::tuple_element<arg_id, args_type>::type...>( /*argN_type=*/
typename std::tuple_element<arg_id, args_type>::type...>(
/*args=*/args, std::get<arg_id>(args)..., /*args=*/args, std::get<arg_id>(args)...,
((void)excess_id, kExcessArg)...); ((void)excess_id, kExcessArg)...);
} }
...@@ -1590,13 +1592,14 @@ template <typename F, typename Impl> ...@@ -1590,13 +1592,14 @@ template <typename F, typename Impl>
public: \ public: \
explicit full_name(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \ explicit full_name(GMOCK_ACTION_TYPE_GVALUE_PARAMS_(params)) \
: impl_(std::make_shared<gmock_Impl>( \ : impl_(std::make_shared<gmock_Impl>( \
GMOCK_ACTION_GVALUE_PARAMS_(params))) { } \ GMOCK_ACTION_GVALUE_PARAMS_(params))) {} \
full_name(const full_name&) = default; \ full_name(const full_name&) = default; \
full_name(full_name&&) noexcept = default; \ full_name(full_name&&) noexcept = default; \
template <typename F> \ template <typename F> \
operator ::testing::Action<F>() const { \ operator ::testing::Action<F>() const { \
return ::testing::internal::MakeAction<F>(impl_); \ return ::testing::internal::MakeAction<F>(impl_); \
} \ } \
\
private: \ private: \
class gmock_Impl { \ class gmock_Impl { \
public: \ public: \
...@@ -1621,8 +1624,9 @@ template <typename F, typename Impl> ...@@ -1621,8 +1624,9 @@ template <typename F, typename Impl>
template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \ template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \
template <typename function_type, typename return_type, typename args_type, \ template <typename function_type, typename return_type, typename args_type, \
GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \ GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \
return_type full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>::gmock_Impl:: \ return_type \
gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const full_name<GMOCK_ACTION_TYPE_PARAMS_(params)>::gmock_Impl::gmock_PerformImpl( \
GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const
} // namespace internal } // namespace internal
...@@ -1636,6 +1640,7 @@ template <typename F, typename Impl> ...@@ -1636,6 +1640,7 @@ template <typename F, typename Impl>
operator ::testing::Action<F>() const { \ operator ::testing::Action<F>() const { \
return ::testing::internal::MakeAction<F, gmock_Impl>(); \ return ::testing::internal::MakeAction<F, gmock_Impl>(); \
} \ } \
\
private: \ private: \
class gmock_Impl { \ class gmock_Impl { \
public: \ public: \
...@@ -1684,7 +1689,7 @@ template <typename F, typename Impl> ...@@ -1684,7 +1689,7 @@ template <typename F, typename Impl>
} // namespace testing } // namespace testing
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_ #endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_
...@@ -40,8 +40,10 @@ ...@@ -40,8 +40,10 @@
#define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_ #define GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_
#include <limits.h> #include <limits.h>
#include <memory> #include <memory>
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
......
...@@ -47,13 +47,13 @@ namespace testing { ...@@ -47,13 +47,13 @@ namespace testing {
// Silence C4100 (unreferenced formal // Silence C4100 (unreferenced formal
// parameter) for MSVC // parameter) for MSVC
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) #pragma warning(push)
# pragma warning(disable:4100) #pragma warning(disable : 4100)
#if (_MSC_VER == 1900) #if (_MSC_VER == 1900)
// and silence C4800 (C4800: 'int *const ': forcing value // and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 14 // to bool 'true' or 'false') for MSVC 14
# pragma warning(disable:4800) #pragma warning(disable : 4800)
#endif #endif
#endif #endif
// Defines a matcher that matches an empty container. The container must // Defines a matcher that matches an empty container. The container must
...@@ -83,10 +83,9 @@ MATCHER(IsFalse, negation ? "is true" : "is false") { ...@@ -83,10 +83,9 @@ MATCHER(IsFalse, negation ? "is true" : "is false") {
} }
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) #pragma warning(pop)
#endif #endif
} // namespace testing } // namespace testing
#endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_ #endif // GOOGLEMOCK_INCLUDE_GMOCK_GMOCK_MORE_MATCHERS_H_
...@@ -59,9 +59,9 @@ namespace internal { ...@@ -59,9 +59,9 @@ namespace internal {
// Silence MSVC C4100 (unreferenced formal parameter) and // Silence MSVC C4100 (unreferenced formal parameter) and
// C4805('==': unsafe mix of type 'const int' and type 'const bool') // C4805('==': unsafe mix of type 'const int' and type 'const bool')
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) #pragma warning(push)
# pragma warning(disable:4100) #pragma warning(disable : 4100)
# pragma warning(disable:4805) #pragma warning(disable : 4805)
#endif #endif
// Joins a vector of strings as if they are fields of a tuple; returns // 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) { ...@@ -91,7 +91,9 @@ inline const Element* GetRawPointer(const std::reference_wrapper<Element>& r) {
// This overloaded version is for the raw pointer case. // This overloaded version is for the raw pointer case.
template <typename Element> 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 // 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 // same as unsigned short when the compiler option /Zc:wchar_t- is
...@@ -100,7 +102,7 @@ inline Element* GetRawPointer(Element* p) { return p; } ...@@ -100,7 +102,7 @@ inline Element* GetRawPointer(Element* p) { return p; }
#if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED) #if defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED)
// wchar_t is a typedef. // wchar_t is a typedef.
#else #else
# define GMOCK_WCHAR_T_IS_NATIVE_ 1 #define GMOCK_WCHAR_T_IS_NATIVE_ 1
#endif #endif
// In what follows, we use the term "kind" to indicate whether a type // In what follows, we use the term "kind" to indicate whether a type
...@@ -108,18 +110,20 @@ inline Element* GetRawPointer(Element* p) { return p; } ...@@ -108,18 +110,20 @@ inline Element* GetRawPointer(Element* p) { return p; }
// or none of them. This categorization is useful for determining // or none of them. This categorization is useful for determining
// when a matcher argument type can be safely converted to another // when a matcher argument type can be safely converted to another
// type in the implementation of SafeMatcherCast. // type in the implementation of SafeMatcherCast.
enum TypeKind { enum TypeKind { kBool, kInteger, kFloatingPoint, kOther };
kBool, kInteger, kFloatingPoint, kOther
};
// KindOf<T>::value is the kind of type T. // 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. enum { value = kOther }; // The default kind.
}; };
// This macro declares that the kind of 'type' is 'kind'. // This macro declares that the kind of 'type' is 'kind'.
#define GMOCK_DECLARE_KIND_(type, 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); GMOCK_DECLARE_KIND_(bool, kBool);
...@@ -204,9 +208,7 @@ using LosslessArithmeticConvertible = ...@@ -204,9 +208,7 @@ using LosslessArithmeticConvertible =
class FailureReporterInterface { class FailureReporterInterface {
public: public:
// The type of a failure (either non-fatal or fatal). // The type of a failure (either non-fatal or fatal).
enum FailureType { enum FailureType { kNonfatal, kFatal };
kNonfatal, kFatal
};
virtual ~FailureReporterInterface() {} virtual ~FailureReporterInterface() {}
...@@ -226,8 +228,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter(); ...@@ -226,8 +228,8 @@ GTEST_API_ FailureReporterInterface* GetFailureReporter();
inline void Assert(bool condition, const char* file, int line, inline void Assert(bool condition, const char* file, int line,
const std::string& msg) { const std::string& msg) {
if (!condition) { if (!condition) {
GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal, GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal, file,
file, line, msg); line, msg);
} }
} }
inline void Assert(bool condition, const char* file, int line) { inline void Assert(bool condition, const char* file, int line) {
...@@ -248,10 +250,7 @@ inline void Expect(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. // Severity level of a log.
enum LogSeverity { enum LogSeverity { kInfo = 0, kWarning = 1 };
kInfo = 0,
kWarning = 1
};
// Valid values for the --gmock_verbose flag. // Valid values for the --gmock_verbose flag.
...@@ -294,8 +293,8 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers(); ...@@ -294,8 +293,8 @@ GTEST_API_ WithoutMatchers GetWithoutMatchers();
// Disable MSVC warnings for infinite recursion, since in this case the // Disable MSVC warnings for infinite recursion, since in this case the
// recursion is unreachable. // recursion is unreachable.
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) #pragma warning(push)
# pragma warning(disable:4717) #pragma warning(disable : 4717)
#endif #endif
// Invalid<T>() is usable as an expression of type T, but will terminate // Invalid<T>() is usable as an expression of type T, but will terminate
...@@ -313,7 +312,7 @@ inline T Invalid() { ...@@ -313,7 +312,7 @@ inline T Invalid() {
} }
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) #pragma warning(pop)
#endif #endif
// Given a raw type (i.e. having no top-level reference or const // Given a raw type (i.e. having no top-level reference or const
...@@ -392,7 +391,8 @@ class StlContainerView< ::std::tuple<ElementPointer, Size> > { ...@@ -392,7 +391,8 @@ class StlContainerView< ::std::tuple<ElementPointer, Size> > {
// The following specialization prevents the user from instantiating // The following specialization prevents the user from instantiating
// StlContainer with a reference type. // 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. // 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, // Pairs like that are used as the value_type of associative containers,
...@@ -413,15 +413,16 @@ struct RemoveConstFromKey<std::pair<const K, V> > { ...@@ -413,15 +413,16 @@ struct RemoveConstFromKey<std::pair<const K, V> > {
GTEST_API_ void IllegalDoDefault(const char* file, int line); GTEST_API_ void IllegalDoDefault(const char* file, int line);
template <typename F, typename Tuple, size_t... Idx> template <typename F, typename Tuple, size_t... Idx>
auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>) -> decltype( auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>)
std::forward<F>(f)(std::get<Idx>(std::forward<Tuple>(args))...)) { -> decltype(std::forward<F>(f)(
std::get<Idx>(std::forward<Tuple>(args))...)) {
return 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. // Apply the function to a tuple of arguments.
template <typename F, typename Tuple> template <typename F, typename Tuple>
auto Apply(F&& f, Tuple&& args) -> decltype( auto Apply(F&& f, Tuple&& args) -> decltype(ApplyImpl(
ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), std::forward<F>(f), std::forward<Tuple>(args),
MakeIndexSequence<std::tuple_size< MakeIndexSequence<std::tuple_size<
typename std::remove_reference<Tuple>::type>::value>())) { typename std::remove_reference<Tuple>::type>::value>())) {
return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args),
...@@ -463,7 +464,7 @@ constexpr size_t Function<R(Args...)>::ArgumentCount; ...@@ -463,7 +464,7 @@ constexpr size_t Function<R(Args...)>::ArgumentCount;
bool Base64Unescape(const std::string& encoded, std::string* decoded); bool Base64Unescape(const std::string& encoded, std::string* decoded);
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) #pragma warning(pop)
#endif #endif
} // namespace internal } // namespace internal
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <cstdint> #include <cstdint>
#include <iostream> #include <iostream>
...@@ -53,13 +54,13 @@ ...@@ -53,13 +54,13 @@
// here, as Google Mock depends on Google Test. Only add a utility // here, as Google Mock depends on Google Test. Only add a utility
// here if it's truly specific to Google Mock. // here if it's truly specific to Google Mock.
#include "gtest/internal/gtest-port.h"
#include "gmock/internal/custom/gmock-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 // For MS Visual C++, check the compiler version. At least VS 2015 is
// required to compile Google Mock. // required to compile Google Mock.
#if defined(_MSC_VER) && _MSC_VER < 1900 #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 #endif
// Macro for referencing flags. This is public as we want the user to // Macro for referencing flags. This is public as we want the user to
...@@ -72,29 +73,35 @@ ...@@ -72,29 +73,35 @@
#define GMOCK_DECLARE_bool_(name) \ #define GMOCK_DECLARE_bool_(name) \
namespace testing { \ namespace testing { \
GTEST_API_ extern bool GMOCK_FLAG(name); \ 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) \ #define GMOCK_DECLARE_int32_(name) \
namespace testing { \ namespace testing { \
GTEST_API_ extern int32_t GMOCK_FLAG(name); \ 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) \ #define GMOCK_DECLARE_string_(name) \
namespace testing { \ namespace testing { \
GTEST_API_ extern ::std::string GMOCK_FLAG(name); \ 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. // Macros for defining flags.
#define GMOCK_DEFINE_bool_(name, default_val, doc) \ #define GMOCK_DEFINE_bool_(name, default_val, doc) \
namespace testing { \ namespace testing { \
GTEST_API_ bool GMOCK_FLAG(name) = (default_val); \ 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) \ #define GMOCK_DEFINE_int32_(name, default_val, doc) \
namespace testing { \ namespace testing { \
GTEST_API_ int32_t GMOCK_FLAG(name) = (default_val); \ 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) \ #define GMOCK_DEFINE_string_(name, default_val, doc) \
namespace testing { \ namespace testing { \
GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val); \ 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_) #endif // !defined(GMOCK_DECLARE_bool_)
#if !defined(GMOCK_FLAG_GET) #if !defined(GMOCK_FLAG_GET)
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements cardinalities. // This file implements cardinalities.
...@@ -35,9 +34,11 @@ ...@@ -35,9 +34,11 @@
#include "gmock/gmock-cardinalities.h" #include "gmock/gmock-cardinalities.h"
#include <limits.h> #include <limits.h>
#include <ostream> // NOLINT #include <ostream> // NOLINT
#include <sstream> #include <sstream>
#include <string> #include <string>
#include "gmock/internal/gmock-internal-utils.h" #include "gmock/internal/gmock-internal-utils.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
...@@ -49,8 +50,7 @@ namespace { ...@@ -49,8 +50,7 @@ namespace {
class BetweenCardinalityImpl : public CardinalityInterface { class BetweenCardinalityImpl : public CardinalityInterface {
public: public:
BetweenCardinalityImpl(int min, int max) BetweenCardinalityImpl(int min, int max)
: min_(min >= 0 ? min : 0), : min_(min >= 0 ? min : 0), max_(max >= min_ ? max : min_) {
max_(max >= min_ ? max : min_) {
std::stringstream ss; std::stringstream ss;
if (min < 0) { if (min < 0) {
ss << "The invocation lower bound must be >= 0, " ss << "The invocation lower bound must be >= 0, "
...@@ -62,8 +62,7 @@ class BetweenCardinalityImpl : public CardinalityInterface { ...@@ -62,8 +62,7 @@ class BetweenCardinalityImpl : public CardinalityInterface {
internal::Expect(false, __FILE__, __LINE__, ss.str()); internal::Expect(false, __FILE__, __LINE__, ss.str());
} else if (min > max) { } else if (min > max) {
ss << "The invocation upper bound (" << 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()); internal::Expect(false, __FILE__, __LINE__, ss.str());
} }
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file defines some utilities useful for implementing Google // This file defines some utilities useful for implementing Google
...@@ -88,8 +87,7 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) { ...@@ -88,8 +87,7 @@ GTEST_API_ std::string ConvertIdentifierNameToWords(const char* id_name) {
(!IsDigit(prev_char) && IsDigit(*p)); (!IsDigit(prev_char) && IsDigit(*p));
if (IsAlNum(*p)) { if (IsAlNum(*p)) {
if (starts_new_word && result != "") if (starts_new_word && result != "") result += ' ';
result += ' ';
result += ToLower(*p); result += ToLower(*p);
} }
} }
...@@ -103,12 +101,9 @@ class GoogleTestFailureReporter : public FailureReporterInterface { ...@@ -103,12 +101,9 @@ class GoogleTestFailureReporter : public FailureReporterInterface {
public: public:
void ReportFailure(FailureType type, const char* file, int line, void ReportFailure(FailureType type, const char* file, int line,
const std::string& message) override { const std::string& message) override {
AssertHelper(type == kFatal ? AssertHelper(type == kFatal ? TestPartResult::kFatalFailure
TestPartResult::kFatalFailure : : TestPartResult::kNonFatalFailure,
TestPartResult::kNonFatalFailure, file, line, message.c_str()) = Message();
file,
line,
message.c_str()) = Message();
if (type == kFatal) { if (type == kFatal) {
posix::Abort(); posix::Abort();
} }
...@@ -156,8 +151,7 @@ GTEST_API_ bool LogIsVisible(LogSeverity severity) { ...@@ -156,8 +151,7 @@ GTEST_API_ bool LogIsVisible(LogSeverity severity) {
// conservative. // conservative.
GTEST_API_ void Log(LogSeverity severity, const std::string& message, GTEST_API_ void Log(LogSeverity severity, const std::string& message,
int stack_frames_to_skip) { int stack_frames_to_skip) {
if (!LogIsVisible(severity)) if (!LogIsVisible(severity)) return;
return;
// Ensures that logs from different threads don't interleave. // Ensures that logs from different threads don't interleave.
MutexLock l(&g_log_mutex); MutexLock l(&g_log_mutex);
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements Matcher<const string&>, Matcher<string>, and // This file implements Matcher<const string&>, Matcher<string>, and
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file implements the spec builder syntax (ON_CALL and // This file implements the spec builder syntax (ON_CALL and
...@@ -49,15 +48,15 @@ ...@@ -49,15 +48,15 @@
#include "gtest/internal/gtest-port.h" #include "gtest/internal/gtest-port.h"
#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC #if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC
# include <unistd.h> // NOLINT #include <unistd.h> // NOLINT
#endif #endif
// Silence C4800 (C4800: 'int *const ': forcing value // Silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 15 // to bool 'true' or 'false') for MSVC 15
#ifdef _MSC_VER #ifdef _MSC_VER
#if _MSC_VER == 1900 #if _MSC_VER == 1900
# pragma warning(push) #pragma warning(push)
# pragma warning(disable:4800) #pragma warning(disable : 4800)
#endif #endif
#endif #endif
...@@ -195,11 +194,12 @@ void ExpectationBase::DescribeCallCountTo(::std::ostream* os) const ...@@ -195,11 +194,12 @@ void ExpectationBase::DescribeCallCountTo(::std::ostream* os) const
// Describes the state of the expectation (e.g. is it satisfied? // Describes the state of the expectation (e.g. is it satisfied?
// is it active?). // is it active?).
*os << " - " << (IsOverSaturated() ? "over-saturated" : *os << " - "
IsSaturated() ? "saturated" : << (IsOverSaturated() ? "over-saturated"
IsSatisfied() ? "satisfied" : "unsatisfied") : IsSaturated() ? "saturated"
<< " and " : IsSatisfied() ? "satisfied"
<< (is_retired() ? "retired" : "active"); : "unsatisfied")
<< " and " << (is_retired() ? "retired" : "active");
} }
// Checks the action count (i.e. the number of WillOnce() and // Checks the action count (i.e. the number of WillOnce() and
...@@ -242,13 +242,12 @@ void ExpectationBase::CheckActionCountIfNotDone() const ...@@ -242,13 +242,12 @@ void ExpectationBase::CheckActionCountIfNotDone() const
::std::stringstream ss; ::std::stringstream ss;
DescribeLocationTo(&ss); DescribeLocationTo(&ss);
ss << "Too " << (too_many ? "many" : "few") ss << "Too " << (too_many ? "many" : "few") << " actions specified in "
<< " actions specified in " << source_text() << "...\n" << source_text() << "...\n"
<< "Expected to be "; << "Expected to be ";
cardinality().DescribeTo(&ss); cardinality().DescribeTo(&ss);
ss << ", but has " << (too_many ? "" : "only ") ss << ", but has " << (too_many ? "" : "only ") << action_count
<< action_count << " WillOnce()" << " WillOnce()" << (action_count == 1 ? "" : "s");
<< (action_count == 1 ? "" : "s");
if (repeated_action_specified_) { if (repeated_action_specified_) {
ss << " and a WillRepeatedly()"; ss << " and a WillRepeatedly()";
} }
...@@ -505,8 +504,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith( ...@@ -505,8 +504,7 @@ UntypedActionResultHolderBase* UntypedFunctionMockerBase::UntypedInvokeWith(
Expectation UntypedFunctionMockerBase::GetHandleOf(ExpectationBase* exp) { Expectation UntypedFunctionMockerBase::GetHandleOf(ExpectationBase* exp) {
// See the definition of untyped_expectations_ for why access to it // See the definition of untyped_expectations_ for why access to it
// is unprotected here. // is unprotected here.
for (UntypedExpectations::const_iterator it = for (UntypedExpectations::const_iterator it = untyped_expectations_.begin();
untyped_expectations_.begin();
it != untyped_expectations_.end(); ++it) { it != untyped_expectations_.end(); ++it) {
if (it->get() == exp) { if (it->get() == exp) {
return Expectation(*it); return Expectation(*it);
...@@ -526,8 +524,7 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() ...@@ -526,8 +524,7 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {
g_gmock_mutex.AssertHeld(); g_gmock_mutex.AssertHeld();
bool expectations_met = true; bool expectations_met = true;
for (UntypedExpectations::const_iterator it = for (UntypedExpectations::const_iterator it = untyped_expectations_.begin();
untyped_expectations_.begin();
it != untyped_expectations_.end(); ++it) { it != untyped_expectations_.end(); ++it) {
ExpectationBase* const untyped_expectation = it->get(); ExpectationBase* const untyped_expectation = it->get();
if (untyped_expectation->IsOverSaturated()) { if (untyped_expectation->IsOverSaturated()) {
...@@ -545,8 +542,8 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked() ...@@ -545,8 +542,8 @@ bool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()
// takes care of it. // takes care of it.
untyped_expectation->MaybeDescribeExtraMatcherTo(&ss); untyped_expectation->MaybeDescribeExtraMatcherTo(&ss);
untyped_expectation->DescribeCallCountTo(&ss); untyped_expectation->DescribeCallCountTo(&ss);
Expect(false, untyped_expectation->file(), Expect(false, untyped_expectation->file(), untyped_expectation->line(),
untyped_expectation->line(), ss.str()); ss.str());
} }
} }
...@@ -712,8 +709,7 @@ void Mock::UnregisterCallReaction(const void* mock_obj) ...@@ -712,8 +709,7 @@ void Mock::UnregisterCallReaction(const void* mock_obj)
// Returns the reaction Google Mock will have on uninteresting calls // Returns the reaction Google Mock will have on uninteresting calls
// made on the given mock object. // made on the given mock object.
internal::CallReaction Mock::GetReactionOnUninterestingCalls( internal::CallReaction Mock::GetReactionOnUninterestingCalls(
const void* mock_obj) const void* mock_obj) GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {
internal::MutexLock l(&internal::g_gmock_mutex); internal::MutexLock l(&internal::g_gmock_mutex);
return (g_uninteresting_call_reaction.count(mock_obj) == 0) return (g_uninteresting_call_reaction.count(mock_obj) == 0)
? internal::intToCallReaction( ? internal::intToCallReaction(
...@@ -873,8 +869,8 @@ Expectation::~Expectation() {} ...@@ -873,8 +869,8 @@ Expectation::~Expectation() {}
void Sequence::AddExpectation(const Expectation& expectation) const { void Sequence::AddExpectation(const Expectation& expectation) const {
if (*last_expectation_ != expectation) { if (*last_expectation_ != expectation) {
if (last_expectation_->expectation_base() != nullptr) { if (last_expectation_->expectation_base() != nullptr) {
expectation.expectation_base()->immediate_prerequisites_ expectation.expectation_base()->immediate_prerequisites_ +=
+= *last_expectation_; *last_expectation_;
} }
*last_expectation_ = expectation; *last_expectation_ = expectation;
} }
...@@ -903,6 +899,6 @@ InSequence::~InSequence() { ...@@ -903,6 +899,6 @@ InSequence::~InSequence() {
#ifdef _MSC_VER #ifdef _MSC_VER
#if _MSC_VER == 1900 #if _MSC_VER == 1900
# pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
GMOCK_DEFINE_bool_(catch_leaked_mocks, true, GMOCK_DEFINE_bool_(catch_leaked_mocks, true,
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream> #include <iostream>
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
...@@ -56,7 +56,7 @@ void loop() { RUN_ALL_TESTS(); } ...@@ -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 // https://web.archive.org/web/20170912203238/connect.microsoft.com/VisualStudio/feedback/details/394464/wmain-link-error-in-the-static-library
// // NOLINT // // NOLINT
#if GTEST_OS_WINDOWS_MOBILE #if GTEST_OS_WINDOWS_MOBILE
# include <tchar.h> // NOLINT #include <tchar.h> // NOLINT
GTEST_API_ int _tmain(int argc, TCHAR** argv) { GTEST_API_ int _tmain(int argc, TCHAR** argv) {
#else #else
......
...@@ -27,32 +27,33 @@ ...@@ -27,32 +27,33 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file tests the built-in actions. // This file tests the built-in actions.
// Silence C4100 (unreferenced formal parameter) for MSVC // Silence C4100 (unreferenced formal parameter) for MSVC
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) #pragma warning(push)
# pragma warning(disable:4100) #pragma warning(disable : 4100)
#if _MSC_VER == 1900 #if _MSC_VER == 1900
// and silence C4800 (C4800: 'int *const ': forcing value // and silence C4800 (C4800: 'int *const ': forcing value
// to bool 'true' or 'false') for MSVC 15 // to bool 'true' or 'false') for MSVC 15
# pragma warning(disable:4800) #pragma warning(disable : 4800)
#endif #endif
#endif #endif
#include "gmock/gmock-actions.h" #include "gmock/gmock-actions.h"
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <memory> #include <memory>
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gmock/internal/gmock-port.h" #include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
namespace { namespace {
...@@ -167,13 +168,13 @@ TEST(BuiltInDefaultValueTest, BoolExists) { ...@@ -167,13 +168,13 @@ TEST(BuiltInDefaultValueTest, BoolExists) {
// Tests that BuiltInDefaultValue<T>::Get() returns "" when T is a // Tests that BuiltInDefaultValue<T>::Get() returns "" when T is a
// string type. // string type.
TEST(BuiltInDefaultValueTest, IsEmptyStringForString) { 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 // Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a
// string type. // string type.
TEST(BuiltInDefaultValueTest, ExistsForString) { TEST(BuiltInDefaultValueTest, ExistsForString) {
EXPECT_TRUE(BuiltInDefaultValue< ::std::string>::Exists()); EXPECT_TRUE(BuiltInDefaultValue<::std::string>::Exists());
} }
// Tests that BuiltInDefaultValue<const T>::Get() returns the same // Tests that BuiltInDefaultValue<const T>::Get() returns the same
...@@ -208,7 +209,6 @@ class MyNonDefaultConstructible { ...@@ -208,7 +209,6 @@ class MyNonDefaultConstructible {
int value_; int value_;
}; };
TEST(BuiltInDefaultValueTest, ExistsForDefaultConstructibleType) { TEST(BuiltInDefaultValueTest, ExistsForDefaultConstructibleType) {
EXPECT_TRUE(BuiltInDefaultValue<MyDefaultConstructible>::Exists()); EXPECT_TRUE(BuiltInDefaultValue<MyDefaultConstructible>::Exists());
} }
...@@ -217,25 +217,19 @@ TEST(BuiltInDefaultValueTest, IsDefaultConstructedForDefaultConstructibleType) { ...@@ -217,25 +217,19 @@ TEST(BuiltInDefaultValueTest, IsDefaultConstructedForDefaultConstructibleType) {
EXPECT_EQ(42, BuiltInDefaultValue<MyDefaultConstructible>::Get().value()); EXPECT_EQ(42, BuiltInDefaultValue<MyDefaultConstructible>::Get().value());
} }
TEST(BuiltInDefaultValueTest, DoesNotExistForNonDefaultConstructibleType) { TEST(BuiltInDefaultValueTest, DoesNotExistForNonDefaultConstructibleType) {
EXPECT_FALSE(BuiltInDefaultValue<MyNonDefaultConstructible>::Exists()); EXPECT_FALSE(BuiltInDefaultValue<MyNonDefaultConstructible>::Exists());
} }
// Tests that BuiltInDefaultValue<T&>::Get() aborts the program. // Tests that BuiltInDefaultValue<T&>::Get() aborts the program.
TEST(BuiltInDefaultValueDeathTest, IsUndefinedForReferences) { TEST(BuiltInDefaultValueDeathTest, IsUndefinedForReferences) {
EXPECT_DEATH_IF_SUPPORTED({ EXPECT_DEATH_IF_SUPPORTED({ BuiltInDefaultValue<int&>::Get(); }, "");
BuiltInDefaultValue<int&>::Get(); EXPECT_DEATH_IF_SUPPORTED({ BuiltInDefaultValue<const char&>::Get(); }, "");
}, "");
EXPECT_DEATH_IF_SUPPORTED({
BuiltInDefaultValue<const char&>::Get();
}, "");
} }
TEST(BuiltInDefaultValueDeathTest, IsUndefinedForNonDefaultConstructibleType) { TEST(BuiltInDefaultValueDeathTest, IsUndefinedForNonDefaultConstructibleType) {
EXPECT_DEATH_IF_SUPPORTED({ EXPECT_DEATH_IF_SUPPORTED(
BuiltInDefaultValue<MyNonDefaultConstructible>::Get(); { BuiltInDefaultValue<MyNonDefaultConstructible>::Get(); }, "");
}, "");
} }
// Tests that DefaultValue<T>::IsSet() is false initially. // Tests that DefaultValue<T>::IsSet() is false initially.
...@@ -281,26 +275,22 @@ TEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) { ...@@ -281,26 +275,22 @@ TEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
EXPECT_EQ(0, DefaultValue<int>::Get()); EXPECT_EQ(0, DefaultValue<int>::Get());
EXPECT_DEATH_IF_SUPPORTED({ EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<MyNonDefaultConstructible>::Get(); },
DefaultValue<MyNonDefaultConstructible>::Get(); "");
}, "");
} }
TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) { TEST(DefaultValueTest, GetWorksForMoveOnlyIfSet) {
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists()); EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists());
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Get() == nullptr); EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Get() == nullptr);
DefaultValue<std::unique_ptr<int>>::SetFactory([] { DefaultValue<std::unique_ptr<int>>::SetFactory(
return std::unique_ptr<int>(new int(42)); [] { return std::unique_ptr<int>(new int(42)); });
});
EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists()); EXPECT_TRUE(DefaultValue<std::unique_ptr<int>>::Exists());
std::unique_ptr<int> i = DefaultValue<std::unique_ptr<int>>::Get(); std::unique_ptr<int> i = DefaultValue<std::unique_ptr<int>>::Get();
EXPECT_EQ(42, *i); EXPECT_EQ(42, *i);
} }
// Tests that DefaultValue<void>::Get() returns void. // Tests that DefaultValue<void>::Get() returns void.
TEST(DefaultValueTest, GetWorksForVoid) { TEST(DefaultValueTest, GetWorksForVoid) { return DefaultValue<void>::Get(); }
return DefaultValue<void>::Get();
}
// Tests using DefaultValue with a reference type. // Tests using DefaultValue with a reference type.
...@@ -348,12 +338,9 @@ TEST(DefaultValueOfReferenceDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) { ...@@ -348,12 +338,9 @@ TEST(DefaultValueOfReferenceDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {
EXPECT_FALSE(DefaultValue<int&>::IsSet()); EXPECT_FALSE(DefaultValue<int&>::IsSet());
EXPECT_FALSE(DefaultValue<MyNonDefaultConstructible&>::IsSet()); EXPECT_FALSE(DefaultValue<MyNonDefaultConstructible&>::IsSet());
EXPECT_DEATH_IF_SUPPORTED({ EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<int&>::Get(); }, "");
DefaultValue<int&>::Get(); EXPECT_DEATH_IF_SUPPORTED({ DefaultValue<MyNonDefaultConstructible>::Get(); },
}, ""); "");
EXPECT_DEATH_IF_SUPPORTED({
DefaultValue<MyNonDefaultConstructible>::Get();
}, "");
} }
// Tests that ActionInterface can be implemented by defining the // Tests that ActionInterface can be implemented by defining the
...@@ -528,7 +515,7 @@ TEST(ReturnTest, AcceptsStringLiteral) { ...@@ -528,7 +515,7 @@ TEST(ReturnTest, AcceptsStringLiteral) {
// Test struct which wraps a vector of integers. Used in // Test struct which wraps a vector of integers. Used in
// 'SupportsWrapperReturnType' test. // 'SupportsWrapperReturnType' test.
struct IntegerVectorWrapper { struct IntegerVectorWrapper {
std::vector<int> * v; std::vector<int>* v;
IntegerVectorWrapper(std::vector<int>& _v) : v(&_v) {} // NOLINT IntegerVectorWrapper(std::vector<int>& _v) : v(&_v) {} // NOLINT
}; };
...@@ -648,7 +635,9 @@ TEST(ReturnRefTest, IsCovariant) { ...@@ -648,7 +635,9 @@ TEST(ReturnRefTest, IsCovariant) {
} }
template <typename T, typename = decltype(ReturnRef(std::declval<T&&>()))> template <typename T, typename = decltype(ReturnRef(std::declval<T&&>()))>
bool CanCallReturnRef(T&&) { return true; } bool CanCallReturnRef(T&&) {
return true;
}
bool CanCallReturnRef(Unused) { return false; } bool CanCallReturnRef(Unused) { return false; }
// Tests that ReturnRef(v) is working with non-temporaries (T&) // Tests that ReturnRef(v) is working with non-temporaries (T&)
...@@ -754,8 +743,7 @@ class MockClass { ...@@ -754,8 +743,7 @@ class MockClass {
// return type by default. // return type by default.
TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) { TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
MockClass mock; MockClass mock;
EXPECT_CALL(mock, IntFunc(_)) EXPECT_CALL(mock, IntFunc(_)).WillOnce(DoDefault());
.WillOnce(DoDefault());
EXPECT_EQ(0, mock.IntFunc(true)); EXPECT_EQ(0, mock.IntFunc(true));
} }
...@@ -763,14 +751,11 @@ TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) { ...@@ -763,14 +751,11 @@ TEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {
// the process when there is no built-in default value for the return type. // the process when there is no built-in default value for the return type.
TEST(DoDefaultDeathTest, DiesForUnknowType) { TEST(DoDefaultDeathTest, DiesForUnknowType) {
MockClass mock; MockClass mock;
EXPECT_CALL(mock, Foo()) EXPECT_CALL(mock, Foo()).WillRepeatedly(DoDefault());
.WillRepeatedly(DoDefault());
#if GTEST_HAS_EXCEPTIONS #if GTEST_HAS_EXCEPTIONS
EXPECT_ANY_THROW(mock.Foo()); EXPECT_ANY_THROW(mock.Foo());
#else #else
EXPECT_DEATH_IF_SUPPORTED({ EXPECT_DEATH_IF_SUPPORTED({ mock.Foo(); }, "");
mock.Foo();
}, "");
#endif #endif
} }
...@@ -782,16 +767,13 @@ void VoidFunc(bool /* flag */) {} ...@@ -782,16 +767,13 @@ void VoidFunc(bool /* flag */) {}
TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) { TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
MockClass mock; MockClass mock;
EXPECT_CALL(mock, IntFunc(_)) EXPECT_CALL(mock, IntFunc(_))
.WillRepeatedly(DoAll(Invoke(VoidFunc), .WillRepeatedly(DoAll(Invoke(VoidFunc), DoDefault()));
DoDefault()));
// Ideally we should verify the error message as well. Sadly, // Ideally we should verify the error message as well. Sadly,
// EXPECT_DEATH() can only capture stderr, while Google Mock's // EXPECT_DEATH() can only capture stderr, while Google Mock's
// errors are printed on stdout. Therefore we have to settle for // errors are printed on stdout. Therefore we have to settle for
// not verifying the message. // not verifying the message.
EXPECT_DEATH_IF_SUPPORTED({ EXPECT_DEATH_IF_SUPPORTED({ mock.IntFunc(true); }, "");
mock.IntFunc(true);
}, "");
} }
// Tests that DoDefault() returns the default value set by // Tests that DoDefault() returns the default value set by
...@@ -799,8 +781,7 @@ TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) { ...@@ -799,8 +781,7 @@ TEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {
TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) { TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) {
DefaultValue<int>::Set(1); DefaultValue<int>::Set(1);
MockClass mock; MockClass mock;
EXPECT_CALL(mock, IntFunc(_)) EXPECT_CALL(mock, IntFunc(_)).WillOnce(DoDefault());
.WillOnce(DoDefault());
EXPECT_EQ(1, mock.IntFunc(false)); EXPECT_EQ(1, mock.IntFunc(false));
DefaultValue<int>::Clear(); DefaultValue<int>::Clear();
} }
...@@ -808,20 +789,19 @@ TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) { ...@@ -808,20 +789,19 @@ TEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) {
// Tests that DoDefault() does the action specified by ON_CALL(). // Tests that DoDefault() does the action specified by ON_CALL().
TEST(DoDefaultTest, DoesWhatOnCallSpecifies) { TEST(DoDefaultTest, DoesWhatOnCallSpecifies) {
MockClass mock; MockClass mock;
ON_CALL(mock, IntFunc(_)) ON_CALL(mock, IntFunc(_)).WillByDefault(Return(2));
.WillByDefault(Return(2)); EXPECT_CALL(mock, IntFunc(_)).WillOnce(DoDefault());
EXPECT_CALL(mock, IntFunc(_))
.WillOnce(DoDefault());
EXPECT_EQ(2, mock.IntFunc(false)); EXPECT_EQ(2, mock.IntFunc(false));
} }
// Tests that using DoDefault() in ON_CALL() leads to a run-time failure. // Tests that using DoDefault() in ON_CALL() leads to a run-time failure.
TEST(DoDefaultTest, CannotBeUsedInOnCall) { TEST(DoDefaultTest, CannotBeUsedInOnCall) {
MockClass mock; MockClass mock;
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
ON_CALL(mock, IntFunc(_)) { // NOLINT
.WillByDefault(DoDefault()); ON_CALL(mock, IntFunc(_)).WillByDefault(DoDefault());
}, "DoDefault() cannot be used in ON_CALL()"); },
"DoDefault() cannot be used in ON_CALL()");
} }
// Tests that SetArgPointee<N>(v) sets the variable pointed to by // Tests that SetArgPointee<N>(v) sets the variable pointed to by
...@@ -868,7 +848,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) { ...@@ -868,7 +848,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
a.Perform(std::make_tuple(&ptr)); a.Perform(std::make_tuple(&ptr));
EXPECT_STREQ(L"world", ptr); EXPECT_STREQ(L"world", ptr);
# if GTEST_HAS_STD_WSTRING #if GTEST_HAS_STD_WSTRING
typedef void MyStringFunction(std::wstring*); typedef void MyStringFunction(std::wstring*);
Action<MyStringFunction> a2 = SetArgPointee<0>(L"world"); Action<MyStringFunction> a2 = SetArgPointee<0>(L"world");
...@@ -876,7 +856,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) { ...@@ -876,7 +856,7 @@ TEST(SetArgPointeeTest, AcceptsWideStringLiteral) {
a2.Perform(std::make_tuple(&str)); a2.Perform(std::make_tuple(&str));
EXPECT_EQ(L"world", str); EXPECT_EQ(L"world", str);
# endif #endif
} }
// Tests that SetArgPointee<N>() accepts a char pointer. // Tests that SetArgPointee<N>() accepts a char pointer.
...@@ -907,7 +887,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) { ...@@ -907,7 +887,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
a.Perform(std::make_tuple(true, &ptr)); a.Perform(std::make_tuple(true, &ptr));
EXPECT_EQ(hi, ptr); EXPECT_EQ(hi, ptr);
# if GTEST_HAS_STD_WSTRING #if GTEST_HAS_STD_WSTRING
typedef void MyStringFunction(bool, std::wstring*); typedef void MyStringFunction(bool, std::wstring*);
wchar_t world_array[] = L"world"; wchar_t world_array[] = L"world";
...@@ -916,7 +896,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) { ...@@ -916,7 +896,7 @@ TEST(SetArgPointeeTest, AcceptsWideCharPointer) {
std::wstring str; std::wstring str;
a2.Perform(std::make_tuple(true, &str)); a2.Perform(std::make_tuple(true, &str));
EXPECT_EQ(world_array, str); EXPECT_EQ(world_array, str);
# endif #endif
} }
// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by // Tests that SetArgumentPointee<N>(v) sets the variable pointed to by
...@@ -1079,7 +1059,6 @@ TEST(AssignTest, CompatibleTypes) { ...@@ -1079,7 +1059,6 @@ TEST(AssignTest, CompatibleTypes) {
EXPECT_DOUBLE_EQ(5, x); EXPECT_DOUBLE_EQ(5, x);
} }
// Tests using WithArgs and with an action that takes 1 argument. // Tests using WithArgs and with an action that takes 1 argument.
TEST(WithArgsTest, OneArg) { TEST(WithArgsTest, OneArg) {
Action<bool(double x, int n)> a = WithArgs<1>(Invoke(Unary)); // NOLINT Action<bool(double x, int n)> a = WithArgs<1>(Invoke(Unary)); // NOLINT
...@@ -1375,8 +1354,9 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_DoAllReturn) { ...@@ -1375,8 +1354,9 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_DoAllReturn) {
MockClass mock; MockClass mock;
std::unique_ptr<int> i(new int(19)); std::unique_ptr<int> i(new int(19));
EXPECT_CALL(mock_function, Call()); EXPECT_CALL(mock_function, Call());
EXPECT_CALL(mock, MakeUnique()).WillOnce(DoAll( EXPECT_CALL(mock, MakeUnique())
InvokeWithoutArgs(&mock_function, &testing::MockFunction<void()>::Call), .WillOnce(DoAll(InvokeWithoutArgs(&mock_function,
&testing::MockFunction<void()>::Call),
Return(ByMove(std::move(i))))); Return(ByMove(std::move(i)))));
std::unique_ptr<int> result1 = mock.MakeUnique(); std::unique_ptr<int> result1 = mock.MakeUnique();
...@@ -1387,9 +1367,8 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) { ...@@ -1387,9 +1367,8 @@ TEST(MockMethodTest, CanReturnMoveOnlyValue_Invoke) {
MockClass mock; MockClass mock;
// Check default value // Check default value
DefaultValue<std::unique_ptr<int>>::SetFactory([] { DefaultValue<std::unique_ptr<int>>::SetFactory(
return std::unique_ptr<int>(new int(42)); [] { return std::unique_ptr<int>(new int(42)); });
});
EXPECT_EQ(42, *mock.MakeUnique()); EXPECT_EQ(42, *mock.MakeUnique());
EXPECT_CALL(mock, MakeUnique()).WillRepeatedly(Invoke(UniquePtrSource)); EXPECT_CALL(mock, MakeUnique()).WillRepeatedly(Invoke(UniquePtrSource));
...@@ -1449,7 +1428,6 @@ TEST(MockMethodTest, CanTakeMoveOnlyValue) { ...@@ -1449,7 +1428,6 @@ TEST(MockMethodTest, CanTakeMoveOnlyValue) {
EXPECT_EQ(42, *saved); EXPECT_EQ(42, *saved);
} }
// Tests for std::function based action. // Tests for std::function based action.
int Add(int val, int& ref, int* ptr) { // NOLINT int Add(int val, int& ref, int* ptr) { // NOLINT
...@@ -1463,7 +1441,9 @@ int Deref(std::unique_ptr<int> ptr) { return *ptr; } ...@@ -1463,7 +1441,9 @@ int Deref(std::unique_ptr<int> ptr) { return *ptr; }
struct Double { struct Double {
template <typename T> template <typename T>
T operator()(T t) { return 2 * t; } T operator()(T t) {
return 2 * t;
}
}; };
std::unique_ptr<int> UniqueInt(int i) { std::unique_ptr<int> UniqueInt(int i) {
...@@ -1532,8 +1512,9 @@ TEST(FunctorActionTest, TypeConversion) { ...@@ -1532,8 +1512,9 @@ TEST(FunctorActionTest, TypeConversion) {
TEST(FunctorActionTest, UnusedArguments) { TEST(FunctorActionTest, UnusedArguments) {
// Verify that users can ignore uninteresting arguments. // Verify that users can ignore uninteresting arguments.
Action<int(int, double y, double z)> a = Action<int(int, double y, double z)> a = [](int i, Unused, Unused) {
[](int i, Unused, Unused) { return 2 * i; }; return 2 * i;
};
std::tuple<int, double, double> dummy = std::make_tuple(3, 7.3, 9.44); std::tuple<int, double, double> dummy = std::make_tuple(3, 7.3, 9.44);
EXPECT_EQ(6, a.Perform(dummy)); EXPECT_EQ(6, a.Perform(dummy));
} }
...@@ -1552,9 +1533,7 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) { ...@@ -1552,9 +1533,7 @@ TEST(MoveOnlyArgumentsTest, ReturningActions) {
EXPECT_EQ(x, 3); EXPECT_EQ(x, 3);
} }
ACTION(ReturnArity) { ACTION(ReturnArity) { return std::tuple_size<args_type>::value; }
return std::tuple_size<args_type>::value;
}
TEST(ActionMacro, LargeArity) { TEST(ActionMacro, LargeArity) {
EXPECT_EQ( EXPECT_EQ(
...@@ -1577,7 +1556,6 @@ TEST(ActionMacro, LargeArity) { ...@@ -1577,7 +1556,6 @@ TEST(ActionMacro, LargeArity) {
#ifdef _MSC_VER #ifdef _MSC_VER
#if _MSC_VER == 1900 #if _MSC_VER == 1900
# pragma warning(pop) #pragma warning(pop)
#endif #endif
#endif #endif
...@@ -27,14 +27,13 @@ ...@@ -27,14 +27,13 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file tests the built-in cardinalities. // This file tests the built-in cardinalities.
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "gtest/gtest-spi.h" #include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
namespace { namespace {
...@@ -59,9 +58,7 @@ class MockFoo { ...@@ -59,9 +58,7 @@ class MockFoo {
}; };
// Tests that Cardinality objects can be default constructed. // Tests that Cardinality objects can be default constructed.
TEST(CardinalityTest, IsDefaultConstructable) { TEST(CardinalityTest, IsDefaultConstructable) { Cardinality c; }
Cardinality c;
}
// Tests that Cardinality objects are copyable. // Tests that Cardinality objects are copyable.
TEST(CardinalityTest, IsCopyable) { TEST(CardinalityTest, IsCopyable) {
...@@ -119,8 +116,7 @@ TEST(AnyNumber, Works) { ...@@ -119,8 +116,7 @@ TEST(AnyNumber, Works) {
stringstream ss; stringstream ss;
c.DescribeTo(&ss); c.DescribeTo(&ss);
EXPECT_PRED_FORMAT2(IsSubstring, "called any number of times", EXPECT_PRED_FORMAT2(IsSubstring, "called any number of times", ss.str());
ss.str());
} }
TEST(AnyNumberTest, HasCorrectBounds) { TEST(AnyNumberTest, HasCorrectBounds) {
...@@ -132,9 +128,11 @@ TEST(AnyNumberTest, HasCorrectBounds) { ...@@ -132,9 +128,11 @@ TEST(AnyNumberTest, HasCorrectBounds) {
// Tests AtLeast(n). // Tests AtLeast(n).
TEST(AtLeastTest, OnNegativeNumber) { TEST(AtLeastTest, OnNegativeNumber) {
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
{ // NOLINT
AtLeast(-1); AtLeast(-1);
}, "The invocation lower bound must be >= 0"); },
"The invocation lower bound must be >= 0");
} }
TEST(AtLeastTest, OnZero) { TEST(AtLeastTest, OnZero) {
...@@ -147,8 +145,7 @@ TEST(AtLeastTest, OnZero) { ...@@ -147,8 +145,7 @@ TEST(AtLeastTest, OnZero) {
stringstream ss; stringstream ss;
c.DescribeTo(&ss); c.DescribeTo(&ss);
EXPECT_PRED_FORMAT2(IsSubstring, "any number of times", EXPECT_PRED_FORMAT2(IsSubstring, "any number of times", ss.str());
ss.str());
} }
TEST(AtLeastTest, OnPositiveNumber) { TEST(AtLeastTest, OnPositiveNumber) {
...@@ -164,18 +161,15 @@ TEST(AtLeastTest, OnPositiveNumber) { ...@@ -164,18 +161,15 @@ TEST(AtLeastTest, OnPositiveNumber) {
stringstream ss1; stringstream ss1;
AtLeast(1).DescribeTo(&ss1); AtLeast(1).DescribeTo(&ss1);
EXPECT_PRED_FORMAT2(IsSubstring, "at least once", EXPECT_PRED_FORMAT2(IsSubstring, "at least once", ss1.str());
ss1.str());
stringstream ss2; stringstream ss2;
c.DescribeTo(&ss2); c.DescribeTo(&ss2);
EXPECT_PRED_FORMAT2(IsSubstring, "at least twice", EXPECT_PRED_FORMAT2(IsSubstring, "at least twice", ss2.str());
ss2.str());
stringstream ss3; stringstream ss3;
AtLeast(3).DescribeTo(&ss3); AtLeast(3).DescribeTo(&ss3);
EXPECT_PRED_FORMAT2(IsSubstring, "at least 3 times", EXPECT_PRED_FORMAT2(IsSubstring, "at least 3 times", ss3.str());
ss3.str());
} }
TEST(AtLeastTest, HasCorrectBounds) { TEST(AtLeastTest, HasCorrectBounds) {
...@@ -187,9 +181,11 @@ TEST(AtLeastTest, HasCorrectBounds) { ...@@ -187,9 +181,11 @@ TEST(AtLeastTest, HasCorrectBounds) {
// Tests AtMost(n). // Tests AtMost(n).
TEST(AtMostTest, OnNegativeNumber) { TEST(AtMostTest, OnNegativeNumber) {
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
{ // NOLINT
AtMost(-1); AtMost(-1);
}, "The invocation upper bound must be >= 0"); },
"The invocation upper bound must be >= 0");
} }
TEST(AtMostTest, OnZero) { TEST(AtMostTest, OnZero) {
...@@ -202,8 +198,7 @@ TEST(AtMostTest, OnZero) { ...@@ -202,8 +198,7 @@ TEST(AtMostTest, OnZero) {
stringstream ss; stringstream ss;
c.DescribeTo(&ss); c.DescribeTo(&ss);
EXPECT_PRED_FORMAT2(IsSubstring, "never called", EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str());
ss.str());
} }
TEST(AtMostTest, OnPositiveNumber) { TEST(AtMostTest, OnPositiveNumber) {
...@@ -219,18 +214,15 @@ TEST(AtMostTest, OnPositiveNumber) { ...@@ -219,18 +214,15 @@ TEST(AtMostTest, OnPositiveNumber) {
stringstream ss1; stringstream ss1;
AtMost(1).DescribeTo(&ss1); AtMost(1).DescribeTo(&ss1);
EXPECT_PRED_FORMAT2(IsSubstring, "called at most once", EXPECT_PRED_FORMAT2(IsSubstring, "called at most once", ss1.str());
ss1.str());
stringstream ss2; stringstream ss2;
c.DescribeTo(&ss2); c.DescribeTo(&ss2);
EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", ss2.str());
ss2.str());
stringstream ss3; stringstream ss3;
AtMost(3).DescribeTo(&ss3); AtMost(3).DescribeTo(&ss3);
EXPECT_PRED_FORMAT2(IsSubstring, "called at most 3 times", EXPECT_PRED_FORMAT2(IsSubstring, "called at most 3 times", ss3.str());
ss3.str());
} }
TEST(AtMostTest, HasCorrectBounds) { TEST(AtMostTest, HasCorrectBounds) {
...@@ -242,21 +234,27 @@ TEST(AtMostTest, HasCorrectBounds) { ...@@ -242,21 +234,27 @@ TEST(AtMostTest, HasCorrectBounds) {
// Tests Between(m, n). // Tests Between(m, n).
TEST(BetweenTest, OnNegativeStart) { TEST(BetweenTest, OnNegativeStart) {
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
{ // NOLINT
Between(-1, 2); Between(-1, 2);
}, "The invocation lower bound must be >= 0, but is actually -1"); },
"The invocation lower bound must be >= 0, but is actually -1");
} }
TEST(BetweenTest, OnNegativeEnd) { TEST(BetweenTest, OnNegativeEnd) {
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
{ // NOLINT
Between(1, -2); Between(1, -2);
}, "The invocation upper bound must be >= 0, but is actually -2"); },
"The invocation upper bound must be >= 0, but is actually -2");
} }
TEST(BetweenTest, OnStartBiggerThanEnd) { TEST(BetweenTest, OnStartBiggerThanEnd) {
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
{ // NOLINT
Between(2, 1); Between(2, 1);
}, "The invocation upper bound (1) must be >= " },
"The invocation upper bound (1) must be >= "
"the invocation lower bound (2)"); "the invocation lower bound (2)");
} }
...@@ -271,8 +269,7 @@ TEST(BetweenTest, OnZeroStartAndZeroEnd) { ...@@ -271,8 +269,7 @@ TEST(BetweenTest, OnZeroStartAndZeroEnd) {
stringstream ss; stringstream ss;
c.DescribeTo(&ss); c.DescribeTo(&ss);
EXPECT_PRED_FORMAT2(IsSubstring, "never called", EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str());
ss.str());
} }
TEST(BetweenTest, OnZeroStartAndNonZeroEnd) { TEST(BetweenTest, OnZeroStartAndNonZeroEnd) {
...@@ -289,8 +286,7 @@ TEST(BetweenTest, OnZeroStartAndNonZeroEnd) { ...@@ -289,8 +286,7 @@ TEST(BetweenTest, OnZeroStartAndNonZeroEnd) {
stringstream ss; stringstream ss;
c.DescribeTo(&ss); c.DescribeTo(&ss);
EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", EXPECT_PRED_FORMAT2(IsSubstring, "called at most twice", ss.str());
ss.str());
} }
TEST(BetweenTest, OnSameStartAndEnd) { TEST(BetweenTest, OnSameStartAndEnd) {
...@@ -307,8 +303,7 @@ TEST(BetweenTest, OnSameStartAndEnd) { ...@@ -307,8 +303,7 @@ TEST(BetweenTest, OnSameStartAndEnd) {
stringstream ss; stringstream ss;
c.DescribeTo(&ss); c.DescribeTo(&ss);
EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", ss.str());
ss.str());
} }
TEST(BetweenTest, OnDifferentStartAndEnd) { TEST(BetweenTest, OnDifferentStartAndEnd) {
...@@ -328,8 +323,7 @@ TEST(BetweenTest, OnDifferentStartAndEnd) { ...@@ -328,8 +323,7 @@ TEST(BetweenTest, OnDifferentStartAndEnd) {
stringstream ss; stringstream ss;
c.DescribeTo(&ss); c.DescribeTo(&ss);
EXPECT_PRED_FORMAT2(IsSubstring, "called between 3 and 5 times", EXPECT_PRED_FORMAT2(IsSubstring, "called between 3 and 5 times", ss.str());
ss.str());
} }
TEST(BetweenTest, HasCorrectBounds) { TEST(BetweenTest, HasCorrectBounds) {
...@@ -341,9 +335,11 @@ TEST(BetweenTest, HasCorrectBounds) { ...@@ -341,9 +335,11 @@ TEST(BetweenTest, HasCorrectBounds) {
// Tests Exactly(n). // Tests Exactly(n).
TEST(ExactlyTest, OnNegativeNumber) { TEST(ExactlyTest, OnNegativeNumber) {
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
{ // NOLINT
Exactly(-1); Exactly(-1);
}, "The invocation lower bound must be >= 0"); },
"The invocation lower bound must be >= 0");
} }
TEST(ExactlyTest, OnZero) { TEST(ExactlyTest, OnZero) {
...@@ -356,8 +352,7 @@ TEST(ExactlyTest, OnZero) { ...@@ -356,8 +352,7 @@ TEST(ExactlyTest, OnZero) {
stringstream ss; stringstream ss;
c.DescribeTo(&ss); c.DescribeTo(&ss);
EXPECT_PRED_FORMAT2(IsSubstring, "never called", EXPECT_PRED_FORMAT2(IsSubstring, "never called", ss.str());
ss.str());
} }
TEST(ExactlyTest, OnPositiveNumber) { TEST(ExactlyTest, OnPositiveNumber) {
...@@ -370,18 +365,15 @@ TEST(ExactlyTest, OnPositiveNumber) { ...@@ -370,18 +365,15 @@ TEST(ExactlyTest, OnPositiveNumber) {
stringstream ss1; stringstream ss1;
Exactly(1).DescribeTo(&ss1); Exactly(1).DescribeTo(&ss1);
EXPECT_PRED_FORMAT2(IsSubstring, "called once", EXPECT_PRED_FORMAT2(IsSubstring, "called once", ss1.str());
ss1.str());
stringstream ss2; stringstream ss2;
c.DescribeTo(&ss2); c.DescribeTo(&ss2);
EXPECT_PRED_FORMAT2(IsSubstring, "called twice", EXPECT_PRED_FORMAT2(IsSubstring, "called twice", ss2.str());
ss2.str());
stringstream ss3; stringstream ss3;
Exactly(3).DescribeTo(&ss3); Exactly(3).DescribeTo(&ss3);
EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", EXPECT_PRED_FORMAT2(IsSubstring, "called 3 times", ss3.str());
ss3.str());
} }
TEST(ExactlyTest, HasCorrectBounds) { TEST(ExactlyTest, HasCorrectBounds) {
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file tests the function mocker classes. // This file tests the function mocker classes.
...@@ -37,7 +36,7 @@ ...@@ -37,7 +36,7 @@
// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but // 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 // we are getting compiler errors if we use basetyps.h, hence including
// objbase.h for definition of STDMETHOD. // objbase.h for definition of STDMETHOD.
# include <objbase.h> #include <objbase.h>
#endif // GTEST_OS_WINDOWS #endif // GTEST_OS_WINDOWS
#include <functional> #include <functional>
...@@ -65,7 +64,7 @@ using testing::Return; ...@@ -65,7 +64,7 @@ using testing::Return;
using testing::ReturnRef; using testing::ReturnRef;
using testing::TypedEq; using testing::TypedEq;
template<typename T> template <typename T>
class TemplatedCopyable { class TemplatedCopyable {
public: public:
TemplatedCopyable() {} TemplatedCopyable() {}
...@@ -133,8 +132,8 @@ class FooInterface { ...@@ -133,8 +132,8 @@ class FooInterface {
// signature. This was fixed in Visual Studio 2008. However, the compiler // signature. This was fixed in Visual Studio 2008. However, the compiler
// still emits a warning that alerts about this change in behavior. // still emits a warning that alerts about this change in behavior.
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(push) #pragma warning(push)
# pragma warning(disable : 4373) #pragma warning(disable : 4373)
#endif #endif
class MockFoo : public FooInterface { class MockFoo : public FooInterface {
public: public:
...@@ -279,7 +278,7 @@ class LegacyMockFoo : public FooInterface { ...@@ -279,7 +278,7 @@ class LegacyMockFoo : public FooInterface {
}; };
#ifdef _MSC_VER #ifdef _MSC_VER
# pragma warning(pop) #pragma warning(pop)
#endif #endif
template <class T> template <class T>
...@@ -595,10 +594,8 @@ TYPED_TEST(TemplateMockTest, Works) { ...@@ -595,10 +594,8 @@ TYPED_TEST(TemplateMockTest, Works) {
.WillOnce(Return(0)); .WillOnce(Return(0));
EXPECT_CALL(mock, Push(_)); EXPECT_CALL(mock, Push(_));
int n = 5; int n = 5;
EXPECT_CALL(mock, GetTop()) EXPECT_CALL(mock, GetTop()).WillOnce(ReturnRef(n));
.WillOnce(ReturnRef(n)); EXPECT_CALL(mock, Pop()).Times(AnyNumber());
EXPECT_CALL(mock, Pop())
.Times(AnyNumber());
EXPECT_EQ(0, mock.GetSize()); EXPECT_EQ(0, mock.GetSize());
mock.Push(5); mock.Push(5);
...@@ -612,10 +609,8 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) { ...@@ -612,10 +609,8 @@ TYPED_TEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {
TypeParam mock; TypeParam mock;
const std::map<int, int> a_map; const std::map<int, int> a_map;
EXPECT_CALL(mock, ReturnTypeWithComma()) EXPECT_CALL(mock, ReturnTypeWithComma()).WillOnce(Return(a_map));
.WillOnce(Return(a_map)); EXPECT_CALL(mock, ReturnTypeWithComma(1)).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());
EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1)); EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));
...@@ -685,10 +680,8 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) { ...@@ -685,10 +680,8 @@ TYPED_TEST(TemplateMockTestWithCallType, Works) {
.WillOnce(Return(0)); .WillOnce(Return(0));
EXPECT_CALL(mock, Push(_)); EXPECT_CALL(mock, Push(_));
int n = 5; int n = 5;
EXPECT_CALL(mock, GetTop()) EXPECT_CALL(mock, GetTop()).WillOnce(ReturnRef(n));
.WillOnce(ReturnRef(n)); EXPECT_CALL(mock, Pop()).Times(AnyNumber());
EXPECT_CALL(mock, Pop())
.Times(AnyNumber());
EXPECT_EQ(0, mock.GetSize()); EXPECT_EQ(0, mock.GetSize());
mock.Push(5); mock.Push(5);
...@@ -779,9 +772,7 @@ TEST(MockMethodMockFunctionTest, WorksForVoidNullary) { ...@@ -779,9 +772,7 @@ TEST(MockMethodMockFunctionTest, WorksForVoidNullary) {
TEST(MockMethodMockFunctionTest, WorksForNonVoidNullary) { TEST(MockMethodMockFunctionTest, WorksForNonVoidNullary) {
MockFunction<int()> foo; MockFunction<int()> foo;
EXPECT_CALL(foo, Call()) EXPECT_CALL(foo, Call()).WillOnce(Return(1)).WillOnce(Return(2));
.WillOnce(Return(1))
.WillOnce(Return(2));
EXPECT_EQ(1, foo.Call()); EXPECT_EQ(1, foo.Call());
EXPECT_EQ(2, foo.Call()); EXPECT_EQ(2, foo.Call());
} }
...@@ -794,19 +785,17 @@ TEST(MockMethodMockFunctionTest, WorksForVoidUnary) { ...@@ -794,19 +785,17 @@ TEST(MockMethodMockFunctionTest, WorksForVoidUnary) {
TEST(MockMethodMockFunctionTest, WorksForNonVoidBinary) { TEST(MockMethodMockFunctionTest, WorksForNonVoidBinary) {
MockFunction<int(bool, int)> foo; MockFunction<int(bool, int)> foo;
EXPECT_CALL(foo, Call(false, 42)) EXPECT_CALL(foo, Call(false, 42)).WillOnce(Return(1)).WillOnce(Return(2));
.WillOnce(Return(1)) EXPECT_CALL(foo, Call(true, Ge(100))).WillOnce(Return(3));
.WillOnce(Return(2));
EXPECT_CALL(foo, Call(true, Ge(100)))
.WillOnce(Return(3));
EXPECT_EQ(1, foo.Call(false, 42)); EXPECT_EQ(1, foo.Call(false, 42));
EXPECT_EQ(2, foo.Call(false, 42)); EXPECT_EQ(2, foo.Call(false, 42));
EXPECT_EQ(3, foo.Call(true, 120)); EXPECT_EQ(3, foo.Call(true, 120));
} }
TEST(MockMethodMockFunctionTest, WorksFor10Arguments) { TEST(MockMethodMockFunctionTest, WorksFor10Arguments) {
MockFunction<int(bool a0, char a1, int a2, int a3, int a4, MockFunction<int(bool a0, char a1, int a2, int a3, int a4, int a5, int a6,
int a5, int a6, char a7, int a8, bool a9)> foo; char a7, int a8, bool a9)>
foo;
EXPECT_CALL(foo, Call(_, 'a', _, _, _, _, _, _, _, _)) EXPECT_CALL(foo, Call(_, 'a', _, _, _, _, _, _, _, _))
.WillOnce(Return(1)) .WillOnce(Return(1))
.WillOnce(Return(2)); .WillOnce(Return(2));
...@@ -816,9 +805,7 @@ TEST(MockMethodMockFunctionTest, WorksFor10Arguments) { ...@@ -816,9 +805,7 @@ TEST(MockMethodMockFunctionTest, WorksFor10Arguments) {
TEST(MockMethodMockFunctionTest, AsStdFunction) { TEST(MockMethodMockFunctionTest, AsStdFunction) {
MockFunction<int(int)> foo; MockFunction<int(int)> foo;
auto call = [](const std::function<int(int)> &f, int i) { auto call = [](const std::function<int(int)>& f, int i) { return f(i); };
return f(i);
};
EXPECT_CALL(foo, Call(1)).WillOnce(Return(-1)); EXPECT_CALL(foo, Call(1)).WillOnce(Return(-1));
EXPECT_CALL(foo, Call(2)).WillOnce(Return(-2)); EXPECT_CALL(foo, Call(2)).WillOnce(Return(-2));
EXPECT_EQ(-1, call(foo.AsStdFunction(), 1)); EXPECT_EQ(-1, call(foo.AsStdFunction(), 1));
...@@ -836,10 +823,8 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionReturnsReference) { ...@@ -836,10 +823,8 @@ TEST(MockMethodMockFunctionTest, AsStdFunctionReturnsReference) {
} }
TEST(MockMethodMockFunctionTest, AsStdFunctionWithReferenceParameter) { TEST(MockMethodMockFunctionTest, AsStdFunctionWithReferenceParameter) {
MockFunction<int(int &)> foo; MockFunction<int(int&)> foo;
auto call = [](const std::function<int(int& )> &f, int &i) { auto call = [](const std::function<int(int&)>& f, int& i) { return f(i); };
return f(i);
};
int i = 42; int i = 42;
EXPECT_CALL(foo, Call(i)).WillOnce(Return(-1)); EXPECT_CALL(foo, Call(i)).WillOnce(Return(-1));
EXPECT_EQ(-1, call(foo.AsStdFunction(), i)); EXPECT_EQ(-1, call(foo.AsStdFunction(), i));
...@@ -888,8 +873,7 @@ TYPED_TEST( ...@@ -888,8 +873,7 @@ TYPED_TEST(
} }
template <typename F> template <typename F>
struct AlternateCallable { struct AlternateCallable {};
};
TYPED_TEST(MockMethodMockFunctionSignatureTest, TYPED_TEST(MockMethodMockFunctionSignatureTest,
IsMockFunctionTemplateArgumentDeducedForAlternateCallable) { IsMockFunctionTemplateArgumentDeducedForAlternateCallable) {
...@@ -898,8 +882,7 @@ TYPED_TEST(MockMethodMockFunctionSignatureTest, ...@@ -898,8 +882,7 @@ TYPED_TEST(MockMethodMockFunctionSignatureTest,
EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo)); EXPECT_TRUE(IsMockFunctionTemplateArgumentDeducedTo<TypeParam>(foo));
} }
TYPED_TEST( TYPED_TEST(MockMethodMockFunctionSignatureTest,
MockMethodMockFunctionSignatureTest,
IsMockFunctionCallMethodSignatureTheSameForAlternateCallable) { IsMockFunctionCallMethodSignatureTheSameForAlternateCallable) {
using ForRawSignature = decltype(&MockFunction<TypeParam>::Call); using ForRawSignature = decltype(&MockFunction<TypeParam>::Call);
using ForStdFunction = using ForStdFunction =
...@@ -907,7 +890,6 @@ TYPED_TEST( ...@@ -907,7 +890,6 @@ TYPED_TEST(
EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value)); EXPECT_TRUE((std::is_same<ForRawSignature, ForStdFunction>::value));
} }
struct MockMethodSizes0 { struct MockMethodSizes0 {
MOCK_METHOD(void, func, ()); MOCK_METHOD(void, func, ());
}; };
...@@ -940,7 +922,6 @@ struct LegacyMockMethodSizes4 { ...@@ -940,7 +922,6 @@ struct LegacyMockMethodSizes4 {
MOCK_METHOD4(func, void(int, int, int, int)); MOCK_METHOD4(func, void(int, int, int, int));
}; };
TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) { TEST(MockMethodMockFunctionTest, MockMethodSizeOverhead) {
EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes1)); EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes1));
EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes2)); EXPECT_EQ(sizeof(MockMethodSizes0), sizeof(MockMethodSizes2));
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Google Mock - a framework for writing C++ mock classes. // Google Mock - a framework for writing C++ mock classes.
// //
// This file tests the internal utilities. // This file tests the internal utilities.
...@@ -58,7 +57,7 @@ ...@@ -58,7 +57,7 @@
#undef GTEST_IMPLEMENTATION_ #undef GTEST_IMPLEMENTATION_
#if GTEST_OS_CYGWIN #if GTEST_OS_CYGWIN
# include <sys/types.h> // For ssize_t. NOLINT #include <sys/types.h> // For ssize_t. NOLINT
#endif #endif
namespace proto2 { namespace proto2 {
...@@ -214,26 +213,26 @@ TEST(LosslessArithmeticConvertibleTest, IntegerToInteger) { ...@@ -214,26 +213,26 @@ TEST(LosslessArithmeticConvertibleTest, IntegerToInteger) {
EXPECT_TRUE((LosslessArithmeticConvertible<unsigned char, int>::value)); EXPECT_TRUE((LosslessArithmeticConvertible<unsigned char, int>::value));
// Unsigned => larger unsigned is fine. // Unsigned => larger unsigned is fine.
EXPECT_TRUE((LosslessArithmeticConvertible< EXPECT_TRUE((LosslessArithmeticConvertible<unsigned short,
unsigned short, uint64_t>::value)); // NOLINT uint64_t>::value)); // NOLINT
// Signed => unsigned is not fine. // Signed => unsigned is not fine.
EXPECT_FALSE((LosslessArithmeticConvertible< EXPECT_FALSE(
short, uint64_t>::value)); // NOLINT (LosslessArithmeticConvertible<short, uint64_t>::value)); // NOLINT
EXPECT_FALSE((LosslessArithmeticConvertible< EXPECT_FALSE((LosslessArithmeticConvertible<signed char,
signed char, unsigned int>::value)); // NOLINT unsigned int>::value)); // NOLINT
// Same size and same signedness: fine too. // Same size and same signedness: fine too.
EXPECT_TRUE((LosslessArithmeticConvertible< EXPECT_TRUE(
unsigned char, unsigned char>::value)); (LosslessArithmeticConvertible<unsigned char, unsigned char>::value));
EXPECT_TRUE((LosslessArithmeticConvertible<int, int>::value)); EXPECT_TRUE((LosslessArithmeticConvertible<int, int>::value));
EXPECT_TRUE((LosslessArithmeticConvertible<wchar_t, wchar_t>::value)); EXPECT_TRUE((LosslessArithmeticConvertible<wchar_t, wchar_t>::value));
EXPECT_TRUE((LosslessArithmeticConvertible< EXPECT_TRUE((LosslessArithmeticConvertible<unsigned long,
unsigned long, unsigned long>::value)); // NOLINT unsigned long>::value)); // NOLINT
// Same size, different signedness: not fine. // Same size, different signedness: not fine.
EXPECT_FALSE((LosslessArithmeticConvertible< EXPECT_FALSE(
unsigned char, signed char>::value)); (LosslessArithmeticConvertible<unsigned char, signed char>::value));
EXPECT_FALSE((LosslessArithmeticConvertible<int, unsigned int>::value)); EXPECT_FALSE((LosslessArithmeticConvertible<int, unsigned int>::value));
EXPECT_FALSE((LosslessArithmeticConvertible<uint64_t, int64_t>::value)); EXPECT_FALSE((LosslessArithmeticConvertible<uint64_t, int64_t>::value));
...@@ -248,8 +247,8 @@ TEST(LosslessArithmeticConvertibleTest, IntegerToFloatingPoint) { ...@@ -248,8 +247,8 @@ TEST(LosslessArithmeticConvertibleTest, IntegerToFloatingPoint) {
// the format of the latter is implementation-defined. // the format of the latter is implementation-defined.
EXPECT_FALSE((LosslessArithmeticConvertible<char, float>::value)); EXPECT_FALSE((LosslessArithmeticConvertible<char, float>::value));
EXPECT_FALSE((LosslessArithmeticConvertible<int, double>::value)); EXPECT_FALSE((LosslessArithmeticConvertible<int, double>::value));
EXPECT_FALSE((LosslessArithmeticConvertible< EXPECT_FALSE(
short, long double>::value)); // NOLINT (LosslessArithmeticConvertible<short, long double>::value)); // NOLINT
} }
TEST(LosslessArithmeticConvertibleTest, FloatingPointToBool) { TEST(LosslessArithmeticConvertibleTest, FloatingPointToBool) {
...@@ -296,7 +295,7 @@ TEST(TupleMatchesTest, WorksForSize0) { ...@@ -296,7 +295,7 @@ TEST(TupleMatchesTest, WorksForSize0) {
} }
TEST(TupleMatchesTest, WorksForSize1) { TEST(TupleMatchesTest, WorksForSize1) {
std::tuple<Matcher<int> > matchers(Eq(1)); std::tuple<Matcher<int>> matchers(Eq(1));
std::tuple<int> values1(1), values2(2); std::tuple<int> values1(1), values2(2);
EXPECT_TRUE(TupleMatches(matchers, values1)); EXPECT_TRUE(TupleMatches(matchers, values1));
...@@ -304,7 +303,7 @@ TEST(TupleMatchesTest, WorksForSize1) { ...@@ -304,7 +303,7 @@ TEST(TupleMatchesTest, WorksForSize1) {
} }
TEST(TupleMatchesTest, WorksForSize2) { 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'), std::tuple<int, char> values1(1, 'a'), values2(1, 'b'), values3(2, 'a'),
values4(2, 'b'); values4(2, 'b');
...@@ -317,7 +316,7 @@ TEST(TupleMatchesTest, WorksForSize2) { ...@@ -317,7 +316,7 @@ TEST(TupleMatchesTest, WorksForSize2) {
TEST(TupleMatchesTest, WorksForSize5) { TEST(TupleMatchesTest, WorksForSize5) {
std::tuple<Matcher<int>, Matcher<char>, Matcher<bool>, std::tuple<Matcher<int>, Matcher<char>, Matcher<bool>,
Matcher<long>, // NOLINT Matcher<long>, // NOLINT
Matcher<std::string> > Matcher<std::string>>
matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq("hi")); matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq("hi"));
std::tuple<int, char, bool, long, std::string> // NOLINT std::tuple<int, char, bool, long, std::string> // NOLINT
values1(1, 'a', true, 2L, "hi"), values2(1, 'a', true, 2L, "hello"), values1(1, 'a', true, 2L, "hi"), values2(1, 'a', true, 2L, "hello"),
...@@ -336,13 +335,10 @@ TEST(AssertTest, SucceedsOnTrue) { ...@@ -336,13 +335,10 @@ TEST(AssertTest, SucceedsOnTrue) {
// Tests that Assert(false, ...) generates a fatal failure. // Tests that Assert(false, ...) generates a fatal failure.
TEST(AssertTest, FailsFatallyOnFalse) { TEST(AssertTest, FailsFatallyOnFalse) {
EXPECT_DEATH_IF_SUPPORTED({ EXPECT_DEATH_IF_SUPPORTED(
Assert(false, __FILE__, __LINE__, "This should fail."); { Assert(false, __FILE__, __LINE__, "This should fail."); }, "");
}, "");
EXPECT_DEATH_IF_SUPPORTED({ EXPECT_DEATH_IF_SUPPORTED({ Assert(false, __FILE__, __LINE__); }, "");
Assert(false, __FILE__, __LINE__);
}, "");
} }
// Tests that Expect(true, ...) succeeds. // Tests that Expect(true, ...) succeeds.
...@@ -353,13 +349,17 @@ TEST(ExpectTest, SucceedsOnTrue) { ...@@ -353,13 +349,17 @@ TEST(ExpectTest, SucceedsOnTrue) {
// Tests that Expect(false, ...) generates a non-fatal failure. // Tests that Expect(false, ...) generates a non-fatal failure.
TEST(ExpectTest, FailsNonfatallyOnFalse) { TEST(ExpectTest, FailsNonfatallyOnFalse) {
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
{ // NOLINT
Expect(false, __FILE__, __LINE__, "This should fail."); Expect(false, __FILE__, __LINE__, "This should fail.");
}, "This should fail"); },
"This should fail");
EXPECT_NONFATAL_FAILURE({ // NOLINT EXPECT_NONFATAL_FAILURE(
{ // NOLINT
Expect(false, __FILE__, __LINE__); Expect(false, __FILE__, __LINE__);
}, "Expectation failed"); },
"Expectation failed");
} }
// Tests LogIsVisible(). // Tests LogIsVisible().
...@@ -404,11 +404,11 @@ void TestLogWithSeverity(const std::string& verbosity, LogSeverity severity, ...@@ -404,11 +404,11 @@ void TestLogWithSeverity(const std::string& verbosity, LogSeverity severity,
CaptureStdout(); CaptureStdout();
Log(severity, "Test log.\n", 0); Log(severity, "Test log.\n", 0);
if (should_print) { if (should_print) {
EXPECT_THAT(GetCapturedStdout().c_str(), EXPECT_THAT(
ContainsRegex( GetCapturedStdout().c_str(),
severity == kWarning ? ContainsRegex(severity == kWarning
"^\nGMOCK WARNING:\nTest log\\.\nStack trace:\n" : ? "^\nGMOCK WARNING:\nTest log\\.\nStack trace:\n"
"^\nTest log\\.\nStack trace:\n")); : "^\nTest log\\.\nStack trace:\n"));
} else { } else {
EXPECT_STREQ("", GetCapturedStdout().c_str()); EXPECT_STREQ("", GetCapturedStdout().c_str());
} }
...@@ -455,13 +455,13 @@ TEST(LogTest, NoSkippingStackFrameInOptMode) { ...@@ -455,13 +455,13 @@ TEST(LogTest, NoSkippingStackFrameInOptMode) {
EXPECT_THAT(log, HasSubstr(expected_message)); EXPECT_THAT(log, HasSubstr(expected_message));
int skip_count = atoi(log.substr(expected_message.size()).c_str()); 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. // In opt mode, no stack frame should be skipped.
const int expected_skip_count = 0; const int expected_skip_count = 0;
# else #else
// In dbg mode, the stack frames should be skipped. // In dbg mode, the stack frames should be skipped.
const int expected_skip_count = 100; const int expected_skip_count = 100;
# endif #endif
// Note that each inner implementation layer will +1 the number to remove // 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 // itself from the trace. This means that the value is a little higher than
...@@ -503,7 +503,7 @@ TEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsInvalid) { ...@@ -503,7 +503,7 @@ TEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsInvalid) {
// Verifies that Log() behaves correctly for the given verbosity level // Verifies that Log() behaves correctly for the given verbosity level
// and log severity. // 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); const std::string saved_flag = GMOCK_FLAG_GET(verbose);
GMOCK_FLAG_SET(verbose, verbosity); GMOCK_FLAG_SET(verbose, verbosity);
CaptureStdout(); CaptureStdout();
...@@ -582,9 +582,9 @@ TEST(OnCallTest, LogsAnythingArgument) { ...@@ -582,9 +582,9 @@ TEST(OnCallTest, LogsAnythingArgument) {
TEST(StlContainerViewTest, WorksForStlContainer) { TEST(StlContainerViewTest, WorksForStlContainer) {
StaticAssertTypeEq<std::vector<int>, StaticAssertTypeEq<std::vector<int>,
StlContainerView<std::vector<int> >::type>(); StlContainerView<std::vector<int>>::type>();
StaticAssertTypeEq<const std::vector<double>&, StaticAssertTypeEq<const std::vector<double>&,
StlContainerView<std::vector<double> >::const_reference>(); StlContainerView<std::vector<double>>::const_reference>();
typedef std::vector<char> Chars; typedef std::vector<char> Chars;
Chars v1; Chars v1;
...@@ -597,8 +597,7 @@ TEST(StlContainerViewTest, WorksForStlContainer) { ...@@ -597,8 +597,7 @@ TEST(StlContainerViewTest, WorksForStlContainer) {
} }
TEST(StlContainerViewTest, WorksForStaticNativeArray) { TEST(StlContainerViewTest, WorksForStaticNativeArray) {
StaticAssertTypeEq<NativeArray<int>, StaticAssertTypeEq<NativeArray<int>, StlContainerView<int[3]>::type>();
StlContainerView<int[3]>::type>();
StaticAssertTypeEq<NativeArray<double>, StaticAssertTypeEq<NativeArray<double>,
StlContainerView<const double[4]>::type>(); StlContainerView<const double[4]>::type>();
StaticAssertTypeEq<NativeArray<char[3]>, StaticAssertTypeEq<NativeArray<char[3]>,
...@@ -607,7 +606,7 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) { ...@@ -607,7 +606,7 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) {
StaticAssertTypeEq<const NativeArray<int>, 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); NativeArray<int> a2 = StlContainerView<int[3]>::ConstReference(a1);
EXPECT_EQ(3U, a2.size()); EXPECT_EQ(3U, a2.size());
EXPECT_EQ(a1, a2.begin()); EXPECT_EQ(a1, a2.begin());
...@@ -625,24 +624,24 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) { ...@@ -625,24 +624,24 @@ TEST(StlContainerViewTest, WorksForStaticNativeArray) {
TEST(StlContainerViewTest, WorksForDynamicNativeArray) { TEST(StlContainerViewTest, WorksForDynamicNativeArray) {
StaticAssertTypeEq<NativeArray<int>, StaticAssertTypeEq<NativeArray<int>,
StlContainerView<std::tuple<const int*, size_t> >::type>(); StlContainerView<std::tuple<const int*, size_t>>::type>();
StaticAssertTypeEq< StaticAssertTypeEq<
NativeArray<double>, NativeArray<double>,
StlContainerView<std::tuple<std::shared_ptr<double>, int> >::type>(); StlContainerView<std::tuple<std::shared_ptr<double>, int>>::type>();
StaticAssertTypeEq< StaticAssertTypeEq<
const NativeArray<int>, 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; const int* const p1 = a1;
NativeArray<int> a2 = NativeArray<int> a2 =
StlContainerView<std::tuple<const int*, int> >::ConstReference( StlContainerView<std::tuple<const int*, int>>::ConstReference(
std::make_tuple(p1, 3)); std::make_tuple(p1, 3));
EXPECT_EQ(3U, a2.size()); EXPECT_EQ(3U, a2.size());
EXPECT_EQ(a1, a2.begin()); 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)); std::make_tuple(static_cast<int*>(a1), 3));
ASSERT_EQ(3U, a3.size()); ASSERT_EQ(3U, a3.size());
EXPECT_EQ(0, a3.begin()[0]); EXPECT_EQ(0, a3.begin()[0]);
......
This diff is collapsed.
...@@ -145,7 +145,7 @@ class Foo { ...@@ -145,7 +145,7 @@ class Foo {
std::string Binary(const std::string& str, char c) const { return str + c; } 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 { int SumOf4(int a, int b, int c, int d) const {
return a + b + c + d + value_; return a + b + c + d + value_;
...@@ -291,8 +291,7 @@ TEST(InvokeTest, FunctionWithUnusedParameters) { ...@@ -291,8 +291,7 @@ TEST(InvokeTest, FunctionWithUnusedParameters) {
std::make_tuple(10, 2, 5.6, std::string("hi")); std::make_tuple(10, 2, 5.6, std::string("hi"));
EXPECT_EQ(12, a1.Perform(dummy)); EXPECT_EQ(12, a1.Perform(dummy));
Action<int(int, int, bool, int*)> a2 = Action<int(int, int, bool, int*)> a2 = Invoke(SumOfFirst2);
Invoke(SumOfFirst2);
EXPECT_EQ( EXPECT_EQ(
23, a2.Perform(std::make_tuple(20, 3, true, static_cast<int*>(nullptr)))); 23, a2.Perform(std::make_tuple(20, 3, true, static_cast<int*>(nullptr))));
} }
...@@ -303,8 +302,7 @@ TEST(InvokeTest, MethodWithUnusedParameters) { ...@@ -303,8 +302,7 @@ TEST(InvokeTest, MethodWithUnusedParameters) {
Action<int(std::string, bool, int, int)> a1 = Invoke(&foo, &Foo::SumOfLast2); 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))); EXPECT_EQ(12, a1.Perform(std::make_tuple(CharPtr("hi"), true, 10, 2)));
Action<int(char, double, int, int)> a2 = Action<int(char, double, int, int)> a2 = Invoke(&foo, &Foo::SumOfLast2);
Invoke(&foo, &Foo::SumOfLast2);
EXPECT_EQ(23, a2.Perform(std::make_tuple('a', 2.5, 20, 3))); EXPECT_EQ(23, a2.Perform(std::make_tuple('a', 2.5, 20, 3)));
} }
...@@ -362,7 +360,8 @@ TEST(InvokeMethodTest, MethodThatTakes4Arguments) { ...@@ -362,7 +360,8 @@ TEST(InvokeMethodTest, MethodThatTakes4Arguments) {
// Tests using Invoke() with a 5-argument method. // Tests using Invoke() with a 5-argument method.
TEST(InvokeMethodTest, MethodThatTakes5Arguments) { TEST(InvokeMethodTest, MethodThatTakes5Arguments) {
Foo foo; 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))); EXPECT_EQ(12345, a.Perform(std::make_tuple(10000, 2000, 300, 40, 5)));
} }
...@@ -523,15 +522,12 @@ TEST(SetArgRefereeActionTest, WorksWithExtraArguments) { ...@@ -523,15 +522,12 @@ TEST(SetArgRefereeActionTest, WorksWithExtraArguments) {
// the bool provided to the constructor to true when destroyed. // the bool provided to the constructor to true when destroyed.
class DeletionTester { class DeletionTester {
public: public:
explicit DeletionTester(bool* is_deleted) explicit DeletionTester(bool* is_deleted) : is_deleted_(is_deleted) {
: is_deleted_(is_deleted) {
// Make sure the bit is set to false. // Make sure the bit is set to false.
*is_deleted_ = false; *is_deleted_ = false;
} }
~DeletionTester() { ~DeletionTester() { *is_deleted_ = true; }
*is_deleted_ = true;
}
private: private:
bool* is_deleted_; bool* is_deleted_;
...@@ -549,8 +545,9 @@ TEST(DeleteArgActionTest, OneArg) { ...@@ -549,8 +545,9 @@ TEST(DeleteArgActionTest, OneArg) {
TEST(DeleteArgActionTest, TenArgs) { TEST(DeleteArgActionTest, TenArgs) {
bool is_deleted = false; bool is_deleted = false;
DeletionTester* t = new DeletionTester(&is_deleted); DeletionTester* t = new DeletionTester(&is_deleted);
const Action<void(bool, int, int, const char*, bool, const Action<void(bool, int, int, const char*, bool, int, int, int, int,
int, int, int, int, DeletionTester*)> a1 = DeleteArg<9>(); DeletionTester*)>
a1 = DeleteArg<9>();
EXPECT_FALSE(is_deleted); EXPECT_FALSE(is_deleted);
a1.Perform(std::make_tuple(true, 5, 6, CharPtr("hi"), false, 7, 8, 9, 10, t)); a1.Perform(std::make_tuple(true, 5, 6, CharPtr("hi"), false, 7, 8, 9, 10, t));
EXPECT_TRUE(is_deleted); EXPECT_TRUE(is_deleted);
...@@ -608,7 +605,7 @@ TEST(ThrowActionTest, Times0) { ...@@ -608,7 +605,7 @@ TEST(ThrowActionTest, Times0) {
// pointed to by the N-th (0-based) argument to values in range [first, last). // pointed to by the N-th (0-based) argument to values in range [first, last).
TEST(SetArrayArgumentTest, SetsTheNthArray) { TEST(SetArrayArgumentTest, SetsTheNthArray) {
using MyFunction = void(bool, int*, char*); using MyFunction = void(bool, int*, char*);
int numbers[] = { 1, 2, 3 }; int numbers[] = {1, 2, 3};
Action<MyFunction> a = SetArrayArgument<1>(numbers, numbers + 3); Action<MyFunction> a = SetArrayArgument<1>(numbers, numbers + 3);
int n[4] = {}; int n[4] = {};
...@@ -644,7 +641,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArray) { ...@@ -644,7 +641,7 @@ TEST(SetArrayArgumentTest, SetsTheNthArray) {
// Tests SetArrayArgument<N>(first, last) where first == last. // Tests SetArrayArgument<N>(first, last) where first == last.
TEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) { TEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) {
using MyFunction = void(bool, int*); using MyFunction = void(bool, int*);
int numbers[] = { 1, 2, 3 }; int numbers[] = {1, 2, 3};
Action<MyFunction> a = SetArrayArgument<1>(numbers, numbers); Action<MyFunction> a = SetArrayArgument<1>(numbers, numbers);
int n[4] = {}; int n[4] = {};
...@@ -660,10 +657,10 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) { ...@@ -660,10 +657,10 @@ TEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) {
// (but not equal) to the argument type. // (but not equal) to the argument type.
TEST(SetArrayArgumentTest, SetsTheNthArrayWithConvertibleType) { TEST(SetArrayArgumentTest, SetsTheNthArrayWithConvertibleType) {
using MyFunction = void(bool, int*); using MyFunction = void(bool, int*);
char chars[] = { 97, 98, 99 }; char chars[] = {97, 98, 99};
Action<MyFunction> a = SetArrayArgument<1>(chars, chars + 3); 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; int* pcodes = codes;
a.Perform(std::make_tuple(true, pcodes)); a.Perform(std::make_tuple(true, pcodes));
EXPECT_EQ(97, codes[0]); EXPECT_EQ(97, codes[0]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment