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

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2020-03-05 14:40:40 +0100
committerMartin Hořeňovský2020-03-27 10:22:25 +0100
commitf52a58e857967124bedf5370b5b03f799c1db0b2 (patch)
tree2983f90bb15a4c22a19194b316f56077f2fab4fb /src
parent007efc173a6cf64f625f4b75f40d7f4ebd3c0b34 (diff)
downloadcatch3-f52a58e857967124bedf5370b5b03f799c1db0b2.tar.gz
Make concrete matchers final
Outside of `MatcherBase` and `GenericMatcherBase`, matchers are not designed to be overriden. This means that doing so can easily lead to errors, and matchers are generally fairly simple functionality-wise. so there is not much code reuse to be gained anyway. Thus, Catch2-provided concrete matchers are now final.
Diffstat (limited to 'src')
-rw-r--r--src/catch2/matchers/catch_matchers_exception.hpp2
-rw-r--r--src/catch2/matchers/catch_matchers_floating.hpp6
-rw-r--r--src/catch2/matchers/catch_matchers_generic.hpp2
-rw-r--r--src/catch2/matchers/catch_matchers_string.hpp10
-rw-r--r--src/catch2/matchers/catch_matchers_vector.hpp10
5 files changed, 15 insertions, 15 deletions
diff --git a/src/catch2/matchers/catch_matchers_exception.hpp b/src/catch2/matchers/catch_matchers_exception.hpp
index 03389005..74355cd8 100644
--- a/src/catch2/matchers/catch_matchers_exception.hpp
+++ b/src/catch2/matchers/catch_matchers_exception.hpp
@@ -13,7 +13,7 @@ namespace Catch {
namespace Matchers {
namespace Exception {
-class ExceptionMessageMatcher : public MatcherBase<std::exception> {
+class ExceptionMessageMatcher final : public MatcherBase<std::exception> {
std::string m_message;
public:
diff --git a/src/catch2/matchers/catch_matchers_floating.hpp b/src/catch2/matchers/catch_matchers_floating.hpp
index cb49cf26..bead3a04 100644
--- a/src/catch2/matchers/catch_matchers_floating.hpp
+++ b/src/catch2/matchers/catch_matchers_floating.hpp
@@ -16,7 +16,7 @@ namespace Matchers {
enum class FloatingPointKind : uint8_t;
- struct WithinAbsMatcher : MatcherBase<double> {
+ struct WithinAbsMatcher final : MatcherBase<double> {
WithinAbsMatcher(double target, double margin);
bool match(double const& matchee) const override;
std::string describe() const override;
@@ -25,7 +25,7 @@ namespace Matchers {
double m_margin;
};
- struct WithinUlpsMatcher : MatcherBase<double> {
+ struct WithinUlpsMatcher final : MatcherBase<double> {
WithinUlpsMatcher(double target, uint64_t ulps, FloatingPointKind baseType);
bool match(double const& matchee) const override;
std::string describe() const override;
@@ -41,7 +41,7 @@ namespace Matchers {
// |lhs - rhs| <= epsilon * max(fabs(lhs), fabs(rhs)), then we get
// the same result if we do this for floats, as if we do this for
// doubles that were promoted from floats.
- struct WithinRelMatcher : MatcherBase<double> {
+ struct WithinRelMatcher final : MatcherBase<double> {
WithinRelMatcher(double target, double epsilon);
bool match(double const& matchee) const override;
std::string describe() const override;
diff --git a/src/catch2/matchers/catch_matchers_generic.hpp b/src/catch2/matchers/catch_matchers_generic.hpp
index 81e21c42..dcdff771 100644
--- a/src/catch2/matchers/catch_matchers_generic.hpp
+++ b/src/catch2/matchers/catch_matchers_generic.hpp
@@ -23,7 +23,7 @@ namespace Detail {
}
template <typename T, typename Predicate>
-class PredicateMatcher : public MatcherBase<T> {
+class PredicateMatcher final : public MatcherBase<T> {
Predicate m_predicate;
std::string m_description;
public:
diff --git a/src/catch2/matchers/catch_matchers_string.hpp b/src/catch2/matchers/catch_matchers_string.hpp
index 6e351cd0..7f522b6f 100644
--- a/src/catch2/matchers/catch_matchers_string.hpp
+++ b/src/catch2/matchers/catch_matchers_string.hpp
@@ -35,24 +35,24 @@ namespace Matchers {
std::string m_operation;
};
- struct EqualsMatcher : StringMatcherBase {
+ struct EqualsMatcher final : StringMatcherBase {
EqualsMatcher( CasedString const& comparator );
bool match( std::string const& source ) const override;
};
- struct ContainsMatcher : StringMatcherBase {
+ struct ContainsMatcher final : StringMatcherBase {
ContainsMatcher( CasedString const& comparator );
bool match( std::string const& source ) const override;
};
- struct StartsWithMatcher : StringMatcherBase {
+ struct StartsWithMatcher final : StringMatcherBase {
StartsWithMatcher( CasedString const& comparator );
bool match( std::string const& source ) const override;
};
- struct EndsWithMatcher : StringMatcherBase {
+ struct EndsWithMatcher final : StringMatcherBase {
EndsWithMatcher( CasedString const& comparator );
bool match( std::string const& source ) const override;
};
- struct RegexMatcher : MatcherBase<std::string> {
+ struct RegexMatcher final : MatcherBase<std::string> {
RegexMatcher( std::string regex, CaseSensitive::Choice caseSensitivity );
bool match( std::string const& matchee ) const override;
std::string describe() const override;
diff --git a/src/catch2/matchers/catch_matchers_vector.hpp b/src/catch2/matchers/catch_matchers_vector.hpp
index 24300641..e5d68949 100644
--- a/src/catch2/matchers/catch_matchers_vector.hpp
+++ b/src/catch2/matchers/catch_matchers_vector.hpp
@@ -18,7 +18,7 @@ namespace Matchers {
namespace Vector {
template<typename T>
- struct ContainsElementMatcher : MatcherBase<std::vector<T>> {
+ struct ContainsElementMatcher final : MatcherBase<std::vector<T>> {
ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {}
@@ -39,7 +39,7 @@ namespace Matchers {
};
template<typename T>
- struct ContainsMatcher : MatcherBase<std::vector<T>> {
+ struct ContainsMatcher final : MatcherBase<std::vector<T>> {
ContainsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {}
@@ -69,7 +69,7 @@ namespace Matchers {
};
template<typename T>
- struct EqualsMatcher : MatcherBase<std::vector<T>> {
+ struct EqualsMatcher final : MatcherBase<std::vector<T>> {
EqualsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {}
@@ -92,7 +92,7 @@ namespace Matchers {
};
template<typename T>
- struct ApproxMatcher : MatcherBase<std::vector<T>> {
+ struct ApproxMatcher final : MatcherBase<std::vector<T>> {
ApproxMatcher(std::vector<T> const& comparator) : m_comparator( comparator ) {}
@@ -128,7 +128,7 @@ namespace Matchers {
};
template<typename T>
- struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {
+ struct UnorderedEqualsMatcher final : MatcherBase<std::vector<T>> {
UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(target) {}
bool match(std::vector<T> const& vec) const override {
// Note: This is a reimplementation of std::is_permutation,