diff options
author | Manoj Srivastava <srivasta@debian.org> | 2016-01-27 12:43:59 -0800 |
---|---|---|
committer | Manoj Srivastava <srivasta@debian.org> | 2016-01-27 12:50:09 -0800 |
commit | 76fce162659078323fcd5e54b3195dae371faca2 (patch) | |
tree | c1d93d415b96238aae3c54eb83cb0815af2e4bca /vendor/bandit/bandit/assertion_frameworks/matchers/Matcher.h | |
parent | b4456969cd02d75c599a5b86b225c0774697e85d (diff) | |
parent | 4aa1a39402c3908e9e8b6eb3fd4e2183d5e5c52e (diff) |
Merge branch 'development' into upstream
Signed-off-by: Manoj Srivastava <srivasta@debian.org>
# Conflicts:
# src/.gitignore
# src/maid-x11.c
# src/quest.pkg
Diffstat (limited to 'vendor/bandit/bandit/assertion_frameworks/matchers/Matcher.h')
-rw-r--r-- | vendor/bandit/bandit/assertion_frameworks/matchers/Matcher.h | 74 |
1 files changed, 74 insertions, 0 deletions
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 <sstream> + +//#import "CedarStringifiers.h" + +namespace bandit { namespace Matchers { + class Matcher + { + public: + Matcher() {} + + template<typename U> + 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<typename U> + std::string failure_message(const std::unique_ptr<U>& 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<typename U> + std::string failure_message(std::function<U>& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + template<typename U> + std::string failure_message(const std::function<U>& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + template<typename U, template <class T, class = std::allocator<T> > class container > + std::string failure_message(const container<U>& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + template<typename U, template <class T, class = std::less<T>, class = std::allocator<T> > class container > + std::string failure_message(const container<U>& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + template<typename U, typename V, template <class K, class T, class = std::less<K>, class = std::allocator<std::pair<const K,T>> > class container > + std::string failure_message(const container<U,V>& value, bool negate) const + { + return failure_message(typeid(value).name(), negate); + } + + protected: + virtual std::string failure_message_end() const = 0; + }; +}} + +#endif // BANDIT_MATCHER_H |