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 --- .../bandit/assertion_frameworks/matchers/Contain.h | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 vendor/bandit/bandit/assertion_frameworks/matchers/Contain.h (limited to 'vendor/bandit/bandit/assertion_frameworks/matchers/Contain.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 -- cgit v1.2.3