From 7b9f4e4e8169ca2fad3a1c7ca03f07ecfc46678e Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Sat, 1 Aug 2015 16:35:25 +0200 Subject: Bandit 2.0.0 --- .../assertion_frameworks/matchers/BeCloseTo.h | 55 +++++++++++++ .../bandit/assertion_frameworks/matchers/BeEmpty.h | 32 ++++++++ .../bandit/assertion_frameworks/matchers/BeFalsy.h | 39 ++++++++++ .../bandit/assertion_frameworks/matchers/BeGTE.h | 45 +++++++++++ .../assertion_frameworks/matchers/BeGreaterThan.h | 39 ++++++++++ .../bandit/assertion_frameworks/matchers/BeLTE.h | 45 +++++++++++ .../assertion_frameworks/matchers/BeLessThan.h | 39 ++++++++++ .../bandit/assertion_frameworks/matchers/BeNull.h | 29 +++++++ .../assertion_frameworks/matchers/BeTruthy.h | 35 +++++++++ .../bandit/assertion_frameworks/matchers/Contain.h | 58 ++++++++++++++ .../bandit/assertion_frameworks/matchers/Equal.h | 90 ++++++++++++++++++++++ .../assertion_frameworks/matchers/MatchProxy.h | 43 +++++++++++ .../bandit/assertion_frameworks/matchers/Matcher.h | 74 ++++++++++++++++++ .../matchers/MatcherException.h | 16 ++++ .../assertion_frameworks/matchers/ThrowException.h | 60 +++++++++++++++ .../assertion_frameworks/matchers/ValueProxy.h | 26 +++++++ .../assertion_frameworks/matchers/matchers.h | 19 +++++ .../bandit/assertion_frameworks/matchers/must.h | 36 +++++++++ 18 files changed, 780 insertions(+) create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeCloseTo.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeEmpty.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeFalsy.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeGTE.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeGreaterThan.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeLTE.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeLessThan.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeNull.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/BeTruthy.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/Contain.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/Equal.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/MatchProxy.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/Matcher.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/MatcherException.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/ThrowException.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/ValueProxy.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/matchers.h create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/must.h (limited to 'vendor/bandit/bandit/assertion_frameworks/matchers') diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeCloseTo.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeCloseTo.h new file mode 100644 index 00000000..e4507c4c --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeCloseTo.h @@ -0,0 +1,55 @@ +#ifndef BANDIT_BECLOSETO_H +#define BANDIT_BECLOSETO_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + template + class BeCloseTo : public Matcher + { + public: + explicit BeCloseTo(const T& expectedValue): Matcher(), _expectedValue(expectedValue), _threshold(0.01) {} + + BeCloseTo& within(float threshold) + { + _threshold = threshold; + return *this; + } + + template + bool matches(const U& actualValue) const + { + return this->subtractable_types_match(actualValue, _expectedValue); + } + + + protected: + virtual std::string failure_message_end() const + { + std::ostringstream ss; + ss << "be close to <" << _expectedValue << ">" << " (within " << _threshold << ")"; + return ss.str(); + } + + private: + template + bool subtractable_types_match(const U& actualValue, const V& expectedValue) const + { + return (actualValue > (expectedValue - _threshold)) && (actualValue < (expectedValue + _threshold)); + } + + + private: + const T& _expectedValue; + float _threshold; + }; + + template + BeCloseTo be_close_to(const T& expectedValue) + { + return BeCloseTo(expectedValue); + } +}} + +#endif // BANDIT_BECLOSETO_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeEmpty.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeEmpty.h new file mode 100644 index 00000000..a83ef994 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeEmpty.h @@ -0,0 +1,32 @@ +#ifndef BANDIT_BEEMPTY_H +#define BANDIT_BEEMPTY_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + class BeEmpty : public Matcher + { + private: + // BeEmpty & operator=(const BeEmpty &); + + public: + explicit BeEmpty() : Matcher() {} + + template + bool matches(const U& container) const + { + return container.empty(); + } + + protected: + std::string failure_message_end() const + { + return std::string("be empty"); + } + }; + + static const BeEmpty be_empty = BeEmpty(); +}} + +#endif // BANDIT_BEEMPTY_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeFalsy.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeFalsy.h new file mode 100644 index 00000000..718c6366 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeFalsy.h @@ -0,0 +1,39 @@ +#ifndef BANDIT_BEFALSY_H +#define BANDIT_BEFALSY_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + class BeFalsy : public Matcher + { + private: + // BeFalsy& operator=(const BeFalsy&); + + public: + explicit BeFalsy() : Matcher() {} + // ~BeFalsy() {} + + template + bool matches(const U& actualValue) const + { + return !actualValue; + } + + bool matches(const std::nullptr_t&) const + { + return true; + } + + + protected: + virtual std::string failure_message_end() const + { + return std::string("evaluate to false"); + } + }; + + static const BeFalsy be_falsy = BeFalsy(); +}} + +#endif // BANDIT_BEFALSY_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeGTE.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeGTE.h new file mode 100644 index 00000000..072b2caf --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeGTE.h @@ -0,0 +1,45 @@ +#ifndef BANDIT_BEGREATERTHANOREQUAL_H +#define BANDIT_BEGREATERTHANOREQUAL_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + template + class BeGTE : public Matcher + { + public: + explicit BeGTE(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {} + + template + bool matches(const U& actualValue) const + { + return actualValue >= _expectedValue; + } + + protected: + virtual std::string failure_message_end() const + { + std::ostringstream ss; + ss << "be greater than or equal to <" << _expectedValue << ">"; + return ss.str(); + } + + private: + const T& _expectedValue; + }; + + template + BeGTE be_gte(const T& expectedValue) + { + return BeGTE(expectedValue); + } + + template + BeGTE be_greater_than_or_equal_to(const T& expectedValue) + { + return be_gte(expectedValue); + } +}} + +#endif // BANDIT_BEGREATERTHANOREQUAL_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeGreaterThan.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeGreaterThan.h new file mode 100644 index 00000000..95d93d1e --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeGreaterThan.h @@ -0,0 +1,39 @@ +#ifndef BANDIT_BEGREATERTHAN_H +#define BANDIT_BEGREATERTHAN_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + template + class BeGreaterThan : public Matcher + { + public: + explicit BeGreaterThan(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {} + + template + bool matches(const U& actualValue) const + { + return actualValue > _expectedValue; + } + + protected: + virtual std::string failure_message_end() const + { + std::ostringstream ss; + ss << "be greater than <" << _expectedValue << ">"; + return ss.str(); + } + + private: + const T& _expectedValue; + }; + + template + BeGreaterThan be_greater_than(const T& expectedValue) + { + return BeGreaterThan(expectedValue); + } +}} + +#endif // BANDIT_BEGREATERTHAN_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeLTE.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeLTE.h new file mode 100644 index 00000000..83463f75 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeLTE.h @@ -0,0 +1,45 @@ +#ifndef BANDIT_BELESSTHANOREQUAL_H +#define BANDIT_BELESSTHANOREQUAL_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + template + class BeLTE : public Matcher + { + public: + explicit BeLTE(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {} + + template + bool matches(const U& actualValue) const + { + return actualValue <= _expectedValue; + } + + protected: + virtual std::string failure_message_end() const + { + std::ostringstream ss; + ss << "be less than or equal to <" << _expectedValue << ">"; + return ss.str(); + } + + private: + const T& _expectedValue; + }; + + template + BeLTE be_lte(const T& expectedValue) + { + return BeLTE(expectedValue); + } + + template + BeLTE be_less_than_or_equal_to(const T& expectedValue) + { + return be_lte(expectedValue); + } +}} + +#endif // BANDIT_BELESSTHANOREQUAL_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeLessThan.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeLessThan.h new file mode 100644 index 00000000..87a2dc5e --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeLessThan.h @@ -0,0 +1,39 @@ +#ifndef BANDIT_BELESSTHAN_H +#define BANDIT_BELESSTHAN_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + template + class BeLessThan : public Matcher + { + public: + explicit BeLessThan(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {} + + template + bool matches(const U& actualValue) const + { + return actualValue < _expectedValue; + } + + protected: + virtual std::string failure_message_end() const + { + std::ostringstream ss; + ss << "be less than <" << _expectedValue << ">"; + return ss.str(); + } + + private: + const T& _expectedValue; + }; + + template + BeLessThan be_less_than(const T& expectedValue) + { + return BeLessThan(expectedValue); + } +}} + +#endif // BANDIT_BELESSTHAN_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeNull.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeNull.h new file mode 100644 index 00000000..6e034d10 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeNull.h @@ -0,0 +1,29 @@ +#ifndef BANDIT_BENULL_H +#define BANDIT_BENULL_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + class BeNull : public Matcher + { + public: + BeNull() : Matcher() {} + + template + bool matches(U *const & actualValue) const + { + return !actualValue; + } + + protected: + std::string failure_message_end() const + { + return std::string("be nil"); + } + }; + + static const BeNull be_null = BeNull(); +}} + +#endif // BANDIT_BENULL_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/BeTruthy.h b/vendor/bandit/bandit/assertion_frameworks/matchers/BeTruthy.h new file mode 100644 index 00000000..c8652538 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/BeTruthy.h @@ -0,0 +1,35 @@ +#ifndef BANDIT_BETRUTHY_H +#define BANDIT_BETRUTHY_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + class BeTruthy : public Matcher + { + public: + BeTruthy() : Matcher() {} + + template + bool matches(const U& actualValue) const + { + return !!actualValue; + } + + bool matches(const std::nullptr_t&) const + { + return false; + } + + + protected: + virtual std::string failure_message_end() const + { + return std::string("evaluate to true"); + } + }; + + static const BeTruthy be_truthy = BeTruthy(); +}} + +#endif // BANDIT_BETRUTHY_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/Contain.h b/vendor/bandit/bandit/assertion_frameworks/matchers/Contain.h new file mode 100644 index 00000000..f048e3a3 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/Contain.h @@ -0,0 +1,58 @@ +#ifndef BANDIT_CONTAIN_H +#define BANDIT_CONTAIN_H + +#include +#include + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + template + class Contain : public Matcher + { + public: + explicit Contain(const T& element) : Matcher(), _element(element) {} + + template + bool matches(const U& container) const + { + return container.find(_element) != container.end(); + } + + template + bool matches(const std::vector& container) const + { + return std::find(container.begin(), container.end(), _element) != container.end(); + } + + bool matches(const char *const container) const + { + return (_element != NULL) && (container != NULL) && (strstr(container, _element) != NULL); + } + + bool matches(char *const container) const + { + return (_element != NULL) && (container != NULL) && (strstr(container, _element) != NULL); + } + + protected: + std::string failure_message_end() const + { + std::ostringstream ss; + ss << "contain <" << _element << ">"; + return ss.str(); + } + + private: + const T& _element; + }; + + template + Contain contain(const T& element) + { + return Contain(element); + } +}} + +#endif // BANDIT_CONTAIN_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/Equal.h b/vendor/bandit/bandit/assertion_frameworks/matchers/Equal.h new file mode 100644 index 00000000..521c6008 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/Equal.h @@ -0,0 +1,90 @@ +#ifndef BANDIT_EQUAL_H +#define BANDIT_EQUAL_H + +#include +#include + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + template + std::ostream& operator<<(std::ostream& os, const std::unique_ptr& obj) + { + return os << *obj; + } + + template + class Equal : public Matcher + { + public: + explicit Equal(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {} + + template + bool matches(const U& actualValue) const + { + return actualValue == _expectedValue; + } + + bool matches(char* actualValue) const + { + return strcmp(actualValue, &*_expectedValue) == 0; + } + + bool matches(const char* actualValue) const + { + return strcmp(actualValue, &*_expectedValue) == 0; + } + + template + bool matches(const std::unique_ptr& pointer) const + { + return matches(pointer.get()); + } + + protected: + virtual std::string failure_message_end() const + { + std::ostringstream ss; + ss << "equal <" << _expectedValue << ">"; + return ss.str(); + } + + private: + const T& _expectedValue; + }; + + template + Equal equal(const T& expectedValue) + { + return Equal(expectedValue); + } + + template + bool operator==(const ValueProxy& actualValue, const U& expectedValue) + { + return actualValue.to == expectedValue; + } + + template + bool operator==(const MatchProxy& matchProxy, const U& expectedValue) + { + matchProxy(equal(expectedValue)); + return true; + } + + template + bool operator!=(const ValueProxy& actualValue, const U& expectedValue) + { + return actualValue.to != expectedValue; + } + + template + bool operator!=(const MatchProxy& matchProxy, const U& expectedValue) + { + matchProxy.negate()(equal(expectedValue)); + return true; + } +}} + +#endif // BANDIT_EQUAL_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/MatchProxy.h b/vendor/bandit/bandit/assertion_frameworks/matchers/MatchProxy.h new file mode 100644 index 00000000..b637ef0d --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/MatchProxy.h @@ -0,0 +1,43 @@ +#ifndef BANDIT_MATCHPROXY_H +#define BANDIT_MATCHPROXY_H + +#include "MatcherException.h" + +namespace bandit { namespace Matchers +{ + template class ValueProxy; + + template + class MatchProxy + { + private: + template + MatchProxy(const MatchProxy&); + + template + MatchProxy& operator=(const MatchProxy&); + + public: + explicit MatchProxy(const ValueProxy& value, bool negate_ = false) : _value(value), _negate(negate_) {} + + template + void operator()(const MatcherType& matcher) const + { + if( matcher.matches(_value._value) == _negate ) + { + throw MatcherException(_value._filename, _value._lineNumber, matcher.failure_message(_value._value, _negate)); + } + } + + MatchProxy negate() const + { + return MatchProxy(_value, !_negate); + } + + private: + const ValueProxy& _value; + bool _negate; + }; +}} + +#endif // BANDIT_MATCHPROXY_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/Matcher.h b/vendor/bandit/bandit/assertion_frameworks/matchers/Matcher.h new file mode 100644 index 00000000..ad48c0a5 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/Matcher.h @@ -0,0 +1,74 @@ +#ifndef BANDIT_MATCHER_H +#define BANDIT_MATCHER_H + +#include + +//#import "CedarStringifiers.h" + +namespace bandit { namespace Matchers { + class Matcher + { + public: + Matcher() {} + + template + std::string failure_message(const U& value, bool negate) const + { + std::ostringstream ss; + ss << "Expected <" << value << "> " << (negate ? "to not " : "to ") << failure_message_end(); + return ss.str(); + } + + std::string failure_message(char *const value, bool negate) const + { + return failure_message((value ? value : "NULL"), negate); + } + + template + std::string failure_message(const std::unique_ptr& value, bool negate) const + { + return failure_message(value.get(), negate); + } + + std::string failure_message(const std::nullptr_t pointer, bool negate) const + { + (void)pointer; + return failure_message("nullptr", negate); + } + + template + std::string failure_message(std::function& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + template + std::string failure_message(const std::function& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + template > class container > + std::string failure_message(const container& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + template, class = std::allocator > class container > + std::string failure_message(const container& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + template, class = std::allocator> > class container > + std::string failure_message(const container& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + protected: + virtual std::string failure_message_end() const = 0; + }; +}} + +#endif // BANDIT_MATCHER_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/MatcherException.h b/vendor/bandit/bandit/assertion_frameworks/matchers/MatcherException.h new file mode 100644 index 00000000..5d657ed7 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/MatcherException.h @@ -0,0 +1,16 @@ +#ifndef BANDIT_MATCHER_EXCEPTION_H +#define BANDIT_MATCHER_EXCEPTION_H + +#include + +namespace bandit { namespace Matchers { + class MatcherException : public detail::assertion_exception + { + public: + MatcherException(const std::string& filename, const unsigned linenumber, const std::string& message) : detail::assertion_exception(message, filename, linenumber) {} + MatcherException(const MatcherException&) = default; + virtual ~MatcherException() noexcept {} + }; +}} + +#endif // BANDIT_MATCHER_EXCEPTION_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/ThrowException.h b/vendor/bandit/bandit/assertion_frameworks/matchers/ThrowException.h new file mode 100644 index 00000000..cd8bfc34 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/ThrowException.h @@ -0,0 +1,60 @@ +#ifndef BANDIT_THROWEXCEPTION_H +#define BANDIT_THROWEXCEPTION_H + +#include "Matcher.h" + +namespace bandit { namespace Matchers { + + template + class ThrowException : public Matcher + { + public: + ThrowException() : Matcher(), _allow_subclasses(false) {} + explicit ThrowException(bool allow_subclasses) : Matcher(), _allow_subclasses(allow_subclasses) {} + + template + ThrowException operator()() const + { + return ThrowException(); + } + + ThrowException& or_subclass() + { + _allow_subclasses = true; + return *this; + } + + template + bool matches(const U& block) const + { + try + { + block(); + } + catch(const T& e) + { + return true; + } + catch(...) // Wrong exception + { + _exception = std::current_exception(); + } + + return false; + } + + protected: + std::string failure_message_end() const + { + return std::string("throw an exception"); + } + + private: + bool _allow_subclasses; + mutable std::exception_ptr _exception; + }; + + static const ThrowException throw_exception; +}} + +#endif // BANDIT_THROWEXCEPTION_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/ValueProxy.h b/vendor/bandit/bandit/assertion_frameworks/matchers/ValueProxy.h new file mode 100644 index 00000000..0cd5d35c --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/ValueProxy.h @@ -0,0 +1,26 @@ +#ifndef BANDIT_VALUEPROXY_H +#define BANDIT_VALUEPROXY_H + +#include "MatchProxy.h" + +namespace bandit { namespace Matchers { + + template + class ValueProxy + { + public: + MatchProxy to; + MatchProxy to_not; + + explicit ValueProxy(const char* filename, int lineNumber, const T& value) : to(*this), to_not(*this, true), _value(value), _filename(filename), _lineNumber(lineNumber) {} + + private: + friend class MatchProxy; + + const T& _value; + std::string _filename; + int _lineNumber; + }; +}} + +#endif // BANDIT_VALUEPROXY_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/matchers.h b/vendor/bandit/bandit/assertion_frameworks/matchers/matchers.h new file mode 100644 index 00000000..033cefcd --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/matchers.h @@ -0,0 +1,19 @@ +#ifndef BANDIT_MATCHERS_H +#define BANDIT_MATCHERS_H + +#include "must.h" + +#include "BeCloseTo.h" +#include "BeEmpty.h" +#include "BeFalsy.h" +#include "BeGreaterThan.h" +#include "BeGTE.h" +#include "BeLessThan.h" +#include "BeLTE.h" +#include "BeNull.h" +#include "BeTruthy.h" +#include "Contain.h" +#include "Equal.h" +#include "ThrowException.h" + +#endif // BANDIT_MATCHERS_H diff --git a/vendor/bandit/bandit/assertion_frameworks/matchers/must.h b/vendor/bandit/bandit/assertion_frameworks/matchers/must.h new file mode 100644 index 00000000..54eedb7f --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/matchers/must.h @@ -0,0 +1,36 @@ +#ifndef BANDIT_MUST_H +#define BANDIT_MUST_H + +#include "ValueProxy.h" + +namespace bandit { namespace Matchers +{ + struct ValueMarker + { + const char* filename; + int lineNumber; + }; + + template + const ValueProxy operator,(const T& value, const ValueMarker& marker) + { + return ValueProxy(marker.filename, marker.lineNumber, value); + } + + template + const MatchProxy operator,(const ValueProxy& value, bool negate) + { + return negate ? value.to_not : value.to; + } + + template + void operator,(const MatchProxy& matchProxy, const MatcherType& matcher) + { + matchProxy(matcher); + } +}} + +#define must ,(bandit::Matchers::ValueMarker){__FILE__, __LINE__},false, +#define must_not ,(bandit::Matchers::ValueMarker){__FILE__, __LINE__},true, + +#endif //BANDIT_MUST_H -- cgit v1.2.3