| 3631 | |
| 3632 | template<typename T> |
| 3633 | struct ApproxMatcher : MatcherBase<std::vector<T>> { |
| 3634 | |
| 3635 | ApproxMatcher(std::vector<T> const& comparator) : m_comparator( comparator ) {} |
| 3636 | |
| 3637 | bool match(std::vector<T> const &v) const override { |
| 3638 | if (m_comparator.size() != v.size()) |
| 3639 | return false; |
| 3640 | for (std::size_t i = 0; i < v.size(); ++i) |
| 3641 | if (m_comparator[i] != approx(v[i])) |
| 3642 | return false; |
| 3643 | return true; |
| 3644 | } |
| 3645 | std::string describe() const override { |
| 3646 | return "is approx: " + ::Catch::Detail::stringify( m_comparator ); |
| 3647 | } |
| 3648 | template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> |
| 3649 | ApproxMatcher& epsilon( T const& newEpsilon ) { |
| 3650 | approx.epsilon(newEpsilon); |
| 3651 | return *this; |
| 3652 | } |
| 3653 | template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> |
| 3654 | ApproxMatcher& margin( T const& newMargin ) { |
| 3655 | approx.margin(newMargin); |
| 3656 | return *this; |
| 3657 | } |
| 3658 | template <typename = typename std::enable_if<std::is_constructible<double, T>::value>::type> |
| 3659 | ApproxMatcher& scale( T const& newScale ) { |
| 3660 | approx.scale(newScale); |
| 3661 | return *this; |
| 3662 | } |
| 3663 | |
| 3664 | std::vector<T> const& m_comparator; |
| 3665 | mutable Catch::Detail::Approx approx = Catch::Detail::Approx::custom(); |
| 3666 | }; |
| 3667 | |
| 3668 | template<typename T> |
| 3669 | struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> { |
nothing calls this directly
no outgoing calls
no test coverage detected