Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorPhil Nash2017-02-21 15:52:03 +0000
committerPhil Nash2017-02-21 15:52:03 +0000
commit45d4096756ef3a59af2f0147d4e869ca669dd94a (patch)
tree8128e9983bc57df0c23ed328d260cb8e36059809 /include
parent4e6938d78e375d9bc3481d7baccb0f84341a4010 (diff)
downloadcatch3-45d4096756ef3a59af2f0147d4e869ca669dd94a.tar.gz
Generalised Matchers so objects and comparators can be different types
Diffstat (limited to 'include')
-rw-r--r--include/internal/catch_matchers.hpp28
-rw-r--r--include/internal/catch_matchers_string.h6
2 files changed, 17 insertions, 17 deletions
diff --git a/include/internal/catch_matchers.hpp b/include/internal/catch_matchers.hpp
index 897bb3b1..d6118f89 100644
--- a/include/internal/catch_matchers.hpp
+++ b/include/internal/catch_matchers.hpp
@@ -33,14 +33,14 @@ namespace Matchers {
MatcherUntypedBase& operator = (MatcherUntypedBase const&);
};
- template<typename ArgT>
+ template<typename ObjectT, typename ComparatorT = ObjectT>
struct MatcherBase : MatcherUntypedBase {
- virtual bool match( ArgT const& arg ) const = 0;
+ virtual bool match( ObjectT const& arg ) const = 0;
- MatchAllOf<ArgT> operator && ( MatcherBase const& other ) const;
- MatchAnyOf<ArgT> operator || ( MatcherBase const& other ) const;
- MatchNotOf<ArgT> operator ! () const;
+ MatchAllOf<ComparatorT> operator && ( MatcherBase const& other ) const;
+ MatchAnyOf<ComparatorT> operator || ( MatcherBase const& other ) const;
+ MatchNotOf<ComparatorT> operator ! () const;
};
template<typename ArgT>
@@ -118,17 +118,17 @@ namespace Matchers {
MatcherBase<ArgT> const& m_underlyingMatcher;
};
- template<typename ArgT>
- MatchAllOf<ArgT> MatcherBase<ArgT>::operator && ( MatcherBase const& other ) const {
- return MatchAllOf<ArgT>() && *this && other;
+ template<typename ObjectT, typename ComparatorT>
+ MatchAllOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator && ( MatcherBase const& other ) const {
+ return MatchAllOf<ComparatorT>() && *this && other;
}
- template<typename ArgT>
- MatchAnyOf<ArgT> MatcherBase<ArgT>::operator || ( MatcherBase const& other ) const {
- return MatchAnyOf<ArgT>() || *this || other;
+ template<typename ObjectT, typename ComparatorT>
+ MatchAnyOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator || ( MatcherBase const& other ) const {
+ return MatchAnyOf<ComparatorT>() || *this || other;
}
- template<typename ArgT>
- MatchNotOf<ArgT> MatcherBase<ArgT>::operator ! () const {
- return MatchNotOf<ArgT>( *this );
+ template<typename ObjectT, typename ComparatorT>
+ MatchNotOf<ComparatorT> MatcherBase<ObjectT, ComparatorT>::operator ! () const {
+ return MatchNotOf<ComparatorT>( *this );
}
} // namespace Impl
diff --git a/include/internal/catch_matchers_string.h b/include/internal/catch_matchers_string.h
index 87476b12..2a6d3ba0 100644
--- a/include/internal/catch_matchers_string.h
+++ b/include/internal/catch_matchers_string.h
@@ -5,8 +5,8 @@
* Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*/
-#ifndef TWOBLUECUBES_CATCH_MATCHERS_STRING_HPP_INCLUDED
-#define TWOBLUECUBES_CATCH_MATCHERS_STRING_HPP_INCLUDED
+#ifndef TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED
+#define TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED
#include "catch_matchers.hpp"
@@ -64,4 +64,4 @@ namespace Matchers {
} // namespace Matchers
} // namespace Catch
-#endif // TWOBLUECUBES_CATCH_MATCHERS_STRING_HPP_INCLUDED
+#endif // TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED