diff options
author | misterg <misterg@google.com> | 2019-10-18 15:06:41 (GMT) |
---|---|---|
committer | Andy Soffer <asoffer@google.com> | 2019-10-18 15:34:08 (GMT) |
commit | f966ed158177f2ed6ff2c402effb16f7f00ca40b (patch) | |
tree | b371f81cfe93dcca39eb876b9e7f53c53eeb0046 /googlemock/include/gmock/gmock-matchers.h | |
parent | 1f9edcd9698162b48d94e1ef2e6a2ab7ab4e6c56 (diff) | |
download | googletest-f966ed158177f2ed6ff2c402effb16f7f00ca40b.zip googletest-f966ed158177f2ed6ff2c402effb16f7f00ca40b.tar.gz googletest-f966ed158177f2ed6ff2c402effb16f7f00ca40b.tar.bz2 |
Googletest export
Added IsNan matcher
PiperOrigin-RevId: 275473218
Diffstat (limited to 'googlemock/include/gmock/gmock-matchers.h')
-rw-r--r-- | googlemock/include/gmock/gmock-matchers.h | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/googlemock/include/gmock/gmock-matchers.h b/googlemock/include/gmock/gmock-matchers.h index be446aa..4428ec1 100644 --- a/googlemock/include/gmock/gmock-matchers.h +++ b/googlemock/include/gmock/gmock-matchers.h @@ -42,8 +42,8 @@ #ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ #define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_ +#include <math.h> #include <algorithm> -#include <cmath> #include <initializer_list> #include <iterator> #include <limits> @@ -54,7 +54,6 @@ #include <type_traits> #include <utility> #include <vector> - #include "gmock/internal/gmock-internal-utils.h" #include "gmock/internal/gmock-port.h" #include "gtest/gtest.h" @@ -1350,22 +1349,6 @@ MakePredicateFormatterFromMatcher(M matcher) { return PredicateFormatterFromMatcher<M>(std::move(matcher)); } -// Implements the polymorphic IsNan() matcher, which matches any floating type -// value that is Nan. -class IsNanMatcher { - public: - template <typename FloatType> - bool MatchAndExplain(const FloatType& f, - MatchResultListener* /* listener */) const { - return (::std::isnan)(f); - } - - void DescribeTo(::std::ostream* os) const { *os << "is NaN"; } - void DescribeNegationTo(::std::ostream* os) const { - *os << "isn't NaN"; - } -}; - // Implements the polymorphic floating point equality matcher, which matches // two float values using ULP-based approximation or, optionally, a // user-specified epsilon. The template is meant to be instantiated with @@ -1426,7 +1409,7 @@ class FloatingEqMatcher { } const FloatType diff = value - expected_; - if (::std::fabs(diff) <= max_abs_error_) { + if (fabs(diff) <= max_abs_error_) { return true; } @@ -3643,11 +3626,6 @@ inline internal::RefMatcher<T&> Ref(T& x) { // NOLINT return internal::RefMatcher<T&>(x); } -// Creates a polymorphic matcher that matches any NaN floating point. -inline PolymorphicMatcher<internal::IsNanMatcher> IsNan() { - return MakePolymorphicMatcher(internal::IsNanMatcher()); -} - // Creates a matcher that matches any double argument approximately // equal to rhs, where two NANs are considered unequal. inline internal::FloatingEqMatcher<double> DoubleEq(double rhs) { |