|
@@ -257,6 +257,8 @@
|
|
|
|
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <cmath>
|
|
|
|
+#include <exception>
|
|
|
|
+#include <functional>
|
|
#include <initializer_list>
|
|
#include <initializer_list>
|
|
#include <ios>
|
|
#include <ios>
|
|
#include <iterator>
|
|
#include <iterator>
|
|
@@ -562,7 +564,7 @@ namespace internal {
|
|
// If the explanation is not empty, prints it to the ostream.
|
|
// If the explanation is not empty, prints it to the ostream.
|
|
inline void PrintIfNotEmpty(const std::string& explanation,
|
|
inline void PrintIfNotEmpty(const std::string& explanation,
|
|
::std::ostream* os) {
|
|
::std::ostream* os) {
|
|
- if (explanation != "" && os != nullptr) {
|
|
|
|
|
|
+ if (!explanation.empty() && os != nullptr) {
|
|
*os << ", " << explanation;
|
|
*os << ", " << explanation;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1199,27 +1201,27 @@ class PairMatchBase {
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
|
|
-class Eq2Matcher : public PairMatchBase<Eq2Matcher, AnyEq> {
|
|
|
|
|
|
+class Eq2Matcher : public PairMatchBase<Eq2Matcher, std::equal_to<>> {
|
|
public:
|
|
public:
|
|
static const char* Desc() { return "an equal pair"; }
|
|
static const char* Desc() { return "an equal pair"; }
|
|
};
|
|
};
|
|
-class Ne2Matcher : public PairMatchBase<Ne2Matcher, AnyNe> {
|
|
|
|
|
|
+class Ne2Matcher : public PairMatchBase<Ne2Matcher, std::not_equal_to<>> {
|
|
public:
|
|
public:
|
|
static const char* Desc() { return "an unequal pair"; }
|
|
static const char* Desc() { return "an unequal pair"; }
|
|
};
|
|
};
|
|
-class Lt2Matcher : public PairMatchBase<Lt2Matcher, AnyLt> {
|
|
|
|
|
|
+class Lt2Matcher : public PairMatchBase<Lt2Matcher, std::less<>> {
|
|
public:
|
|
public:
|
|
static const char* Desc() { return "a pair where the first < the second"; }
|
|
static const char* Desc() { return "a pair where the first < the second"; }
|
|
};
|
|
};
|
|
-class Gt2Matcher : public PairMatchBase<Gt2Matcher, AnyGt> {
|
|
|
|
|
|
+class Gt2Matcher : public PairMatchBase<Gt2Matcher, std::greater<>> {
|
|
public:
|
|
public:
|
|
static const char* Desc() { return "a pair where the first > the second"; }
|
|
static const char* Desc() { return "a pair where the first > the second"; }
|
|
};
|
|
};
|
|
-class Le2Matcher : public PairMatchBase<Le2Matcher, AnyLe> {
|
|
|
|
|
|
+class Le2Matcher : public PairMatchBase<Le2Matcher, std::less_equal<>> {
|
|
public:
|
|
public:
|
|
static const char* Desc() { return "a pair where the first <= the second"; }
|
|
static const char* Desc() { return "a pair where the first <= the second"; }
|
|
};
|
|
};
|
|
-class Ge2Matcher : public PairMatchBase<Ge2Matcher, AnyGe> {
|
|
|
|
|
|
+class Ge2Matcher : public PairMatchBase<Ge2Matcher, std::greater_equal<>> {
|
|
public:
|
|
public:
|
|
static const char* Desc() { return "a pair where the first >= the second"; }
|
|
static const char* Desc() { return "a pair where the first >= the second"; }
|
|
};
|
|
};
|
|
@@ -1473,6 +1475,7 @@ class SomeOfArrayMatcher {
|
|
operator Matcher<U>() const { // NOLINT
|
|
operator Matcher<U>() const { // NOLINT
|
|
using RawU = typename std::decay<U>::type;
|
|
using RawU = typename std::decay<U>::type;
|
|
std::vector<Matcher<RawU>> matchers;
|
|
std::vector<Matcher<RawU>> matchers;
|
|
|
|
+ matchers.reserve(matchers_.size());
|
|
for (const auto& matcher : matchers_) {
|
|
for (const auto& matcher : matchers_) {
|
|
matchers.push_back(MatcherCast<RawU>(matcher));
|
|
matchers.push_back(MatcherCast<RawU>(matcher));
|
|
}
|
|
}
|
|
@@ -2964,7 +2967,7 @@ class KeyMatcherImpl : public MatcherInterface<PairType> {
|
|
const bool match = inner_matcher_.MatchAndExplain(
|
|
const bool match = inner_matcher_.MatchAndExplain(
|
|
pair_getters::First(key_value, Rank0()), &inner_listener);
|
|
pair_getters::First(key_value, Rank0()), &inner_listener);
|
|
const std::string explanation = inner_listener.str();
|
|
const std::string explanation = inner_listener.str();
|
|
- if (explanation != "") {
|
|
|
|
|
|
+ if (!explanation.empty()) {
|
|
*listener << "whose first field is a value " << explanation;
|
|
*listener << "whose first field is a value " << explanation;
|
|
}
|
|
}
|
|
return match;
|
|
return match;
|
|
@@ -3111,12 +3114,12 @@ class PairMatcherImpl : public MatcherInterface<PairType> {
|
|
const std::string& second_explanation,
|
|
const std::string& second_explanation,
|
|
MatchResultListener* listener) const {
|
|
MatchResultListener* listener) const {
|
|
*listener << "whose both fields match";
|
|
*listener << "whose both fields match";
|
|
- if (first_explanation != "") {
|
|
|
|
|
|
+ if (!first_explanation.empty()) {
|
|
*listener << ", where the first field is a value " << first_explanation;
|
|
*listener << ", where the first field is a value " << first_explanation;
|
|
}
|
|
}
|
|
- if (second_explanation != "") {
|
|
|
|
|
|
+ if (!second_explanation.empty()) {
|
|
*listener << ", ";
|
|
*listener << ", ";
|
|
- if (first_explanation != "") {
|
|
|
|
|
|
+ if (!first_explanation.empty()) {
|
|
*listener << "and ";
|
|
*listener << "and ";
|
|
} else {
|
|
} else {
|
|
*listener << "where ";
|
|
*listener << "where ";
|
|
@@ -3317,8 +3320,8 @@ class FieldsAreMatcherImpl<Struct, IndexSequence<I...>>
|
|
std::vector<StringMatchResultListener> inner_listener(sizeof...(I));
|
|
std::vector<StringMatchResultListener> inner_listener(sizeof...(I));
|
|
|
|
|
|
VariadicExpand(
|
|
VariadicExpand(
|
|
- {failed_pos == ~size_t{}&& !std::get<I>(matchers_).MatchAndExplain(
|
|
|
|
- std::get<I>(tuple), &inner_listener[I])
|
|
|
|
|
|
+ {failed_pos == ~size_t{} && !std::get<I>(matchers_).MatchAndExplain(
|
|
|
|
+ std::get<I>(tuple), &inner_listener[I])
|
|
? failed_pos = I
|
|
? failed_pos = I
|
|
: 0 ...});
|
|
: 0 ...});
|
|
if (failed_pos != ~size_t{}) {
|
|
if (failed_pos != ~size_t{}) {
|
|
@@ -5474,8 +5477,7 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
|
|
inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \
|
|
inline name##Matcher GMOCK_INTERNAL_WARNING_PUSH() \
|
|
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \
|
|
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-function") \
|
|
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \
|
|
GMOCK_INTERNAL_WARNING_CLANG(ignored, "-Wunused-member-function") \
|
|
- name \
|
|
|
|
- GMOCK_INTERNAL_WARNING_POP()() { \
|
|
|
|
|
|
+ name GMOCK_INTERNAL_WARNING_POP()() { \
|
|
return {}; \
|
|
return {}; \
|
|
} \
|
|
} \
|
|
template <typename arg_type> \
|
|
template <typename arg_type> \
|
|
@@ -5543,7 +5545,8 @@ PolymorphicMatcher<internal::ExceptionMatcherImpl<Err>> ThrowsMessage(
|
|
\
|
|
\
|
|
private: \
|
|
private: \
|
|
::std::string FormatDescription(bool negation) const { \
|
|
::std::string FormatDescription(bool negation) const { \
|
|
- ::std::string gmock_description = (description); \
|
|
|
|
|
|
+ ::std::string gmock_description; \
|
|
|
|
+ gmock_description = (description); \
|
|
if (!gmock_description.empty()) { \
|
|
if (!gmock_description.empty()) { \
|
|
return gmock_description; \
|
|
return gmock_description; \
|
|
} \
|
|
} \
|