summaryrefslogtreecommitdiffstats
path: root/googlemock/include/gmock/gmock-matchers.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-12-17 23:59:00 (GMT)
committerMark Barolak <mbar@google.com>2018-12-20 19:09:31 (GMT)
commite26a3fa13ca21500773293946e92ec72f8d8c9ea (patch)
treec69e48ca1dcbe3623903040d25b4647d70f7d3bf /googlemock/include/gmock/gmock-matchers.h
parent9ab640ce5e5120021c5972d7e60f258bfca64d71 (diff)
downloadgoogletest-e26a3fa13ca21500773293946e92ec72f8d8c9ea.zip
googletest-e26a3fa13ca21500773293946e92ec72f8d8c9ea.tar.gz
googletest-e26a3fa13ca21500773293946e92ec72f8d8c9ea.tar.bz2
Googletest export
Unifdef c++11-related macros from googletest now that it requires C++11. PiperOrigin-RevId: 225905601
Diffstat (limited to 'googlemock/include/gmock/gmock-matchers.h')
-rw-r--r--googlemock/include/gmock/gmock-matchers.h63
1 files changed, 1 insertions, 62 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h
index be881e1..f9ad348 100644
--- a/googlemock/include/gmock/gmock-matchers.h
+++ b/googlemock/include/gmock/gmock-matchers.h
@@ -44,6 +44,7 @@
#include <math.h>
#include <algorithm>
+#include <initializer_list>
#include <iterator>
#include <limits>
#include <memory>
@@ -57,10 +58,6 @@
#include "gmock/internal/gmock-port.h"
#include "gtest/gtest.h"
-#if GTEST_HAS_STD_INITIALIZER_LIST_
-# include <initializer_list> // NOLINT -- must be after gtest.h
-#endif
-
GTEST_DISABLE_MSC_WARNINGS_PUSH_(
4251 5046 /* class A needs to have dll-interface to be used by clients of
class B */
@@ -194,7 +191,6 @@ class MatcherCastImpl<T, Matcher<U> > {
// We delegate the matching logic to the source matcher.
bool MatchAndExplain(T x, MatchResultListener* listener) const override {
-#if GTEST_LANG_CXX11
using FromType = typename std::remove_cv<typename std::remove_pointer<
typename std::remove_reference<T>::type>::type>::type;
using ToType = typename std::remove_cv<typename std::remove_pointer<
@@ -208,7 +204,6 @@ class MatcherCastImpl<T, Matcher<U> > {
std::is_same<FromType, ToType>::value ||
!std::is_base_of<FromType, ToType>::value,
"Can't implicitly convert from <base> to <derived>");
-#endif // GTEST_LANG_CXX11
return source_matcher_.MatchAndExplain(static_cast<U>(x), listener);
}
@@ -524,11 +519,7 @@ class IsNullMatcher {
template <typename Pointer>
bool MatchAndExplain(const Pointer& p,
MatchResultListener* /* listener */) const {
-#if GTEST_LANG_CXX11
return p == nullptr;
-#else // GTEST_LANG_CXX11
- return GetRawPointer(p) == NULL;
-#endif // GTEST_LANG_CXX11
}
void DescribeTo(::std::ostream* os) const { *os << "is NULL"; }
@@ -544,11 +535,7 @@ class NotNullMatcher {
template <typename Pointer>
bool MatchAndExplain(const Pointer& p,
MatchResultListener* /* listener */) const {
-#if GTEST_LANG_CXX11
return p != nullptr;
-#else // GTEST_LANG_CXX11
- return GetRawPointer(p) != NULL;
-#endif // GTEST_LANG_CXX11
}
void DescribeTo(::std::ostream* os) const { *os << "isn't NULL"; }
@@ -1845,14 +1832,8 @@ struct CallableTraits {
static void CheckIsValid(Functor /* functor */) {}
-#if GTEST_LANG_CXX11
template <typename T>
static auto Invoke(Functor f, T arg) -> decltype(f(arg)) { return f(arg); }
-#else
- typedef typename Functor::result_type ResultType;
- template <typename T>
- static ResultType Invoke(Functor f, T arg) { return f(arg); }
-#endif
};
// Specialization for function pointers.
@@ -1891,12 +1872,8 @@ class ResultOfMatcher {
template <typename T>
class Impl : public MatcherInterface<T> {
-#if GTEST_LANG_CXX11
using ResultType = decltype(CallableTraits<Callable>::template Invoke<T>(
std::declval<CallableStorageType>(), std::declval<T>()));
-#else
- typedef typename CallableTraits<Callable>::ResultType ResultType;
-#endif
public:
template <typename M>
@@ -2027,13 +2004,9 @@ class BeginEndDistanceIsMatcher {
bool MatchAndExplain(Container container,
MatchResultListener* listener) const override {
-#if GTEST_HAS_STD_BEGIN_AND_END_
using std::begin;
using std::end;
DistanceType distance = std::distance(begin(container), end(container));
-#else
- DistanceType distance = std::distance(container.begin(), container.end());
-#endif
StringMatchResultListener distance_listener;
const bool result =
distance_matcher_.MatchAndExplain(distance, &distance_listener);
@@ -2497,7 +2470,6 @@ struct Rank1 {};
struct Rank0 : Rank1 {};
namespace pair_getters {
-#if GTEST_LANG_CXX11
using std::get;
template <typename T>
auto First(T& x, Rank1) -> decltype(get<0>(x)) { // NOLINT
@@ -2516,25 +2488,6 @@ template <typename T>
auto Second(T& x, Rank0) -> decltype((x.second)) { // NOLINT
return x.second;
}
-#else
-template <typename T>
-typename T::first_type& First(T& x, Rank0) { // NOLINT
- return x.first;
-}
-template <typename T>
-const typename T::first_type& First(const T& x, Rank0) {
- return x.first;
-}
-
-template <typename T>
-typename T::second_type& Second(T& x, Rank0) { // NOLINT
- return x.second;
-}
-template <typename T>
-const typename T::second_type& Second(const T& x, Rank0) {
- return x.second;
-}
-#endif // GTEST_LANG_CXX11
} // namespace pair_getters
// Implements Key(inner_matcher) for the given argument pair type.
@@ -3547,13 +3500,11 @@ ElementsAreArray(const Container& container) {
return ElementsAreArray(container.begin(), container.end());
}
-#if GTEST_HAS_STD_INITIALIZER_LIST_
template <typename T>
inline internal::ElementsAreArrayMatcher<T>
ElementsAreArray(::std::initializer_list<T> xs) {
return ElementsAreArray(xs.begin(), xs.end());
}
-#endif
// UnorderedElementsAreArray(iterator_first, iterator_last)
// UnorderedElementsAreArray(pointer, count)
@@ -3596,13 +3547,11 @@ UnorderedElementsAreArray(const Container& container) {
return UnorderedElementsAreArray(container.begin(), container.end());
}
-#if GTEST_HAS_STD_INITIALIZER_LIST_
template <typename T>
inline internal::UnorderedElementsAreArrayMatcher<T>
UnorderedElementsAreArray(::std::initializer_list<T> xs) {
return UnorderedElementsAreArray(xs.begin(), xs.end());
}
-#endif
// _ is a matcher that matches anything of any type.
//
@@ -3790,7 +3739,6 @@ Property(const std::string& property_name,
property_name, property, MatcherCast<const PropertyType&>(matcher)));
}
-#if GTEST_LANG_CXX11
// The same as above but for reference-qualified member functions.
template <typename Class, typename PropertyType, typename PropertyMatcher>
inline PolymorphicMatcher<internal::PropertyMatcher<
@@ -3815,7 +3763,6 @@ Property(const std::string& property_name,
PropertyType (Class::*)() const&>(
property_name, property, MatcherCast<const PropertyType&>(matcher)));
}
-#endif
// Creates a matcher that matches an object iff the result of applying
// a callable to x matches 'matcher'.
@@ -4107,7 +4054,6 @@ Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {
tuple_matcher, rhs);
}
-#if GTEST_HAS_STD_INITIALIZER_LIST_
// Supports the Pointwise(m, {a, b, c}) syntax.
template <typename TupleMatcher, typename T>
@@ -4116,7 +4062,6 @@ inline internal::PointwiseMatcher<TupleMatcher, std::vector<T> > Pointwise(
return Pointwise(tuple_matcher, std::vector<T>(rhs));
}
-#endif // GTEST_HAS_STD_INITIALIZER_LIST_
// UnorderedPointwise(pair_matcher, rhs) matches an STL-style
// container or a native array that contains the same number of
@@ -4161,7 +4106,6 @@ UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,
return UnorderedElementsAreArray(matchers);
}
-#if GTEST_HAS_STD_INITIALIZER_LIST_
// Supports the UnorderedPointwise(m, {a, b, c}) syntax.
template <typename Tuple2Matcher, typename T>
@@ -4172,7 +4116,6 @@ UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,
return UnorderedPointwise(tuple2_matcher, std::vector<T>(rhs));
}
-#endif // GTEST_HAS_STD_INITIALIZER_LIST_
// Matches an STL-style container or a native array that contains at
// least one element matching the given value or matcher.
@@ -4252,13 +4195,11 @@ IsSupersetOf(const Container& container) {
return IsSupersetOf(container.begin(), container.end());
}
-#if GTEST_HAS_STD_INITIALIZER_LIST_
template <typename T>
inline internal::UnorderedElementsAreArrayMatcher<T> IsSupersetOf(
::std::initializer_list<T> xs) {
return IsSupersetOf(xs.begin(), xs.end());
}
-#endif
// IsSubsetOf(iterator_first, iterator_last)
// IsSubsetOf(pointer, count)
@@ -4311,13 +4252,11 @@ IsSubsetOf(const Container& container) {
return IsSubsetOf(container.begin(), container.end());
}
-#if GTEST_HAS_STD_INITIALIZER_LIST_
template <typename T>
inline internal::UnorderedElementsAreArrayMatcher<T> IsSubsetOf(
::std::initializer_list<T> xs) {
return IsSubsetOf(xs.begin(), xs.end());
}
-#endif
// Matches an STL-style container or a native array that contains only
// elements matching the given value or matcher.