diff options
20 files changed, 136 insertions, 393 deletions
diff --git a/.travis.yml b/.travis.yml index 27c725c0..930f9944 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,16 +25,16 @@ matrix: script: ./ci/build-linux-bazel.sh - os: linux compiler: gcc - env: BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11 + env: BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" - os: linux compiler: clang - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" NO_EXCEPTION=ON NO_RTTI=ON COMPILER_IS_GNUCXX=ON - os: osx compiler: gcc - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp - os: osx compiler: clang - env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS=-std=c++11 HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp + env: BUILD_TYPE=Release VERBOSE=1 CXX_FLAGS="-std=c++11 -Wdeprecated" HOMEBREW_LOGS=~/homebrew-logs HOMEBREW_TEMP=~/homebrew-temp # These are the install and build (script) phases for the most common entries in the matrix. They could be included # in each entry in the matrix, but that is just repetitive. diff --git a/ci/travis.sh b/ci/travis.sh index f37660bb..a2488229 100755 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -3,21 +3,6 @@ set -evx . ci/get-nprocessors.sh -# if possible, ask for the precise number of processors, -# otherwise take 2 processors as reasonable default; see -# https://docs.travis-ci.com/user/speeding-up-the-build/#Makefile-optimization -if [ -x /usr/bin/getconf ]; then - NPROCESSORS=$(/usr/bin/getconf _NPROCESSORS_ONLN) -else - NPROCESSORS=2 -fi -# as of 2017-09-04 Travis CI reports 32 processors, but GCC build -# crashes if parallelized too much (maybe memory consumption problem), -# so limit to 4 processors for the time being. -if [ $NPROCESSORS -gt 4 ] ; then - echo "$0:Note: Limiting processors to use by make from $NPROCESSORS to 4." - NPROCESSORS=4 -fi # Tell make to use the processors. No preceding '-' required. MAKEFLAGS="j${NPROCESSORS}" export MAKEFLAGS diff --git a/googlemock/docs/for_dummies.md b/googlemock/docs/for_dummies.md index 327e6cc3..8f5d17ae 100644 --- a/googlemock/docs/for_dummies.md +++ b/googlemock/docs/for_dummies.md @@ -257,8 +257,8 @@ Stack trace: ... ``` -**Tip 1:** If you run the test from an Emacs buffer, you can hit <Enter> on the -line number to jump right to the failed expectation. +**Tip 1:** If you run the test from an Emacs buffer, you can hit `<Enter>` on +the line number to jump right to the failed expectation. **Tip 2:** If your mock objects are never deleted, the final verification won't happen. Therefore it's a good idea to turn on the heap checker in your tests diff --git a/googlemock/include/gmock/gmock-actions.h b/googlemock/include/gmock/gmock-actions.h index 615651b3..0f30abde 100644 --- a/googlemock/include/gmock/gmock-actions.h +++ b/googlemock/include/gmock/gmock-actions.h @@ -138,6 +138,7 @@ #include <functional> #include <memory> #include <string> +#include <tuple> #include <type_traits> #include <utility> @@ -570,13 +571,9 @@ class PolymorphicAction { private: Impl impl_; - - GTEST_DISALLOW_ASSIGN_(MonomorphicImpl); }; Impl impl_; - - GTEST_DISALLOW_ASSIGN_(PolymorphicAction); }; // Creates an Action from its implementation and returns it. The @@ -717,13 +714,9 @@ class ReturnAction { private: bool performed_; const std::shared_ptr<R> wrapper_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const std::shared_ptr<R> value_; - - GTEST_DISALLOW_ASSIGN_(ReturnAction); }; // Implements the ReturnNull() action. @@ -784,13 +777,9 @@ class ReturnRefAction { private: T& ref_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; T& ref_; - - GTEST_DISALLOW_ASSIGN_(ReturnRefAction); }; // Implements the polymorphic ReturnRefOfCopy(x) action, which can be @@ -831,13 +820,9 @@ class ReturnRefOfCopyAction { private: T value_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const T value_; - - GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction); }; // Implements the polymorphic ReturnRoundRobin(v) action, which can be @@ -894,8 +879,6 @@ class AssignAction { private: T1* const ptr_; const T2 value_; - - GTEST_DISALLOW_ASSIGN_(AssignAction); }; #if !GTEST_OS_WINDOWS_MOBILE @@ -917,8 +900,6 @@ class SetErrnoAndReturnAction { private: const int errno_; const T result_; - - GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction); }; #endif // !GTEST_OS_WINDOWS_MOBILE @@ -1024,13 +1005,9 @@ class IgnoreResultAction { OriginalFunction; const Action<OriginalFunction> action_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const A action_; - - GTEST_DISALLOW_ASSIGN_(IgnoreResultAction); }; template <typename InnerAction, size_t... I> @@ -1311,6 +1288,31 @@ inline ::std::reference_wrapper<T> ByRef(T& l_value) { // NOLINT namespace internal { +template <typename T, typename... Params> +struct ReturnNewAction { + T* operator()() const { + return internal::Apply( + [](const Params&... unpacked_params) { + return new T(unpacked_params...); + }, + params); + } + std::tuple<Params...> params; +}; + +} // namespace internal + +// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new +// instance of type T, constructed on the heap with constructor arguments +// a1, a2, ..., and a_k. The caller assumes ownership of the returned value. +template <typename T, typename... Params> +internal::ReturnNewAction<T, typename std::decay<Params>::type...> ReturnNew( + Params&&... params) { + return {std::forward_as_tuple(std::forward<Params>(params)...)}; +} + +namespace internal { + // A macro from the ACTION* family (defined later in gmock-generated-actions.h) // defines an action that can be used in a mock function. Typically, // these actions only care about a subset of the arguments of the mock @@ -1467,13 +1469,7 @@ auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) { template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \ GMOCK_ACTION_FIELD_PARAMS_(params) \ - \ - private: \ - GTEST_DISALLOW_ASSIGN_(gmock_Impl); \ }; \ - \ - private: \ - GTEST_DISALLOW_ASSIGN_(full_name); \ }; \ template <GMOCK_ACTION_TYPENAME_PARAMS_(params)> \ inline full_name<GMOCK_ACTION_TYPE_PARAMS_(params)> name( \ @@ -1512,13 +1508,7 @@ auto InvokeArgumentAdl(AdlTag, F f, Args... args) -> decltype(f(args...)) { } \ template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_> \ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const; \ - \ - private: \ - GTEST_DISALLOW_ASSIGN_(gmock_Impl); \ }; \ - \ - private: \ - GTEST_DISALLOW_ASSIGN_(name##Action); \ }; \ inline name##Action name() { return name##Action(); } \ template <typename F> \ diff --git a/googlemock/include/gmock/gmock-generated-actions.h b/googlemock/include/gmock/gmock-generated-actions.h index c78debef..7030a98e 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h +++ b/googlemock/include/gmock/gmock-generated-actions.h @@ -435,16 +435,12 @@ template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>\ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;\ GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ };\ template <typename F> operator ::testing::Action<F>() const {\ return ::testing::Action<F>(\ new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\ }\ GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ };\ template <GMOCK_INTERNAL_DECL_##template_params\ GMOCK_INTERNAL_DECL_TYPE_##value_params>\ @@ -602,77 +598,6 @@ ACTION_TEMPLATE(InvokeArgument, p8, p9); } -// Various overloads for ReturnNew<T>(). -// -// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new -// instance of type T, constructed on the heap with constructor arguments -// a1, a2, ..., and a_k. The caller assumes ownership of the returned value. -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_0_VALUE_PARAMS()) { - return new T(); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_1_VALUE_PARAMS(p0)) { - return new T(p0); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_2_VALUE_PARAMS(p0, p1)) { - return new T(p0, p1); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_3_VALUE_PARAMS(p0, p1, p2)) { - return new T(p0, p1, p2); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_4_VALUE_PARAMS(p0, p1, p2, p3)) { - return new T(p0, p1, p2, p3); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) { - return new T(p0, p1, p2, p3, p4); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) { - return new T(p0, p1, p2, p3, p4, p5); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) { - return new T(p0, p1, p2, p3, p4, p5, p6); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8); -} - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) { - return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9); -} - #ifdef _MSC_VER # pragma warning(pop) #endif diff --git a/googlemock/include/gmock/gmock-generated-actions.h.pump b/googlemock/include/gmock/gmock-generated-actions.h.pump index be9d99fe..3430204f 100644 --- a/googlemock/include/gmock/gmock-generated-actions.h.pump +++ b/googlemock/include/gmock/gmock-generated-actions.h.pump @@ -253,16 +253,12 @@ $range k 0..n-1 template <GMOCK_ACTION_TEMPLATE_ARGS_NAMES_>\ return_type gmock_PerformImpl(GMOCK_ACTION_ARG_TYPES_AND_NAMES_) const;\ GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(gmock_Impl);\ };\ template <typename F> operator ::testing::Action<F>() const {\ return ::testing::Action<F>(\ new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\ }\ GMOCK_INTERNAL_DEFN_##value_params\ - private:\ - GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\ };\ template <GMOCK_INTERNAL_DECL_##template_params\ GMOCK_INTERNAL_DECL_TYPE_##value_params>\ @@ -344,24 +340,6 @@ ACTION_TEMPLATE(InvokeArgument, ]] -// Various overloads for ReturnNew<T>(). -// -// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new -// instance of type T, constructed on the heap with constructor arguments -// a1, a2, ..., and a_k. The caller assumes ownership of the returned value. -$range i 0..n -$for i [[ -$range j 0..i-1 -$var ps = [[$for j, [[p$j]]]] - -ACTION_TEMPLATE(ReturnNew, - HAS_1_TEMPLATE_PARAMS(typename, T), - AND_$i[[]]_VALUE_PARAMS($ps)) { - return new T($ps); -} - -]] - #ifdef _MSC_VER # pragma warning(pop) #endif diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index fe88a7c7..08fd6d14 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -444,8 +444,6 @@ class MatcherCastImpl<T, Matcher<U> > { private: const Matcher<U> source_matcher_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; }; @@ -861,13 +859,9 @@ class RefMatcher<T&> { private: const Super& object_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; T& object_; - - GTEST_DISALLOW_ASSIGN_(RefMatcher); }; // Polymorphic helper functions for narrow and wide string matchers. @@ -970,8 +964,6 @@ class StrEqualityMatcher { const StringType string_; const bool expect_eq_; const bool case_sensitive_; - - GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher); }; // Implements the polymorphic HasSubstr(substring) matcher, which @@ -1026,8 +1018,6 @@ class HasSubstrMatcher { private: const StringType substring_; - - GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher); }; // Implements the polymorphic StartsWith(substring) matcher, which @@ -1083,8 +1073,6 @@ class StartsWithMatcher { private: const StringType prefix_; - - GTEST_DISALLOW_ASSIGN_(StartsWithMatcher); }; // Implements the polymorphic EndsWith(substring) matcher, which @@ -1139,8 +1127,6 @@ class EndsWithMatcher { private: const StringType suffix_; - - GTEST_DISALLOW_ASSIGN_(EndsWithMatcher); }; // Implements a matcher that compares the two fields of a 2-tuple @@ -1234,8 +1220,6 @@ class NotMatcherImpl : public MatcherInterface<const T&> { private: const Matcher<T> matcher_; - - GTEST_DISALLOW_ASSIGN_(NotMatcherImpl); }; // Implements the Not(m) matcher, which matches a value that doesn't @@ -1254,8 +1238,6 @@ class NotMatcher { private: InnerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(NotMatcher); }; // Implements the AllOf(m1, m2) matcher for a particular argument type @@ -1317,8 +1299,6 @@ class AllOfMatcherImpl : public MatcherInterface<const T&> { private: const std::vector<Matcher<T> > matchers_; - - GTEST_DISALLOW_ASSIGN_(AllOfMatcherImpl); }; // VariadicMatcher is used for the variadic implementation of @@ -1333,6 +1313,9 @@ class VariadicMatcher { static_assert(sizeof...(Args) > 0, "Must have at least one matcher."); } + VariadicMatcher(const VariadicMatcher&) = default; + VariadicMatcher& operator=(const VariadicMatcher&) = delete; + // This template type conversion operator allows an // VariadicMatcher<Matcher1, Matcher2...> object to match any type that // all of the provided matchers (Matcher1, Matcher2, ...) can match. @@ -1357,8 +1340,6 @@ class VariadicMatcher { std::integral_constant<size_t, sizeof...(Args)>) const {} std::tuple<Args...> matchers_; - - GTEST_DISALLOW_ASSIGN_(VariadicMatcher); }; template <typename... Args> @@ -1423,8 +1404,6 @@ class AnyOfMatcherImpl : public MatcherInterface<const T&> { private: const std::vector<Matcher<T> > matchers_; - - GTEST_DISALLOW_ASSIGN_(AnyOfMatcherImpl); }; // AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...). @@ -1452,8 +1431,6 @@ class SomeOfArrayMatcher { private: const ::std::vector<T> matchers_; - - GTEST_DISALLOW_ASSIGN_(SomeOfArrayMatcher); }; template <typename T> @@ -1497,8 +1474,6 @@ class TrulyMatcher { private: Predicate predicate_; - - GTEST_DISALLOW_ASSIGN_(TrulyMatcher); }; // Used for implementing Matches(matcher), which turns a matcher into @@ -1535,8 +1510,6 @@ class MatcherAsPredicate { private: M matcher_; - - GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate); }; // For implementing ASSERT_THAT() and EXPECT_THAT(). The template @@ -1587,8 +1560,6 @@ class PredicateFormatterFromMatcher { private: const M matcher_; - - GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher); }; // A helper function for converting a matcher to a predicate-formatter @@ -1740,8 +1711,6 @@ class FloatingEqMatcher { const bool nan_eq_nan_; // max_abs_error will be used for value comparison when >= 0. const FloatType max_abs_error_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; // The following 3 type conversion operators allow FloatEq(expected) and @@ -1770,8 +1739,6 @@ class FloatingEqMatcher { const bool nan_eq_nan_; // max_abs_error will be used for value comparison when >= 0. const FloatType max_abs_error_; - - GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher); }; // A 2-tuple ("binary") wrapper around FloatingEqMatcher: @@ -1901,13 +1868,9 @@ class PointeeMatcher { private: const Matcher<const Pointee&> matcher_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const InnerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(PointeeMatcher); }; #if GTEST_HAS_RTTI @@ -1944,8 +1907,6 @@ class WhenDynamicCastToMatcherBase { static void GetCastTypeDescription(::std::ostream* os) { *os << "when dynamic_cast to " << GetToName() << ", "; } - - GTEST_DISALLOW_ASSIGN_(WhenDynamicCastToMatcherBase); }; // Primary template. @@ -2043,8 +2004,6 @@ class FieldMatcher { // Contains either "whose given field " if the name of the field is unknown // or "whose field `name_of_field` " if the name is known. const std::string whose_field_; - - GTEST_DISALLOW_ASSIGN_(FieldMatcher); }; // Implements the Property() matcher for matching a property @@ -2113,8 +2072,6 @@ class PropertyMatcher { // Contains either "whose given property " if the name of the property is // unknown or "whose property `name_of_property` " if the name is known. const std::string whose_property_; - - GTEST_DISALLOW_ASSIGN_(PropertyMatcher); }; // Type traits specifying various features of different functors for ResultOf. @@ -2204,14 +2161,10 @@ class ResultOfMatcher { // how many times the callable will be invoked. mutable CallableStorageType callable_; const Matcher<ResultType> matcher_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; // class Impl const CallableStorageType callable_; const InnerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(ResultOfMatcher); }; // Implements a matcher that checks the size of an STL-style container. @@ -2256,12 +2209,10 @@ class SizeIsMatcher { private: const Matcher<SizeType> size_matcher_; - GTEST_DISALLOW_ASSIGN_(Impl); }; private: const SizeMatcher size_matcher_; - GTEST_DISALLOW_ASSIGN_(SizeIsMatcher); }; // Implements a matcher that checks the begin()..end() distance of an STL-style @@ -2313,12 +2264,10 @@ class BeginEndDistanceIsMatcher { private: const Matcher<DistanceType> distance_matcher_; - GTEST_DISALLOW_ASSIGN_(Impl); }; private: const DistanceMatcher distance_matcher_; - GTEST_DISALLOW_ASSIGN_(BeginEndDistanceIsMatcher); }; // Implements an equality matcher for any STL-style container whose elements @@ -2411,8 +2360,6 @@ class ContainerEqMatcher { private: const StlContainer expected_; - - GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher); }; // A comparator functor that uses the < operator to compare two values. @@ -2494,8 +2441,6 @@ class WhenSortedByMatcher { private: const Comparator comparator_; const ContainerMatcher matcher_; - - GTEST_DISALLOW_ASSIGN_(WhenSortedByMatcher); }; // Implements Pointwise(tuple_matcher, rhs_container). tuple_matcher @@ -2611,15 +2556,11 @@ class PointwiseMatcher { private: const Matcher<InnerMatcherArg> mono_tuple_matcher_; const RhsStlContainer rhs_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; private: const TupleMatcher tuple_matcher_; const RhsStlContainer rhs_; - - GTEST_DISALLOW_ASSIGN_(PointwiseMatcher); }; // Holds the logic common to ContainsMatcherImpl and EachMatcherImpl. @@ -2662,8 +2603,6 @@ class QuantifierMatcherImpl : public MatcherInterface<Container> { protected: const Matcher<const Element&> inner_matcher_; - - GTEST_DISALLOW_ASSIGN_(QuantifierMatcherImpl); }; // Implements Contains(element_matcher) for the given argument type Container. @@ -2690,9 +2629,6 @@ class ContainsMatcherImpl : public QuantifierMatcherImpl<Container> { MatchResultListener* listener) const override { return this->MatchAndExplainImpl(false, container, listener); } - - private: - GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl); }; // Implements Each(element_matcher) for the given argument type Container. @@ -2719,9 +2655,6 @@ class EachMatcherImpl : public QuantifierMatcherImpl<Container> { MatchResultListener* listener) const override { return this->MatchAndExplainImpl(true, container, listener); } - - private: - GTEST_DISALLOW_ASSIGN_(EachMatcherImpl); }; // Implements polymorphic Contains(element_matcher). @@ -2738,8 +2671,6 @@ class ContainsMatcher { private: const M inner_matcher_; - - GTEST_DISALLOW_ASSIGN_(ContainsMatcher); }; // Implements polymorphic Each(element_matcher). @@ -2756,8 +2687,6 @@ class EachMatcher { private: const M inner_matcher_; - - GTEST_DISALLOW_ASSIGN_(EachMatcher); }; struct Rank1 {}; @@ -2828,8 +2757,6 @@ class KeyMatcherImpl : public MatcherInterface<PairType> { private: const Matcher<const KeyType&> inner_matcher_; - - GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl); }; // Implements polymorphic Key(matcher_for_key). @@ -2846,8 +2773,6 @@ class KeyMatcher { private: const M matcher_for_key_; - - GTEST_DISALLOW_ASSIGN_(KeyMatcher); }; // Implements Pair(first_matcher, second_matcher) for the given argument pair @@ -2933,8 +2858,6 @@ class PairMatcherImpl : public MatcherInterface<PairType> { const Matcher<const FirstType&> first_matcher_; const Matcher<const SecondType&> second_matcher_; - - GTEST_DISALLOW_ASSIGN_(PairMatcherImpl); }; // Implements polymorphic Pair(first_matcher, second_matcher). @@ -2953,8 +2876,6 @@ class PairMatcher { private: const FirstMatcher first_matcher_; const SecondMatcher second_matcher_; - - GTEST_DISALLOW_ASSIGN_(PairMatcher); }; // Implements ElementsAre() and ElementsAreArray(). @@ -3100,8 +3021,6 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> { size_t count() const { return matchers_.size(); } ::std::vector<Matcher<const Element&> > matchers_; - - GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl); }; // Connectivity matrix of (elements X matchers), in element-major order. @@ -3204,8 +3123,6 @@ class GTEST_API_ UnorderedElementsAreMatcherImplBase { private: UnorderedMatcherRequire::Flags match_flags_; MatcherDescriberVec matcher_describers_; - - GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImplBase); }; // Implements UnorderedElementsAre, UnorderedElementsAreArray, IsSubsetOf, and @@ -3301,8 +3218,6 @@ class UnorderedElementsAreMatcherImpl } ::std::vector<Matcher<const Element&> > matchers_; - - GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImpl); }; // Functor for use in TransformTuple. @@ -3340,7 +3255,6 @@ class UnorderedElementsAreMatcher { private: const MatcherTuple matchers_; - GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcher); }; // Implements ElementsAre. @@ -3370,7 +3284,6 @@ class ElementsAreMatcher { private: const MatcherTuple matchers_; - GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher); }; // Implements UnorderedElementsAreArray(), IsSubsetOf(), and IsSupersetOf(). @@ -3392,8 +3305,6 @@ class UnorderedElementsAreArrayMatcher { private: UnorderedMatcherRequire::Flags match_flags_; ::std::vector<T> matchers_; - - GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreArrayMatcher); }; // Implements ElementsAreArray(). @@ -3415,8 +3326,6 @@ class ElementsAreArrayMatcher { private: const ::std::vector<T> matchers_; - - GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher); }; // Given a 2-tuple matcher tm of type Tuple2Matcher and a value second @@ -3478,8 +3387,6 @@ class BoundSecondMatcher { private: const Matcher<const ArgTuple&> mono_tuple2_matcher_; const Second second_value_; - - GTEST_DISALLOW_ASSIGN_(Impl); }; const Tuple2Matcher tuple2_matcher_; @@ -3552,12 +3459,10 @@ class OptionalMatcher { private: const Matcher<ValueType> value_matcher_; - GTEST_DISALLOW_ASSIGN_(Impl); }; private: const ValueMatcher value_matcher_; - GTEST_DISALLOW_ASSIGN_(OptionalMatcher); }; namespace variant_matcher { @@ -4784,7 +4689,7 @@ inline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; } // and is printable using 'PrintToString'. It is compatible with // std::optional/std::experimental::optional. // Note that to compare an optional type variable against nullopt you should -// use Eq(nullopt) and not Optional(Eq(nullopt)). The latter implies that the +// use Eq(nullopt) and not Eq(Optional(nullopt)). The latter implies that the // optional value contains an optional itself. template <typename ValueMatcher> inline internal::OptionalMatcher<ValueMatcher> Optional( diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index 4b5fc661..ac215501 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -499,7 +499,10 @@ class GTEST_API_ Expectation { public: // Constructs a null object that doesn't reference any expectation. Expectation(); - + Expectation(Expectation&&) = default; + Expectation(const Expectation&) = default; + Expectation& operator=(Expectation&&) = default; + Expectation& operator=(const Expectation&) = default; ~Expectation(); // This single-argument ctor must not be explicit, in order to support the @@ -879,8 +882,6 @@ class GTEST_API_ ExpectationBase { Clause last_clause_; mutable bool action_count_checked_; // Under mutex_. mutable Mutex mutex_; // Protects action_count_checked_. - - GTEST_DISALLOW_ASSIGN_(ExpectationBase); }; // class ExpectationBase // Impements an expectation for the given function type. @@ -1295,8 +1296,6 @@ class MockSpec { internal::FunctionMocker<F>* const function_mocker_; // The argument matchers specified in the spec. ArgumentMatcherTuple matchers_; - - GTEST_DISALLOW_ASSIGN_(MockSpec); }; // class MockSpec // Wrapper type for generically holding an ordinary value or lvalue reference. diff --git a/googlemock/include/gmock/internal/gmock-internal-utils.h b/googlemock/include/gmock/internal/gmock-internal-utils.h index 66cf857b..5580dcb3 100644 --- a/googlemock/include/gmock/internal/gmock-internal-utils.h +++ b/googlemock/include/gmock/internal/gmock-internal-utils.h @@ -422,11 +422,13 @@ auto ApplyImpl(F&& f, Tuple&& args, IndexSequence<Idx...>) -> decltype( // Apply the function to a tuple of arguments. template <typename F, typename Tuple> -auto Apply(F&& f, Tuple&& args) - -> decltype(ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), - MakeIndexSequence<std::tuple_size<Tuple>::value>())) { +auto Apply(F&& f, Tuple&& args) -> decltype( + ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), + MakeIndexSequence<std::tuple_size< + typename std::remove_reference<Tuple>::type>::value>())) { return ApplyImpl(std::forward<F>(f), std::forward<Tuple>(args), - MakeIndexSequence<std::tuple_size<Tuple>::value>()); + MakeIndexSequence<std::tuple_size< + typename std::remove_reference<Tuple>::type>::value>()); } // Template struct Function<F>, where F must be a function type, contains diff --git a/googlemock/src/gmock-matchers.cc b/googlemock/src/gmock-matchers.cc index 4f73e0a6..dded437a 100644 --- a/googlemock/src/gmock-matchers.cc +++ b/googlemock/src/gmock-matchers.cc @@ -218,8 +218,6 @@ class MaxBipartiteMatchState { // right_[left_[i]] = i. ::std::vector<size_t> left_; ::std::vector<size_t> right_; - - GTEST_DISALLOW_ASSIGN_(MaxBipartiteMatchState); }; const size_t MaxBipartiteMatchState::kUnused; diff --git a/googlemock/test/gmock-actions_test.cc b/googlemock/test/gmock-actions_test.cc index d1229ac9..cac8f94f 100644 --- a/googlemock/test/gmock-actions_test.cc +++ b/googlemock/test/gmock-actions_test.cc @@ -54,35 +54,34 @@ namespace { -// This list should be kept sorted. -using testing::_; -using testing::Action; -using testing::ActionInterface; -using testing::Assign; -using testing::ByMove; -using testing::ByRef; -using testing::DefaultValue; -using testing::DoAll; -using testing::DoDefault; -using testing::IgnoreResult; -using testing::Invoke; -using testing::InvokeWithoutArgs; -using testing::MakePolymorphicAction; -using testing::Ne; -using testing::PolymorphicAction; -using testing::Return; -using testing::ReturnNull; -using testing::ReturnRef; -using testing::ReturnRefOfCopy; -using testing::ReturnRoundRobin; -using testing::SetArgPointee; -using testing::SetArgumentPointee; -using testing::Unused; -using testing::WithArgs; -using testing::internal::BuiltInDefaultValue; +using ::testing::_; +using ::testing::Action; +using ::testing::ActionInterface; +using ::testing::Assign; +using ::testing::ByMove; +using ::testing::ByRef; +using ::testing::DefaultValue; +using ::testing::DoAll; +using ::testing::DoDefault; +using ::testing::IgnoreResult; +using ::testing::Invoke; +using ::testing::InvokeWithoutArgs; +using ::testing::MakePolymorphicAction; +using ::testing::PolymorphicAction; +using ::testing::Return; +using ::testing::ReturnNew; +using ::testing::ReturnNull; +using ::testing::ReturnRef; +using ::testing::ReturnRefOfCopy; +using ::testing::ReturnRoundRobin; +using ::testing::SetArgPointee; +using ::testing::SetArgumentPointee; +using ::testing::Unused; +using ::testing::WithArgs; +using ::testing::internal::BuiltInDefaultValue; #if !GTEST_OS_WINDOWS_MOBILE -using testing::SetErrnoAndReturn; +using ::testing::SetErrnoAndReturn; #endif // Tests that BuiltInDefaultValue<T*>::Get() returns NULL. @@ -575,8 +574,6 @@ class FromType { private: bool* const converted_; - - GTEST_DISALLOW_ASSIGN_(FromType); }; class ToType { @@ -1292,6 +1289,52 @@ TEST(ByRefTest, PrintsCorrectly) { EXPECT_EQ(expected.str(), actual.str()); } +struct UnaryConstructorClass { + explicit UnaryConstructorClass(int v) : value(v) {} + int value; +}; + +// Tests using ReturnNew() with a unary constructor. +TEST(ReturnNewTest, Unary) { + Action<UnaryConstructorClass*()> a = ReturnNew<UnaryConstructorClass>(4000); + UnaryConstructorClass* c = a.Perform(std::make_tuple()); + EXPECT_EQ(4000, c->value); + delete c; +} + +TEST(ReturnNewTest, UnaryWorksWhenMockMethodHasArgs) { + Action<UnaryConstructorClass*(bool, int)> a = + ReturnNew<UnaryConstructorClass>(4000); + UnaryConstructorClass* c = a.Perform(std::make_tuple(false, 5)); + EXPECT_EQ(4000, c->value); + delete c; +} + +TEST(ReturnNewTest, UnaryWorksWhenMockMethodReturnsPointerToConst) { + Action<const UnaryConstructorClass*()> a = + ReturnNew<UnaryConstructorClass>(4000); + const UnaryConstructorClass* c = a.Perform(std::make_tuple()); + EXPECT_EQ(4000, c->value); + delete c; +} + +class TenArgConstructorClass { + public: + TenArgConstructorClass(int a1, int a2, int a3, int a4, int a5, int a6, int a7, + int a8, int a9, int a10) + : value_(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10) {} + int value_; +}; + +// Tests using ReturnNew() with a 10-argument constructor. +TEST(ReturnNewTest, ConstructorThatTakes10Arguments) { + Action<TenArgConstructorClass*()> a = ReturnNew<TenArgConstructorClass>( + 1000000000, 200000000, 30000000, 4000000, 500000, 60000, 7000, 800, 90, + 0); + TenArgConstructorClass* c = a.Perform(std::make_tuple()); + EXPECT_EQ(1234567890, c->value_); + delete c; +} std::unique_ptr<int> UniquePtrSource() { return std::unique_ptr<int>(new int(19)); diff --git a/googlemock/test/gmock-generated-actions_test.cc b/googlemock/test/gmock-generated-actions_test.cc index 4c649a7e..ef39dff7 100644 --- a/googlemock/test/gmock-generated-actions_test.cc +++ b/googlemock/test/gmock-generated-actions_test.cc @@ -53,7 +53,6 @@ using testing::ByRef; using testing::DoAll; using testing::Invoke; using testing::Return; -using testing::ReturnNew; using testing::SetArgPointee; using testing::StaticAssertTypeEq; using testing::Unused; @@ -844,49 +843,6 @@ TEST(ActionPnMacroTest, CanExplicitlyInstantiateWithReferenceTypes) { EXPECT_EQ(55, a.Perform(empty)); } -class NullaryConstructorClass { - public: - NullaryConstructorClass() : value_(123) {} - int value_; -}; - -// Tests using ReturnNew() with a nullary constructor. -TEST(ReturnNewTest, NoArgs) { - Action<NullaryConstructorClass*()> a = ReturnNew<NullaryConstructorClass>(); - NullaryConstructorClass* c = a.Perform(std::make_tuple()); - EXPECT_EQ(123, c->value_); - delete c; -} - -class UnaryConstructorClass { - public: - explicit UnaryConstructorClass(int value) : value_(value) {} - int value_; -}; - -// Tests using ReturnNew() with a unary constructor. -TEST(ReturnNewTest, Unary) { - Action<UnaryConstructorClass*()> a = ReturnNew<UnaryConstructorClass>(4000); - UnaryConstructorClass* c = a.Perform(std::make_tuple()); - EXPECT_EQ(4000, c->value_); - delete c; -} - -TEST(ReturnNewTest, UnaryWorksWhenMockMethodHasArgs) { - Action<UnaryConstructorClass*(bool, int)> a = - ReturnNew<UnaryConstructorClass>(4000); - UnaryConstructorClass* c = a.Perform(std::make_tuple(false, 5)); - EXPECT_EQ(4000, c->value_); - delete c; -} - -TEST(ReturnNewTest, UnaryWorksWhenMockMethodReturnsPointerToConst) { - Action<const UnaryConstructorClass*()> a = - ReturnNew<UnaryConstructorClass>(4000); - const UnaryConstructorClass* c = a.Perform(std::make_tuple()); - EXPECT_EQ(4000, c->value_); - delete c; -} class TenArgConstructorClass { public: @@ -897,17 +853,6 @@ class TenArgConstructorClass { int value_; }; -// Tests using ReturnNew() with a 10-argument constructor. -TEST(ReturnNewTest, ConstructorThatTakes10Arguments) { - Action<TenArgConstructorClass*()> a = - ReturnNew<TenArgConstructorClass>(1000000000, 200000000, 30000000, - 4000000, 500000, 60000, - 7000, 800, 90, 0); - TenArgConstructorClass* c = a.Perform(std::make_tuple()); - EXPECT_EQ(1234567890, c->value_); - delete c; -} - // Tests that ACTION_TEMPLATE works when there is no value parameter. ACTION_TEMPLATE(CreateNew, HAS_1_TEMPLATE_PARAMS(typename, T), diff --git a/googlemock/test/gmock-matchers_test.cc b/googlemock/test/gmock-matchers_test.cc index 186d8aae..5db0a7ae 100644 --- a/googlemock/test/gmock-matchers_test.cc +++ b/googlemock/test/gmock-matchers_test.cc @@ -3746,17 +3746,11 @@ struct AStruct { const double y; // A const field. Uncopyable z; // An uncopyable field. const char* p; // A pointer field. - - private: - GTEST_DISALLOW_ASSIGN_(AStruct); }; // A derived struct for testing Field(). struct DerivedStruct : public AStruct { char ch; - - private: - GTEST_DISALLOW_ASSIGN_(DerivedStruct); }; // Tests that Field(&Foo::field, ...) works when field is non-const. diff --git a/googletest/docs/advanced.md b/googletest/docs/advanced.md index d65f1eff..3c3c6fe9 100644 --- a/googletest/docs/advanced.md +++ b/googletest/docs/advanced.md @@ -401,7 +401,7 @@ alone with them. For a list of matchers gMock provides, read your [own matchers](../../googlemock/docs/cook_book.md#NewMatchers) too. gMock is bundled with googletest, so you don't need to add any build dependency -in order to take advantage of this. Just include `"testing/base/public/gmock.h"` +in order to take advantage of this. Just include `"gmock/gmock.h"` and you're ready to go. ### More String Assertions @@ -863,7 +863,7 @@ restored afterwards, so you need not do that yourself. For example: ```c++ int main(int argc, char** argv) { - InitGoogle(argv[0], &argc, &argv, true); + ::testing::InitGoogleTest(&argc, argv); ::testing::FLAGS_gtest_death_test_style = "fast"; return RUN_ALL_TESTS(); } diff --git a/googletest/include/gtest/gtest-death-test.h b/googletest/include/gtest/gtest-death-test.h index dc878ffb..2bd41cf3 100644 --- a/googletest/include/gtest/gtest-death-test.h +++ b/googletest/include/gtest/gtest-death-test.h @@ -190,11 +190,10 @@ GTEST_API_ bool InDeathTestChild(); class GTEST_API_ ExitedWithCode { public: explicit ExitedWithCode(int exit_code); + ExitedWithCode(const ExitedWithCode&) = default; + void operator=(const ExitedWithCode& other) = delete; bool operator()(int exit_status) const; private: - // No implementation - assignment is unsupported. - void operator=(const ExitedWithCode& other); - const int exit_code_; }; diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index c36029ee..fabc8042 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -94,12 +94,6 @@ namespace proto2 { class MessageLite; } -namespace google { -namespace protobuf { -class MessageLite; -} -} - namespace testing { // Forward declarations. @@ -887,15 +881,10 @@ class GTEST_API_ Random { typename std::remove_const<typename std::remove_reference<T>::type>::type // IsAProtocolMessage<T>::value is a compile-time bool constant that's -// true if and only if T is type proto2::MessageLite or -// google::protobuf::MessageLite or a subclass of one of them. +// true if and only if T is type proto2::MessageLite or a subclass of it. template <typename T> struct IsAProtocolMessage - : public std::integral_constant< - bool, - std::is_convertible<const T*, const ::proto2::MessageLite*>::value || - std::is_convertible< - const T*, const ::google::protobuf::MessageLite*>::value> {}; + : public std::is_convertible<const T*, const ::proto2::MessageLite*> {}; // When the compiler sees expression IsContainerTest<C>(0), if C is an // STL-style container class, the first overload of IsContainerTest @@ -1131,8 +1120,6 @@ class NativeArray { const Element* array_; size_t size_; void (NativeArray::*clone_)(const Element*, size_t); - - GTEST_DISALLOW_ASSIGN_(NativeArray); }; // Backport of std::index_sequence. diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h index 21fcf822..893c7f30 100644 --- a/googletest/include/gtest/internal/gtest-port.h +++ b/googletest/include/gtest/internal/gtest-port.h @@ -681,8 +681,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // A macro to disallow copy constructor and operator= // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \ - type(type const &) = delete; \ - GTEST_DISALLOW_ASSIGN_(type) + type(type const&) = delete; \ + type& operator=(type const&) = delete // A macro to disallow move operator= // This should be used in the private: declarations for a class. @@ -692,8 +692,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; // A macro to disallow move constructor and operator= // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_MOVE_AND_ASSIGN_(type) \ - type(type &&) noexcept = delete; \ - GTEST_DISALLOW_MOVE_ASSIGN_(type) + type(type&&) noexcept = delete; \ + type& operator=(type&&) noexcept = delete // Tell the compiler to warn about unused return values for functions declared // with this macro. The macro should be used on function declarations @@ -920,8 +920,6 @@ class GTEST_API_ RE { const char* full_pattern_; // For FullMatch(); # endif - - GTEST_DISALLOW_ASSIGN_(RE); }; #endif // GTEST_USES_PCRE diff --git a/googletest/test/googletest-param-test-test.cc b/googletest/test/googletest-param-test-test.cc index 6ba89654..c852220e 100644 --- a/googletest/test/googletest-param-test-test.cc +++ b/googletest/test/googletest-param-test-test.cc @@ -490,16 +490,17 @@ TEST(CombineTest, CombineWithMaxNumberOfParameters) { class NonDefaultConstructAssignString { public: NonDefaultConstructAssignString(const std::string& s) : str_(s) {} + NonDefaultConstructAssignString() = delete; + NonDefaultConstructAssignString(const NonDefaultConstructAssignString&) = + default; + NonDefaultConstructAssignString& operator=( + const NonDefaultConstructAssignString&) = delete; + ~NonDefaultConstructAssignString() = default; const std::string& str() const { return str_; } private: std::string str_; - - // Not default constructible - NonDefaultConstructAssignString(); - // Not assignable - void operator=(const NonDefaultConstructAssignString&); }; TEST(CombineTest, NonDefaultConstructAssign) { diff --git a/googletest/test/googletest-port-test.cc b/googletest/test/googletest-port-test.cc index 60d637c3..44b99ce5 100644 --- a/googletest/test/googletest-port-test.cc +++ b/googletest/test/googletest-port-test.cc @@ -90,10 +90,10 @@ TEST(IsXDigitTest, ReturnsFalseForWideNonAscii) { class Base { public: - // Copy constructor and assignment operator do exactly what we need, so we - // use them. Base() : member_(0) {} explicit Base(int n) : member_(n) {} + Base(const Base&) = default; + Base& operator=(const Base&) = default; virtual ~Base() {} int member() { return member_; } @@ -1180,8 +1180,6 @@ class DestructorTracker { return DestructorCall::List().size() - 1; } const size_t index_; - - GTEST_DISALLOW_ASSIGN_(DestructorTracker); }; typedef ThreadLocal<DestructorTracker>* ThreadParam; diff --git a/googletest/test/gtest_unittest.cc b/googletest/test/gtest_unittest.cc index 631180e3..005a2d40 100644 --- a/googletest/test/gtest_unittest.cc +++ b/googletest/test/gtest_unittest.cc @@ -7115,10 +7115,6 @@ TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) { EXPECT_TRUE(IsAProtocolMessage<::proto2::MessageLite>::value); } -TEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAnOpenSourceProtocolMessage) { - EXPECT_TRUE(IsAProtocolMessage<::google::protobuf::MessageLite>::value); -} - // Tests that IsAProtocolMessage<T>::value is false when T is neither // ::proto2::Message nor a sub-class of it. TEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) { |