summaryrefslogtreecommitdiff
path: root/vendor/bandit/bandit
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-08-01 16:35:25 +0200
committerBardur Arantsson <bardur@scientician.net>2015-09-14 05:58:27 +0200
commit7b9f4e4e8169ca2fad3a1c7ca03f07ecfc46678e (patch)
tree0cef1ac0dc228b621afc90bc94e4e0dddcb90c82 /vendor/bandit/bandit
parentc6196b25d119a10e79deedef26a73e0d5a021b0e (diff)
Bandit 2.0.0
Diffstat (limited to 'vendor/bandit/bandit')
-rw-r--r--vendor/bandit/bandit/assertion_exception.h8
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeCloseTo.h55
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeEmpty.h32
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeFalsy.h39
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeGTE.h45
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeGreaterThan.h39
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeLTE.h45
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeLessThan.h39
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeNull.h29
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/BeTruthy.h35
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/Contain.h58
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/Equal.h90
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/MatchProxy.h43
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/Matcher.h74
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/MatcherException.h16
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/ThrowException.h60
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/ValueProxy.h26
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/matchers.h19
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/matchers/must.h36
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/.gitignore6
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/CMakeLists.txt44
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/LICENSE_1_0.txt23
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/README.md83
-rwxr-xr-xvendor/bandit/bandit/assertion_frameworks/snowhouse/cross_compile.sh50
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/basic_assertions.cpp228
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/boolean_operators.cpp48
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/container_spec.cpp85
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/custom_matchers_test.cpp69
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/exceptions_tests.cpp97
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/expression_error_handling.cpp28
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/main.cpp38
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/map_tests.cpp38
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/operator_tests.cpp137
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/sequence_container_tests.cpp192
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/string_line_tests.cpp179
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/string_tests.cpp65
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/stringize_tests.cpp111
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/example/tests.h16
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assert.h48
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertionexception.h10
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h9
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/constraints.h2
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalsconstraint.h9
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalscontainerconstraint.h7
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/isgreaterthanorequaltoconstraint.h55
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/islessthanorequaltoconstraint.h55
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/exceptions.h61
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/expressionbuilder.h60
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/collections/collectionconstraintevaluator.h4
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/constraintoperator.h23
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/invalidexpressionexception.h28
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/snowhouse.h11
-rw-r--r--vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/stringize.h14
-rw-r--r--vendor/bandit/bandit/bandit.h10
-rw-r--r--vendor/bandit/bandit/context.h4
-rw-r--r--vendor/bandit/bandit/grammar.h46
-rw-r--r--vendor/bandit/bandit/options.h10
-rw-r--r--vendor/bandit/bandit/registration/registrar.h6
-rw-r--r--vendor/bandit/bandit/reporters/colorizer.h46
-rw-r--r--vendor/bandit/bandit/reporters/info_reporter.h194
-rw-r--r--vendor/bandit/bandit/reporters/reporters.h1
-rw-r--r--vendor/bandit/bandit/run_policies/bandit_run_policy.h10
-rw-r--r--vendor/bandit/bandit/run_policies/run_policy.h17
-rw-r--r--vendor/bandit/bandit/runner.h7
64 files changed, 2971 insertions, 101 deletions
diff --git a/vendor/bandit/bandit/assertion_exception.h b/vendor/bandit/bandit/assertion_exception.h
index 33d7474f..9abc9867 100644
--- a/vendor/bandit/bandit/assertion_exception.h
+++ b/vendor/bandit/bandit/assertion_exception.h
@@ -6,8 +6,8 @@ namespace bandit { namespace detail {
struct assertion_exception : public std::runtime_error
{
assertion_exception(const std::string& message,
- const std::string& file_name, const unsigned int line_number)
- : std::runtime_error(message), file_name_(file_name), line_number_(line_number)
+ const std::string& filename, const unsigned int linenumber)
+ : std::runtime_error(message), file_name_(filename), line_number_(linenumber)
{}
assertion_exception(const std::string& message)
@@ -17,7 +17,9 @@ namespace bandit { namespace detail {
//
// To make gcc < 4.7 happy.
//
- virtual ~assertion_exception() throw()
+ assertion_exception(const assertion_exception&) = default;
+ assertion_exception(assertion_exception&&) = default;
+ virtual ~assertion_exception() noexcept
{}
const std::string& file_name() const
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<typename T>
+ class BeCloseTo : public Matcher
+ {
+ public:
+ explicit BeCloseTo(const T& expectedValue): Matcher(), _expectedValue(expectedValue), _threshold(0.01) {}
+
+ BeCloseTo<T>& within(float threshold)
+ {
+ _threshold = threshold;
+ return *this;
+ }
+
+ template<typename U>
+ 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<typename U, typename V>
+ 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<typename T>
+ BeCloseTo<T> be_close_to(const T& expectedValue)
+ {
+ return BeCloseTo<T>(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<typename U>
+ 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<typename U>
+ 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<typename T>
+ class BeGTE : public Matcher
+ {
+ public:
+ explicit BeGTE(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {}
+
+ template<typename U>
+ 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<typename T>
+ BeGTE<T> be_gte(const T& expectedValue)
+ {
+ return BeGTE<T>(expectedValue);
+ }
+
+ template<typename T>
+ BeGTE<T> 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<typename T>
+ class BeGreaterThan : public Matcher
+ {
+ public:
+ explicit BeGreaterThan(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {}
+
+ template<typename U>
+ 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<typename T>
+ BeGreaterThan<T> be_greater_than(const T& expectedValue)
+ {
+ return BeGreaterThan<T>(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<typename T>
+ class BeLTE : public Matcher
+ {
+ public:
+ explicit BeLTE(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {}
+
+ template<typename U>
+ 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<typename T>
+ BeLTE<T> be_lte(const T& expectedValue)
+ {
+ return BeLTE<T>(expectedValue);
+ }
+
+ template<typename T>
+ BeLTE<T> 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<typename T>
+ class BeLessThan : public Matcher
+ {
+ public:
+ explicit BeLessThan(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {}
+
+ template<typename U>
+ 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<typename T>
+ BeLessThan<T> be_less_than(const T& expectedValue)
+ {
+ return BeLessThan<T>(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<typename U>
+ 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<typename U>
+ 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 <cstring>
+#include <vector>
+
+#include "Matcher.h"
+
+namespace bandit { namespace Matchers {
+
+ template<typename T>
+ class Contain : public Matcher
+ {
+ public:
+ explicit Contain(const T& element) : Matcher(), _element(element) {}
+
+ template<typename U>
+ bool matches(const U& container) const
+ {
+ return container.find(_element) != container.end();
+ }
+
+ template<typename U>
+ bool matches(const std::vector<U>& 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<typename T>
+ Contain<T> contain(const T& element)
+ {
+ return Contain<T>(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 <cstring>
+#include <memory>
+
+#include "Matcher.h"
+
+namespace bandit { namespace Matchers {
+
+ template<typename T>
+ std::ostream& operator<<(std::ostream& os, const std::unique_ptr<T>& obj)
+ {
+ return os << *obj;
+ }
+
+ template<typename T>
+ class Equal : public Matcher
+ {
+ public:
+ explicit Equal(const T& expectedValue) : Matcher(), _expectedValue(expectedValue) {}
+
+ template<typename U>
+ 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<typename U>
+ bool matches(const std::unique_ptr<U>& 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<typename T>
+ Equal<T> equal(const T& expectedValue)
+ {
+ return Equal<T>(expectedValue);
+ }
+
+ template<typename T, typename U>
+ bool operator==(const ValueProxy<T>& actualValue, const U& expectedValue)
+ {
+ return actualValue.to == expectedValue;
+ }
+
+ template<typename T, typename U>
+ bool operator==(const MatchProxy<T>& matchProxy, const U& expectedValue)
+ {
+ matchProxy(equal(expectedValue));
+ return true;
+ }
+
+ template<typename T, typename U>
+ bool operator!=(const ValueProxy<T>& actualValue, const U& expectedValue)
+ {
+ return actualValue.to != expectedValue;
+ }
+
+ template<typename T, typename U>
+ bool operator!=(const MatchProxy<T>& 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<typename T> class ValueProxy;
+
+ template<typename T>
+ class MatchProxy
+ {
+ private:
+ template<typename U>
+ MatchProxy(const MatchProxy<U>&);
+
+ template<typename U>
+ MatchProxy& operator=(const MatchProxy<U>&);
+
+ public:
+ explicit MatchProxy(const ValueProxy<T>& value, bool negate_ = false) : _value(value), _negate(negate_) {}
+
+ template<typename MatcherType>
+ 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<T> negate() const
+ {
+ return MatchProxy<T>(_value, !_negate);
+ }
+
+ private:
+ const ValueProxy<T>& _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 <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
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 <bandit/assertion_exception.h>
+
+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 <typename T>
+ class ThrowException : public Matcher
+ {
+ public:
+ ThrowException() : Matcher(), _allow_subclasses(false) {}
+ explicit ThrowException(bool allow_subclasses) : Matcher(), _allow_subclasses(allow_subclasses) {}
+
+ template <typename U = std::exception>
+ ThrowException<U> operator()() const
+ {
+ return ThrowException<U>();
+ }
+
+ ThrowException& or_subclass()
+ {
+ _allow_subclasses = true;
+ return *this;
+ }
+
+ template <typename U>
+ 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<std::exception> 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<typename T>
+ class ValueProxy
+ {
+ public:
+ MatchProxy<T> to;
+ MatchProxy<T> 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<T>;
+
+ 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<typename T>
+ const ValueProxy<T> operator,(const T& value, const ValueMarker& marker)
+ {
+ return ValueProxy<T>(marker.filename, marker.lineNumber, value);
+ }
+
+ template<typename T>
+ const MatchProxy<T> operator,(const ValueProxy<T>& value, bool negate)
+ {
+ return negate ? value.to_not : value.to;
+ }
+
+ template<typename T, typename MatcherType>
+ void operator,(const MatchProxy<T>& 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
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/.gitignore b/vendor/bandit/bandit/assertion_frameworks/snowhouse/.gitignore
deleted file mode 100644
index bf3ce9c6..00000000
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-#cmake files
-CMakeCache.txt
-CMakeFiles/
-Makefile
-bin/
-cmake_install.cmake
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/CMakeLists.txt b/vendor/bandit/bandit/assertion_frameworks/snowhouse/CMakeLists.txt
index edfabc0d..ea43226b 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/CMakeLists.txt
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/CMakeLists.txt
@@ -2,16 +2,48 @@ cmake_minimum_required(VERSION 2.8)
project(snowhouse)
+option(SNOWHOUSE_BUILD_TESTS "Build the Snowhouse tests" ON)
+option(SNOWHOUSE_RUN_TESTS "Run the Snowhouse tests" ON)
+option(SNOWHOUSE_IS_CPP11 "Whether to build this as a C++11 project" OFF)
+
include_directories("${PROJECT_SOURCE_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ./bin)
set(CMAKE_CXX_FLAGS "-Wfatal-errors -Wall -W -Werror -Wfloat-equal -Wundef -Wendif-labels -Wshadow -pedantic-errors")
-FILE(GLOB SnowhouseSpecSourceFiles example/*.cpp)
-add_executable(snowhouse-tests ${SnowhouseSpecSourceFiles})
+if(SNOWHOUSE_IS_CPP11)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdeprecated")
+
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
+ else()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ endif()
+ endif()
+
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+ endif()
+
+ if (CMAKE_HOST_APPLE AND (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ endif()
+endif()
+
+message(${CMAKE_CXX_FLAGS})
+
+if (SNOWHOUSE_BUILD_TESTS)
+ FILE(GLOB SnowhouseSpecSourceFiles example/*.cpp)
+ add_executable(snowhouse-tests ${SnowhouseSpecSourceFiles})
+endif()
-add_custom_command(TARGET snowhouse-tests
- POST_BUILD
- COMMAND snowhouse-tests
- WORKING_DIRECTORY ./bin)
+if (SNOWHOUSE_BUILD_TESTS AND SNOWHOUSE_RUN_TESTS)
+ add_custom_command(TARGET snowhouse-tests
+ POST_BUILD
+ COMMAND snowhouse-tests
+ WORKING_DIRECTORY ./bin)
+elseif (SNOWHOUSE_RUN_TESTS)
+ message(WARNING "Unable to run snowhouse tests - set:\n option(SNOWHOUSE_BUILD_TESTS, \"Build the Snowhouse tests\" ON)\nand clear your CMakeCache.txt")
+endif()
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/LICENSE_1_0.txt b/vendor/bandit/bandit/assertion_frameworks/snowhouse/LICENSE_1_0.txt
new file mode 100644
index 00000000..36b7cd93
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/LICENSE_1_0.txt
@@ -0,0 +1,23 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/README.md b/vendor/bandit/bandit/assertion_frameworks/snowhouse/README.md
index 67d849b6..ecd6e039 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/README.md
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/README.md
@@ -111,6 +111,33 @@ AssertThat(x, IsLessThan(3));
AssertThat(x, Is().LessThan(3));
```
+####GreaterThanOrEqualTo Constraint
+
+Used to verify that actual is greater than or equal to a value.
+
+```cpp
+AssertThat(x, IsGreaterThanOrEqualTo(5));
+AssertThat(x, Is().GreaterThanOrEqualTo(5));
+```
+
+####LessThanOrEqualTo Constraint
+
+Used to verify that actual is less than or equal to a value.
+
+```cpp
+AssertThat(x, IsLessThanOrEqualTo(6));
+AssertThat(x, Is().LessThanOrEqualTo(6));
+```
+
+### Pointer Constraints
+
+Used to check for `nullptr` equality.
+
+```cpp
+AssertThat(x, IsNull());
+AssertThat(x, Is().Null());
+```
+
### String Constraints
String assertions in Snowhouse are used to verify the values of STL strings (std::string).
@@ -120,7 +147,7 @@ String assertions in Snowhouse are used to verify the values of STL strings (std
Used to verify that actual is equal to an expected value.
```cpp
-Assert:That(actual_str, Equals("foo"));
+AssertThat(actual_str, Equals("foo"));
AssertThat(actual_str, Is().EqualTo("foo"));
```
@@ -336,3 +363,57 @@ AssertThat(42, Is().Fulfilling(IsEvenNumber()));
Your custom matcher should implement a method called Matches() that takes a parameter of the type you expect and returns true if the passed parameter fulfills the constraint.
To get more expressive failure messages, you should also implement the streaming operator as in the example above.
+
+##Getting better output for your types
+
+Whenever Snowhouse prints an error message for a type, it will use the stream operator for that type, otherwise it will print "[unsupported type]"
+as a placeholder.
+
+```cpp
+struct MyType { /*...*/ };
+
+AssertThat(myType, Fulfills(MyConstraint());
+```
+
+Will output the following if the constraint fails:
+
+```bash
+Expected: To fulfill my constraint
+Actual: [unsupported type]
+```
+
+If we add a stream operator:
+
+```cpp
+std::ostream& operator<<(std::ostream& stream, const MyType& a)
+{
+ stream << "MyType( x = " << a.x << " )";
+ return stream;
+}
+```
+
+the output will be a bit more readable:
+
+```bash
+Expected: To fullfill my constraint
+Actual: MyType( x = 23 )
+```
+
+##Configurable Failure Handlers
+
+You can provide Snowhouse with custom failure handlers, for example to call `std::terminate` instead of throwing an exception. See `DefaultFailureHandler` for an example of a failure handler. You can derive your own macros with custom failure handlers using `SNOWHOUSE_ASSERT_THAT` and `SNOWHOUSE_ASSERT_THROWS`. See the definitions of `AssertThat` and `AssertThrows` for examples of these. Define `SNOWHOUSE_NO_MACROS` to disable the unprefixed macros `AssertThat` and `AssertThrows`.
+
+### Example Use Cases
+
+#### Assert Program State
+
+Log an error immediately as we may crash if we try to continue. Don't attempt to unwind the stack as we may be inside a destructor or `nothrow` function. We may want to call `std::terminate`, or attempt to muddle along with the rest of the program.
+
+#### Assert Program State in Safe Builds
+
+As above, but only in debug builds.
+
+#### Test Assert
+
+Assert that a test behaved as expected. Throw an exception and let our testing framework deal with the test failure.
+
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/cross_compile.sh b/vendor/bandit/bandit/assertion_frameworks/snowhouse/cross_compile.sh
new file mode 100755
index 00000000..d3a73279
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/cross_compile.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+STATUS=""
+
+function build_for {
+ local CC=$1
+ local CXX=$2
+ local CXX_VERSION=$3
+
+ echo "Compiling for $CC, $CXX, $CXX_VERSION..."
+
+ if [[ "$CXX_VERSION" == "CXX" ]]; then
+ local SNOWHOUSE_IS_CPP11=OFF
+ else
+ local SNOWHOUSE_IS_CPP11=ON
+ fi
+
+ echo "SNOWHOUSE_IS_CPP11=$SNOWHOUSE_IS_CPP11"
+
+ BUILD_DIR=build-$CC-$CXX_VERSION
+ mkdir $BUILD_DIR
+ pushd $BUILD_DIR
+ CC=$CC CXX=$CXX cmake -DSNOWHOUSE_IS_CPP11=$SNOWHOUSE_IS_CPP11 ../..
+ make
+ STATUS="$STATUS\n$BUILD_DIR - Status: $?"
+ popd
+}
+
+if [[ -d builds ]]; then
+ rm -rf builds
+fi
+
+mkdir builds
+pushd builds
+
+build_for gcc-4.5 g++-4.5 CXX
+build_for gcc-4.6 g++-4.6 CXX
+build_for gcc-4.6 g++-4.6 CXX11
+build_for gcc-4.7 g++-4.7 CXX
+build_for gcc-4.7 g++-4.7 CXX11
+build_for gcc-4.8 g++-4.8 CXX
+build_for gcc-4.8 g++-4.8 CXX11
+build_for gcc-4.9 g++-4.9 CXX
+build_for gcc-4.9 g++-4.9 CXX11
+build_for clang clang++ CXX
+build_for clang clang++ CXX11
+popd
+
+echo "============================================"
+echo -e $STATUS
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/basic_assertions.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/basic_assertions.cpp
new file mode 100644
index 00000000..2766ec0a
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/basic_assertions.cpp
@@ -0,0 +1,228 @@
+#include <stdexcept>
+#include <sstream>
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+void throwRuntimeError() {
+ throw std::runtime_error("This is expected");
+}
+
+struct IgnoreErrors {
+ template <class ExpectedType, class ActualType>
+ static void Handle(const ExpectedType&, const ActualType&, const char*, int)
+ {
+ }
+
+ static void Handle(const std::string&)
+ {
+ }
+};
+
+void BasicAssertions()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " ASSERTIONS " << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "ShouldHandleIntegerEquality" << std::endl;
+ {
+ Assert::That(5, Is().EqualTo(5));
+ }
+
+ std::cout << "ShouldDetectIntegerInequality" << std::endl;
+ {
+ AssertTestFails(Assert::That(5, Is().EqualTo(4)), "equal to 4");
+ }
+
+ std::cout << "ShouldDetectIfNotFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(5, Is().Not().EqualTo(5)), "Expected: not equal to 5\nActual: 5\n");
+ }
+
+ std::cout << "ShouldHandleStrings" << std::endl;
+ {
+ Assert::That(std::string("joakim"), Is().EqualTo(std::string("joakim")));
+ }
+
+ std::cout << "ShouldHandleStringsWithoutExplicitTemplateSpecialization" << std::endl;
+ {
+ Assert::That("kim", Is().EqualTo("kim"));
+ }
+
+ std::cout << "ShouldHandleGreaterThan" << std::endl;
+ {
+ Assert::That(5, Is().GreaterThan(4));
+ }
+
+ std::cout << "ShouldDetectWhenGreaterThanFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(5, Is().GreaterThan(5)),
+ "Expected: greater than 5\nActual: 5\n");
+ }
+
+ std::cout << "ShouldHandleLessThan" << std::endl;
+ {
+ Assert::That(5, Is().LessThan(6));
+ }
+
+ std::cout << "ShouldDetectWhenLessThanFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(6, Is().LessThan(5)),
+ "Expected: less than 5\nActual: 6\n");
+ }
+
+ std::cout << "ShouldThrowExplicitFailureMessage" << std::endl;
+ {
+ AssertTestFails(Assert::Failure("foo"), "foo");
+ }
+
+ std::cout << "Should contain location information" << std::endl;
+ {
+ int line;
+ std::string file;
+
+ try
+ {
+ Assert::That(5, Equals(2), "filename", 32);
+ }
+ catch(const AssertionException& e)
+ {
+ line = e.GetLineNumber();
+ file = e.GetFilename();
+ }
+
+ Assert::That(line, Equals(32));
+ Assert::That(file, Equals("filename"));
+ }
+
+ std::cout << "ShouldEnsureExceptionIsThrown" << std::endl;
+ {
+
+ AssertThrows(std::runtime_error, throwRuntimeError());
+ }
+
+ std::cout << "ShouldIgnoreTheError" << std::endl;
+ {
+ ConfigurableAssert<IgnoreErrors>::That(1, Equals(2));
+ }
+
+ std::cout << "================================================" << std::endl;
+ std::cout << " ASSERTIONS EXPRESSION TEMPLATES" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "ShouldHandleIntegerEquality" << std::endl;
+ {
+ Assert::That(5, Equals(5));
+ }
+
+ std::cout << "ShouldDetectIntegerInequality" << std::endl;
+ {
+ AssertTestFails(Assert::That(5, Equals(4)), "equal to 4");
+ }
+
+ std::cout << "ShouldDetectIfNotFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(5, !Equals(5)),
+ "Expected: not equal to 5\nActual: 5\n");
+ }
+
+ std::cout << "ShouldHandleStrings" << std::endl;
+ {
+ Assert::That(std::string("joakim"), Equals(std::string("joakim")));
+ }
+
+ std::cout << "ShouldHandleStringsWithoutExplicitTemplateSpecialization"
+ << std::endl;
+ {
+ Assert::That("kim", Equals("kim"));
+ }
+
+ std::cout << "ShouldHandleGreaterThan" << std::endl;
+ {
+ Assert::That(5, IsGreaterThan(4));
+ }
+
+ std::cout << "ShouldHandleGreaterThanOrEqualTo" << std::endl;
+ {
+ Assert::That(4, IsGreaterThanOrEqualTo(4));
+ Assert::That(5, IsGreaterThanOrEqualTo(4));
+ }
+
+ std::cout << "ShouldDetectWhenGreaterThanFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(5, IsGreaterThan(5)),
+ "Expected: greater than 5\nActual: 5\n");
+ }
+
+ std::cout << "ShouldDetectWhenGreaterThanOrEqualToFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(4, IsGreaterThanOrEqualTo(5)),
+ "Expected: greater than or equal to 5\nActual: 4\n");
+ }
+
+ std::cout << "ShouldHandleLessThan" << std::endl;
+ {
+ Assert::That(5, IsLessThan(6));
+ }
+
+ std::cout << "ShouldHandleLessThanOrEqualTo" << std::endl;
+ {
+ Assert::That(5, IsLessThanOrEqualTo(6));
+ Assert::That(6, IsLessThanOrEqualTo(6));
+ }
+
+ std::cout << "ShouldDetectWhenLessThanFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(6, IsLessThan(5)),
+ "Expected: less than 5\nActual: 6\n");
+ }
+
+ std::cout << "ShouldDetectWhenLessThanOrEqualToFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(6, IsLessThanOrEqualTo(5)),
+ "Expected: less than or equal to 5\nActual: 6\n");
+ }
+
+#if __cplusplus > 199711L
+ std::cout << "ShouldHandleNull" << std::endl;
+ {
+ Assert::That(nullptr, IsNull());
+ }
+
+ std::cout << "ShouldHandleNull" << std::endl;
+ {
+ Assert::That(nullptr, Is().Null());
+ }
+
+ std::cout << "ShouldHandleNotNull" << std::endl;
+ {
+ int anInt = 0;
+ Assert::That(&anInt, ! IsNull());
+ }
+
+ std::cout << "ShouldDetectWhenIsNullFails" << std::endl;
+ {
+ int anInt = 0;
+ std::ostringstream message;
+ message << "Expected: equal to nullptr\nActual: " << &anInt << "\n";
+ AssertTestFails(Assert::That(&anInt, IsNull()), message.str());
+ }
+
+ std::cout << "ShouldDetectWhenIsNullFails" << std::endl;
+ {
+ int anInt = 0;
+ std::ostringstream message;
+ message << "Expected: equal to nullptr\nActual: " << &anInt << "\n";
+ AssertTestFails(Assert::That(&anInt, Is().Null()), message.str());
+ }
+
+ std::cout << "ShouldDetectWhenIsNotNullFails" << std::endl;
+ {
+ std::ostringstream message;
+ message << "Expected: not equal to nullptr\nActual: nullptr\n";
+
+ AssertTestFails(Assert::That(nullptr, ! IsNull()), message.str());
+ }
+#endif
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/boolean_operators.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/boolean_operators.cpp
new file mode 100644
index 00000000..3e4577a5
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/boolean_operators.cpp
@@ -0,0 +1,48 @@
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+void BooleanOperators()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " Boolean operators" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "ShouldHandleIsFalseOperator" << std::endl;
+ {
+ Assert::That(false, IsFalse());
+ }
+
+ std::cout << "ShouldHandleWhenIsFalseFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(true, IsFalse()), "Expected: false");
+ }
+
+ std::cout << "ShouldHandleIsTrueOperator" << std::endl;
+ {
+ Assert::That(true, IsTrue());
+ }
+
+ std::cout << "ShouldHandleWhenIsTrueFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(false, IsTrue()), "Expected: true");
+ }
+
+ std::cout << "ShouldHandleFluentIsTrue" << std::endl;
+ {
+ Assert::That(true, Is().True());
+ AssertTestFails(Assert::That(false, Is().True()), "Expected: true");
+ }
+
+ std::cout << "ShouldHandleFluentIsFalse" << std::endl;
+ {
+ Assert::That(false, Is().False());
+ AssertTestFails(Assert::That(true, Is().False()), "Expected: false");
+ }
+
+ std::cout << "ShouldTreatAssertWithoutConstraintAsBooleanConstrains" << std::endl;
+ {
+ Assert::That(true);
+ }
+}
+
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/container_spec.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/container_spec.cpp
new file mode 100644
index 00000000..c668dffa
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/container_spec.cpp
@@ -0,0 +1,85 @@
+
+// Copyright Joakim Karlsson & Kim Gräsman 2010-2013.
+// 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)
+
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+struct my_type
+{
+ my_type(int my_val)
+ : my_val_(my_val)
+ {}
+
+ friend bool operator==(const my_type&, const my_type&);
+ friend bool operator!=(const my_type&, const my_type&);
+ friend std::ostream& operator<<(std::ostream&, const my_type&);
+
+ int my_val_;
+};
+
+bool operator==(const my_type& lhs, const my_type& rhs)
+{
+ return lhs.my_val_ == rhs.my_val_;
+}
+
+bool operator!=(const my_type& lhs, const my_type& rhs)
+{
+ return !(lhs == rhs);
+}
+
+std::ostream& operator<<(std::ostream& stream, const my_type& item)
+{
+ stream << "(my_type: my_val_=" << item.my_val_ << " )";
+ return stream;
+}
+
+static bool are_my_types_equal(const my_type& lhs, const my_type& rhs)
+{
+ return lhs.my_val_ == rhs.my_val_;
+}
+
+void ContainerConstraints()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " ContainerContstraints" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "it_should_be_able_to_compare_containers_of_custom_types" << std::endl;
+ {
+ const my_type e[] = {my_type(1), my_type(3)};
+ const std::list<my_type> expected(e, e + sizeof(e) / sizeof(e[0]));
+ std::list<my_type> my_container_;
+ my_container_.push_back(my_type(1));
+ my_container_.push_back(my_type(3));
+
+ AssertThat(my_container_, EqualsContainer(expected));
+ }
+
+ std::cout << "it_should_handle_failing_comparisons" << std::endl;
+ {
+ const my_type e[] = {my_type(1), my_type(2)};
+ const std::list<my_type> expected(e, e + sizeof(e) / sizeof(e[0]));
+ std::list<my_type> my_container_;
+ my_container_.push_back(my_type(1));
+ my_container_.push_back(my_type(3));
+
+ AssertTestFails(Assert::That(my_container_, EqualsContainer(expected)),
+ "Expected: [ (my_type: my_val_=1 ), (my_type: my_val_=2 ) ]");
+ }
+
+ std::cout << "it_should_handle_comparison_with_a_predicate_function" << std::endl;
+ {
+ const my_type e[] = {my_type(1), my_type(3)};
+ const std::list<my_type> expected(e, e + sizeof(e) / sizeof(e[0]));
+ std::list<my_type> my_container_;
+ my_container_.push_back(my_type(1));
+ my_container_.push_back(my_type(3));
+
+ Assert::That(my_container_, EqualsContainer(expected, are_my_types_equal));
+ Assert::That(my_container_, Is().EqualToContainer(expected, are_my_types_equal));
+ }
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/custom_matchers_test.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/custom_matchers_test.cpp
new file mode 100644
index 00000000..c5437f9f
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/custom_matchers_test.cpp
@@ -0,0 +1,69 @@
+
+// Copyright Joakim Karlsson & Kim Gräsman 2010-2013.
+// 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)
+
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+struct IsEvenNumberNoStreamOperator
+{
+ bool Matches(const int actual) const
+ {
+ return (actual % 2) == 0;
+ }
+};
+
+struct IsEvenNumberWithStreamOperator
+{
+ bool Matches(const int actual) const
+ {
+ return (actual % 2) == 0;
+ }
+
+ friend std::ostream& operator<<(std::ostream& stm,
+ const IsEvenNumberWithStreamOperator& );
+};
+
+std::ostream& operator<<(std::ostream& stm,
+ const IsEvenNumberWithStreamOperator& )
+{
+ stm << "An even number";
+ return stm;
+}
+
+void CustomMatchers()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " CustomMatchersNoStreamOperator" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "CanHandleCustomMatcher" << std::endl;
+ {
+ Assert::That(2, Fulfills(IsEvenNumberNoStreamOperator()));
+ }
+
+ std::cout << "CustomMatcherWithFluent" << std::endl;
+ {
+ Assert::That(2, Is().Fulfilling(IsEvenNumberNoStreamOperator()));
+ }
+
+ std::cout << "OutputsCorrectMessageWhenFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(3, Fulfills(IsEvenNumberNoStreamOperator())),
+ "Expected: [unsupported type]\nActual: 3");
+ }
+
+
+ std::cout << "================================================" << std::endl;
+ std::cout << "CustomMatcherWithStreamOperator" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "ErrorMessageUsesCustomStreamOperatorIfAvailable" << std::endl;
+ {
+ AssertTestFails(Assert::That(3, Fulfills(IsEvenNumberWithStreamOperator())),
+ "Expected: An even number\nActual: 3");
+ }
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/exceptions_tests.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/exceptions_tests.cpp
new file mode 100644
index 00000000..0f1ac2ab
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/exceptions_tests.cpp
@@ -0,0 +1,97 @@
+
+// Copyright Joakim Karlsson & Kim Gräsman 2010-2013.
+// 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)
+
+#include <snowhouse/snowhouse.h>
+#include <stdexcept>
+using namespace snowhouse;
+
+#include "tests.h"
+
+class ClassWithExceptions
+{
+public:
+ int LogicError()
+ {
+ throw std::logic_error("not logical!");
+ }
+
+ double RangeError()
+ {
+ throw std::range_error("range error!");
+ }
+
+ void NoError()
+ {
+ }
+};
+
+void ExceptionTests()
+{
+ ClassWithExceptions objectUnderTest;
+
+ std::cout << "================================================" << std::endl;
+ std::cout << " ExceptionTests" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+
+ std::cout << "CanDetectExceptions" << std::endl;
+ {
+ AssertThrows(std::exception, objectUnderTest.LogicError());
+ }
+
+ std::cout << "CanAssertOnLastException" << std::endl;
+ {
+ AssertThrows(std::logic_error, objectUnderTest.LogicError());
+ Assert::That(LastException<std::logic_error>().what(), Contains("not logical!"));
+ }
+
+ std::cout << "CanDetectWhenWrongExceptionIsThrown" << std::endl;
+ {
+ AssertTestFails(AssertThrows(std::logic_error, objectUnderTest.RangeError()), "Wrong exception");
+ }
+
+ std::cout << "CanPrintExpectedExceptionTypeWhenWrongExceptionIsThrown" << std::endl;
+ {
+ AssertTestFails(AssertThrows(std::logic_error, objectUnderTest.RangeError()), "Expected std::logic_error");
+ }
+
+ std::cout << "CanHaveSeveralExceptionAssertionsInSameSpec" << std::endl;
+ {
+ AssertThrows(std::logic_error, objectUnderTest.LogicError());
+ Assert::That(LastException<std::logic_error>().what(), Contains("not logical!"));
+
+ AssertThrows(std::range_error, objectUnderTest.RangeError());
+ Assert::That(LastException<std::range_error>().what(), Contains("range error!"));
+ }
+
+ std::cout << "CanHaveSeveralExceptionAssertionForTheSameExceptionInSameSpec" << std::endl;
+ {
+ AssertThrows(std::logic_error, objectUnderTest.LogicError());
+ Assert::That(LastException<std::logic_error>().what(), Contains("not logical!"));
+
+ AssertThrows(std::logic_error, objectUnderTest.LogicError());
+ Assert::That(LastException<std::logic_error>().what(), Contains("not logical!"));
+ }
+
+ std::cout << "CanDetectWhenNoExceptionIsThrown" << std::endl;
+ {
+ AssertTestFails(AssertThrows(std::logic_error, objectUnderTest.NoError()), "No exception");
+ }
+
+ std::cout << "CanPrintExpectedExceptionWhenNoExceptionIsThrown" << std::endl;
+ {
+ AssertTestFails(AssertThrows(std::logic_error, objectUnderTest.NoError()), "Expected std::logic_error");
+ }
+
+ std::cout << "ExceptionsAreDestoryedWhenWeExitScope" << std::endl;
+ {
+ {
+ AssertThrows(std::logic_error, objectUnderTest.LogicError());
+ }
+ AssertThrows(AssertionException, LastException<std::logic_error>());
+ Assert::That(LastException<AssertionException>().GetMessage(), Contains("No exception was stored"));
+ }
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/expression_error_handling.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/expression_error_handling.cpp
new file mode 100644
index 00000000..de96f038
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/expression_error_handling.cpp
@@ -0,0 +1,28 @@
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+void ExpressionErrorHandling()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " ExpressionErrorHandling" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::vector<int> collection;
+ collection.push_back(1);
+ collection.push_back(2);
+ collection.push_back(3);
+
+ std::cout << "AnInvalidAllOperationShouldBeReportedProperly" << std::endl;
+ {
+ AssertTestFails(Assert::That(collection, Has().All()),
+ "The expression after \"all\" operator does not yield any result");
+ }
+
+ std::cout << "AnInvalidAtLeastOperationShouldBeReportedProperly" << std::endl;
+ {
+ AssertTestFails(Assert::That(collection, Has().AtLeast(2)),
+ "The expression after \"at least 2\" operator does not yield any result");
+ }
+
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/main.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/main.cpp
index 4153ec7f..616b97ff 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/main.cpp
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/main.cpp
@@ -1,20 +1,42 @@
#include <snowhouse/snowhouse.h>
-
using namespace snowhouse;
+#include "tests.h"
+
+void BooleanOperators();
+void BasicAssertions();
+void ContainerConstraints();
+void CustomMatchers();
+void ExceptionTests();
+void ExpressionErrorHandling();
+void MapTests();
+void OperatorTests();
+void SequenceContainerTests();
+void StringLineTests();
+void StringTests();
+void StringizeTests();
int main()
{
- std::cout << "Testing that 23 is 23" << std::endl;
- Assert::That(23, Is().EqualTo(23));
-
try
{
- AssertThat(12, Is().LessThan(11).And().GreaterThan(99));
+ BasicAssertions();
+ BooleanOperators();
+ ContainerConstraints();
+ CustomMatchers();
+ ExceptionTests();
+ ExpressionErrorHandling();
+ MapTests();
+ OperatorTests();
+ SequenceContainerTests();
+ StringLineTests();
+ StringTests();
+ StringizeTests();
}
- catch(const AssertionException& ex)
+ catch(const AssertionException& e)
{
- std::cout << "Apparently this failed:" << std::endl;
- std::cout << ex.GetMessage() << std::endl;
+ std::cout << "Tests failed!" << std::endl;
+ std::cout << e.GetMessage() << std::endl;
+ return 1;
}
return 0;
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/map_tests.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/map_tests.cpp
new file mode 100644
index 00000000..813b5011
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/map_tests.cpp
@@ -0,0 +1,38 @@
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+void MapTests()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " MapTests" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::map<std::string, int> ages;
+ ages["joakim"] = 38;
+ ages["maria"] = 36;
+ ages["hanna"] = 6;
+ ages["moa"] = 4;
+
+ std::cout << "ContainingShouldDetermineIfKeyExists" << std::endl;
+ {
+ Assert::That(ages, Is().Containing("joakim"));
+ }
+
+ std::cout << "ShouldGiveAProperMessageWhenContainingFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(ages, Is().Not().Containing("hanna")),
+ "Expected: not contains hanna");
+ }
+
+ std::cout << "ContainingShouldDetermineIfKeyExists" << std::endl;
+ {
+ Assert::That(ages, Contains("joakim"));
+ }
+
+ std::cout << "ShouldGiveAProperMessageWhenContainingFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(ages, !Contains("hanna")),
+ "Expected: not contains hanna");
+ }
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/operator_tests.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/operator_tests.cpp
new file mode 100644
index 00000000..3d11ae07
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/operator_tests.cpp
@@ -0,0 +1,137 @@
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+void OperatorTests()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " OperatorTests" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "ShouldHandleAndOperatorExpressionTemplates" << std::endl;
+ {
+ Assert::That(5, IsLessThan(6) && IsGreaterThan(4));
+ }
+
+ std::cout << "ShouldHandleAndOperator" << std::endl;
+ {
+ Assert::That(5, Is().LessThan(6).And().GreaterThan(4));
+ }
+
+ std::cout << "ShouldHandleAndOperatorFailExpressionTemplates" << std::endl;
+ {
+ AssertTestFails(Assert::That(5, IsLessThan(7) && IsGreaterThan(5)),
+ "less than 7 and greater than 5");
+ }
+
+ std::cout << "ShouldHandleAndOperatorFail" << std::endl;
+ {
+ AssertTestFails(Assert::That(5, Is().LessThan(7).And().GreaterThan(5)),
+ "less than 7 and greater than 5");
+ }
+
+ std::cout << "ShouldHandleOrOperator" << std::endl;
+ {
+ Assert::That(12, Is().LessThan(7).Or().GreaterThan(5));
+ }
+
+ std::cout << "ShouldHandleOrOperatorExpressionTemplates" << std::endl;
+ {
+ Assert::That(12, IsLessThan(7) || IsGreaterThan(5));
+ }
+
+ std::cout << "ShouldHandleOrOperatorFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(67, Is().LessThan(12).Or().GreaterThan(99)),
+ "less than 12 or greater than 99");
+ }
+
+ std::cout << "ShouldHandleOrOperatorFailsExpressionTemplates" << std::endl;
+ {
+ AssertTestFails(Assert::That(67, IsLessThan(12) || IsGreaterThan(99)),
+ "less than 12 or greater than 99");
+ }
+
+ std::cout << "ShouldHandleNotOperators" << std::endl;
+ {
+ Assert::That(5, Is().Not().EqualTo(4));
+ }
+
+ std::cout << "ShouldHandleNotOperatorsExpressionTemplates" << std::endl;
+ {
+ Assert::That(5, !Equals(4));
+ }
+
+ std::cout << "ShouldHandleNotOperatorsFails" << std::endl;
+ {
+ AssertTestFails(Assert::That(12, Is().Not().EqualTo(12)), "not equal to 12");
+ }
+
+ std::cout << "ShouldHandleNotOperatorsFailsExpressionTemplates" << std::endl;
+ {
+ AssertTestFails(Assert::That(12, !Equals(12)), "not equal to 12");
+ }
+
+ std::cout << "ShouldHandleNotOperatorsForStrings" << std::endl;
+ {
+ Assert::That("joakim", Is().Not().EqualTo("harry"));
+ }
+
+ std::cout << "ShouldHandleNotOperatorsForStringsExpressionTemplates" << std::endl;
+ {
+ Assert::That("joakim", !Equals("harry"));
+ }
+
+ std::cout << "ShouldHandleBothLeftAndRightAssociativeOperators" << std::endl;
+ {
+ Assert::That(5, Is().GreaterThan(4).And().Not().LessThan(3));
+ }
+
+ std::cout << "ShouldHandleBothLeftAndRightAssociativeOperatorsExpressionTemplates" << std::endl;
+ {
+ Assert::That(5, IsGreaterThan(4)&& !IsLessThan(3));
+ }
+
+ std::cout << "MalformedExpressionYieldsError" << std::endl;
+ {
+ AssertTestFails(Assert::That(4, Is().Not()),
+ "The expression contains a not operator without any operand");
+ }
+
+ std::cout <<
+ "EqualsWithDeltaOperator_should_fail_for_actual_larger_than_delta"
+ << std::endl;
+ {
+ AssertTestFails(Assert::That(3.9, EqualsWithDelta(3, 0.5)),
+ "Expected: equal to 3 (+/- 0.5)");
+ }
+
+ std::cout << "EqualsWithDeltaOperator_should_fail_for_actual_less_than_delta" << std::endl;
+ {
+ AssertTestFails(Assert::That(2.49, EqualsWithDelta(3, 0.5)),
+ "Expected: equal to 3 (+/- 0.5)");
+ }
+
+ std::cout << "EqualsWithDeltaOperator_should_succeed" << std::endl;
+ {
+ Assert::That(2, EqualsWithDelta(1.9, 0.1));
+ }
+
+ std::cout << "Fluent_equals_with_delta_should_fail_for_actual_larger_than_delta" << std::endl;
+ {
+ AssertTestFails(Assert::That(3.9, Is().EqualToWithDelta(3, 0.5)),
+ "Expected: equal to 3 (+/- 0.5)");
+ }
+
+ std::cout << "Fluent_EqualsWithDeltaOperator_should_fail_for_actual_less_than_delta" << std::endl;
+ {
+ AssertTestFails(Assert::That(2.49, Is().EqualToWithDelta(3, 0.5)),
+ "Expected: equal to 3 (+/- 0.5)");
+ }
+
+ std::cout << "Fluent_EqualsWithDeltaOperator_should_succeed" << std::endl;
+ {
+ Assert::That(2, Is().EqualToWithDelta(1.9, 0.1));
+ }
+
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/sequence_container_tests.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/sequence_container_tests.cpp
new file mode 100644
index 00000000..c090cc58
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/sequence_container_tests.cpp
@@ -0,0 +1,192 @@
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+
+template <typename T>
+void SequenceContainerActual()
+{
+ const char* ExpectedActual = "\nActual: [ 1, 2, 3, 5, 8 ]";
+
+ T container;
+ container.clear();
+ container.push_back(1);
+ container.push_back(2);
+ container.push_back(3);
+ container.push_back(5);
+ container.push_back(8);
+
+ std::cout << "ShouldHandleAllOperator" << std::endl;
+ {
+ Assert::That(container, Has().All().GreaterThan(1).Or().LessThan(4));
+ }
+
+ std::cout << "ShouldHandleFailingAllOperator" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Has().All().GreaterThan(4)), std::string("Expected: all greater than 4") + ExpectedActual);
+ }
+
+ std::cout << "SHouldHandleInvalidExpressionAfterAllOperator" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Has().All().Not()), "The expression contains a not operator without any operand");
+ }
+
+ std::cout << "ShouldHandleNoExpressionAfterAllOperator" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Has().All()), "The expression after \"all\" operator does not yield any result");
+ }
+
+ std::cout << "ShouldHandleAtLeastOperator" << std::endl;
+ {
+ Assert::That(container, Has().AtLeast(1).LessThan(5));
+ }
+
+ std::cout << "ShouldHandleFailingAtLeastOperator" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Has().AtLeast(2).LessThan(2)), std::string("Expected: at least 2 less than 2") + ExpectedActual);
+ }
+
+ std::cout << "ShouldHandleExactlyOperator" << std::endl;
+ {
+ Assert::That(container, Has().Exactly(1).EqualTo(3));
+ }
+
+ std::cout << "ShouldHandleFailingExactlyOperator" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Has().Exactly(2).EqualTo(3)), std::string("Expected: exactly 2 equal to 3") + ExpectedActual);
+ }
+
+ std::cout << "ShouldHandleAtMostOperator" << std::endl;
+ {
+ Assert::That(container, Has().AtMost(1).EqualTo(5));
+ }
+
+ std::cout << "ShouldHandleFailingAtMostOperator" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Has().AtMost(1).EqualTo(3).Or().EqualTo(5)), std::string("Expected: at most 1 equal to 3 or equal to 5") + ExpectedActual);
+ }
+
+ std::cout << "ShouldHandleNoneOperator" << std::endl;
+ {
+ Assert::That(container, Has().None().EqualTo(666));
+ }
+
+ std::cout << "ShouldHandleFailingNoneOperator" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Has().None().EqualTo(5)), std::string("Expected: none equal to 5") + ExpectedActual);
+ }
+
+ std::cout << "ShouldHandleContaining" << std::endl;
+ {
+ Assert::That(container, Contains(3));
+ }
+
+ std::cout << "ShouldDetectFailingContains" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Contains(99)), std::string("contains 99") + ExpectedActual);
+ }
+
+ std::cout << "ShouldHandleOfLength" << std::endl;
+ {
+ Assert::That(container, HasLength(5));
+ }
+
+ std::cout << "ShouldHandleFailingOfLength" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, HasLength(7)), std::string("of length 7") + ExpectedActual);
+ }
+
+ std::cout << "ShouldHandleContaining_ExpressionTemplates" << std::endl;
+ {
+ Assert::That(container, Contains(3));
+ }
+
+ std::cout << "ShouldDetectFailingContains_ExpressionTemplates" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Contains(99)), std::string("contains 99") + ExpectedActual);
+ }
+
+ std::cout << "ShouldHandleOfLength_ExpressionTemplates" << std::endl;
+ {
+ Assert::That(container, HasLength(5));
+ }
+
+ std::cout << "ShouldHandleFailingOfLengthForVectors" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, HasLength(7)), std::string("of length 7") + ExpectedActual);
+ }
+
+ std::cout << "ShouldHandleIsEmpty" << std::endl;
+ {
+ T is_empty;
+
+ Assert::That(is_empty, IsEmpty());
+ }
+
+ std::cout << "ShouldHandleFailingIsEmpty" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, IsEmpty()), "of length 0");
+ }
+
+ std::cout << "ShouldHandleFluentIsEmpty" << std::endl;
+ {
+ T is_empty;
+
+ Assert::That(is_empty, Is().Empty());
+ }
+
+ std::cout << "ShouldHandleFailingFluentIsEmpty" << std::endl;
+ {
+ AssertTestFails(Assert::That(container, Is().Empty()), "of length 0");
+ }
+
+ std::cout << "ShouldHandlerEqualsContainer" << std::endl;
+ {
+ std::list<int> expected;
+ expected.assign(container.begin(), container.end());
+
+ AssertThat(container, EqualsContainer(expected));
+ }
+
+ std::cout << "ShouldHandleEqualsContainer_Fluent" << std::endl;
+ {
+ std::list<int> expected;
+ expected.assign(container.begin(), container.end());
+
+ AssertThat(container, Is().EqualToContainer(expected));
+ }
+
+ std::cout << "ShouldHandleFailingEqualsContainer" << std::endl;
+ {
+ const int e[] = {4, 2, 4};
+ std::list<int> expected(e, e + sizeof(e) / sizeof(e[0]));
+
+ AssertTestFails(Assert::That(container, EqualsContainer(expected)), "Expected: [ 4, 2, 4 ]");
+ }
+
+ std::cout << "ShouldHandleFailingEqualsContainer_Fluent" << std::endl;
+ {
+ const int e[] = {4, 2, 4};
+ std::list<int> expected(e, e + sizeof(e) / sizeof(e[0]));
+
+ AssertTestFails(Assert::That(container, Is().EqualToContainer(expected)), "Expected: [ 4, 2, 4 ]");
+ }
+}
+
+void SequenceContainerTests()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " SequenceContainerTests(vector)" << std::endl;
+ std::cout << "================================================" << std::endl;
+ SequenceContainerActual<std::vector<int> >();
+
+ std::cout << "================================================" << std::endl;
+ std::cout << " SequenceContainerTests(list)" << std::endl;
+ std::cout << "================================================" << std::endl;
+ SequenceContainerActual<std::list<int> >();
+
+ std::cout << "================================================" << std::endl;
+ std::cout << " SequenceContainerTests(deque)" << std::endl;
+ std::cout << "================================================" << std::endl;
+ SequenceContainerActual<std::deque<int> >();
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/string_line_tests.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/string_line_tests.cpp
new file mode 100644
index 00000000..8cf90cfb
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/string_line_tests.cpp
@@ -0,0 +1,179 @@
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+void StringLineTests()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " StringLineTests" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "CanAssertThatAtLeastOneLineInAStreamMatches" << std::endl;
+ {
+ Assert::That("First line\n", Has().AtLeast(1).EqualTo("First line"));
+ }
+
+ std::cout << "CanDetectWhenAssertionFails" << std::endl;
+ {
+ AssertTestFails(Assert::That("First line\n", Has().AtLeast(1).EqualTo("Second line")), "Expected: at least 1 equal to Second line");
+ }
+
+ std::cout << "CanHandleLineMissingNewline" << std::endl;
+ {
+ Assert::That("First line", Has().AtLeast(1).EqualTo("First line"));
+ }
+
+ std::cout << "CanHandleSeveralLines" << std::endl;
+ {
+ std::string lines = "First line\nSecond line";
+ Assert::That(lines, Has().Exactly(2).EndingWith("line"));
+ }
+
+ std::cout << "CanHandleWindowsLineEndings" << std::endl;
+ {
+ std::string lines = "First line\r\nSecond line\r\nThird line";
+ Assert::That(lines, Has().Exactly(3).EndingWith("line"));
+ }
+
+ std::cout << "CanMatchBeginningOfLinesWithWindowsLineEndings" << std::endl;
+ {
+ std::string lines = "First line\nSecond line\r\nThird line";
+ Assert::That(lines, Has().Exactly(1).StartingWith("Second"));
+ }
+
+ std::cout << "CanHandleEmptyLinesWhenUsingWindowsLineEndings" << std::endl;
+ {
+ std::string lines = "\r\nSecond line\r\n\r\n";
+ Assert::That(lines, Has().Exactly(2).OfLength(0));
+ }
+
+ std::cout << "CanHandleLastLineMissingNewlineForWindowsLineEndings" << std::endl;
+ {
+ std::string lines = "First line\r\nSecond line";
+ Assert::That(lines, Has().Exactly(2).EndingWith("line"));
+ }
+
+ std::cout << "CanHandleAllEmptyLines" << std::endl;
+ {
+ Assert::That("\n\n\n\n\n\n", Has().Exactly(6).OfLength(0));
+ }
+
+ std::cout << "CanHandleAllEmptyLinesWithWindowsLineEndings" << std::endl;
+ {
+ Assert::That("\r\n\r\n\r\n", Has().Exactly(3).OfLength(0));
+ }
+
+
+ std::cout << "================================================" << std::endl;
+ std::cout << " StringLineParserTests" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+
+ std::cout << "CanParseEmptyString" << std::endl;
+ {
+ std::vector<std::string> res;
+
+ StringLineParser::Parse("", res);
+
+ Assert::That(res, HasLength(0));
+ }
+
+ std::cout << "CanParseSingleLine" << std::endl;
+ {
+ std::vector<std::string> res;
+
+ StringLineParser::Parse("Simple line", res);
+
+ Assert::That(res, HasLength(1));
+ Assert::That(res, Has().Exactly(1).EqualTo("Simple line"));
+ }
+
+ std::cout << "CanParseTwoLines" << std::endl;
+ {
+ std::vector<std::string> res;
+
+ StringLineParser::Parse("One line\nTwo lines", res);
+
+ Assert::That(res, HasLength(2));
+ Assert::That(res, Has().Exactly(1).EqualTo("One line"));
+ Assert::That(res, Has().Exactly(1).EqualTo("Two lines"));
+ }
+
+ std::cout << "CanParseThreeLines" << std::endl;
+ {
+ std::vector<std::string> res;
+
+ StringLineParser::Parse("One line\nTwo lines\nThree lines", res);
+
+ Assert::That(res, HasLength(3));
+ Assert::That(res, Has().Exactly(1).EqualTo("One line"));
+ Assert::That(res, Has().Exactly(1).EqualTo("Two lines"));
+ Assert::That(res, Has().Exactly(1).EqualTo("Three lines"));
+ }
+
+ std::cout << "CanHandleStringEndingWithNewline" << std::endl;
+ {
+ std::vector<std::string> res;
+ StringLineParser::Parse("One line\n", res);
+ Assert::That(res, HasLength(1));
+ Assert::That(res, Has().Exactly(1).EqualTo("One line"));
+ }
+
+ std::cout << "CanHandleSingleLineWithWindowsLineEnding" << std::endl;
+ {
+ std::vector<std::string> res;
+ StringLineParser::Parse("One line\r\n", res);
+ Assert::That(res, HasLength(1));
+ Assert::That(res, Has().Exactly(1).EqualTo("One line"));
+ }
+
+ std::cout << "CanHandleTwoLinesWithWindowsLineEndings" << std::endl;
+ {
+ std::vector<std::string> res;
+ StringLineParser::Parse("One line\r\nTwo lines", res);
+ Assert::That(res, HasLength(2));
+ Assert::That(res, Has().Exactly(1).EqualTo("One line"));
+ Assert::That(res, Has().Exactly(1).EqualTo("Two lines"));
+ }
+
+ std::cout << "CanHandleEmptyLineWithNewline" << std::endl;
+ {
+ std::vector<std::string> res;
+ StringLineParser::Parse("\n", res);
+ Assert::That(res, Is().OfLength(1).And().Exactly(1).OfLength(0));
+ }
+
+ std::cout << "CanHandleTwoEmptyLines" << std::endl;
+ {
+ std::vector<std::string> res;
+ StringLineParser::Parse("\n\n", res);
+ Assert::That(res, HasLength(2));
+ Assert::That(res, Has().Exactly(2).OfLength(0));
+ }
+
+ std::cout << "CanHandleTwoEmptyLinesWithWindowsLineEndings" << std::endl;
+ {
+ std::vector<std::string> res;
+ StringLineParser::Parse("\r\n\r\n", res);
+ Assert::That(res, HasLength(2));
+ Assert::That(res, Has().Exactly(2).OfLength(0));
+ }
+
+ std::cout << "CanHandleCarriageReturnOnly" << std::endl;
+ {
+ std::vector<std::string> res;
+ StringLineParser::Parse("One line\rTwo lines", res);
+ Assert::That(res, HasLength(2));
+ Assert::That(res, Has().Exactly(1).EqualTo("One line"));
+ Assert::That(res, Has().Exactly(1).EqualTo("Two lines"));
+ }
+
+ std::cout << "CanHandleCarriageReturnOnlyAtEndOfString" << std::endl;
+ {
+ std::vector<std::string> res;
+ StringLineParser::Parse("One line\r\nTwo lines\r", res);
+ Assert::That(res, HasLength(2));
+ Assert::That(res, Has().Exactly(1).EqualTo("One line"));
+ Assert::That(res, Has().Exactly(1).EqualTo("Two lines"));
+ }
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/string_tests.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/string_tests.cpp
new file mode 100644
index 00000000..989ad42b
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/string_tests.cpp
@@ -0,0 +1,65 @@
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+void StringTests()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " StringTests" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "ShouldHandleStringContainsConstraint" << std::endl;
+ {
+ Assert::That("abcdef", Contains("bcde"));
+ }
+
+ std::cout << "StringConstraintShouldHandleMatchAtBeginningOfString" << std::endl;
+ {
+ Assert::That("abcdef", Contains("a"));
+ }
+
+ std::cout << "ShouldDetectFailingContains" << std::endl;
+ {
+ AssertTestFails(Assert::That("abcdef", Contains("hello")), "contains hello");
+ }
+
+ std::cout << "ShouldHandleStringStartingWithConstraint" << std::endl;
+ {
+ Assert::That("abcdef", StartsWith("abc"));
+ }
+
+ std::cout << "ShouldHandleStringEndingWithConstraint" << std::endl;
+ {
+ Assert::That("abcdef", EndsWith("def"));
+ }
+
+ std::cout << "ShouldHandleOperatorsForStrings" << std::endl;
+ {
+ Assert::That("abcdef", StartsWith("ab") && EndsWith("ef"));
+ }
+
+ std::cout << "ShouldHandleStringsWithMultipleOperators" << std::endl;
+ {
+ Assert::That("abcdef", StartsWith("ab") && !EndsWith("qwqw"));
+ }
+
+ std::cout << "ShouldHandleOfLength" << std::endl;
+ {
+ Assert::That("12345", HasLength(5));
+ }
+
+ std::cout << "ShouldHandleWeirdLongExpressions" << std::endl;
+ {
+ Assert::That("12345", HasLength(5) && StartsWith("123") && !EndsWith("zyxxy"));
+ }
+
+ std::cout << "ShouldHandleStdStrings" << std::endl;
+ {
+ Assert::That("12345", Contains(std::string("23")));
+ }
+
+ std::cout << "ShouldHandleSimpleChar" << std::endl;
+ {
+ Assert::That("12345", StartsWith('1'));
+ }
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/stringize_tests.cpp b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/stringize_tests.cpp
new file mode 100644
index 00000000..a0971274
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/stringize_tests.cpp
@@ -0,0 +1,111 @@
+#include <snowhouse/snowhouse.h>
+using namespace snowhouse;
+#include "tests.h"
+
+namespace
+{
+ // No overload for operator<<(std::ostream&) or specialization of igloo::Stringizer
+ struct WithoutStreamOperator
+ {
+ WithoutStreamOperator(int id)
+ : m_id(id)
+ {
+ }
+
+ bool operator==(const WithoutStreamOperator& rhs) const
+ {
+ return m_id == rhs.m_id;
+ }
+
+ int m_id;
+ };
+
+ // Has operator<<(std::ostream&)
+ struct WithStreamOperator : public WithoutStreamOperator
+ {
+ WithStreamOperator(int id)
+ : WithoutStreamOperator(id)
+ {
+ }
+ };
+
+ std::ostream& operator<<(std::ostream& stream, const WithStreamOperator& a)
+ {
+ stream << a.m_id;
+ return stream;
+ }
+
+ // Has no operator<<(std::ostream&), but a specialization of igloo::Stringizer
+ struct WithoutStreamOperatorButWithStringizer : public WithoutStreamOperator
+ {
+ WithoutStreamOperatorButWithStringizer(int id)
+ : WithoutStreamOperator(id)
+ {
+ }
+ };
+}
+
+namespace snowhouse {
+
+ template<>
+ struct Stringizer< WithoutStreamOperatorButWithStringizer >
+ {
+ static std::string ToString(const WithoutStreamOperatorButWithStringizer& value)
+ {
+ return snowhouse::Stringize(value.m_id);
+ }
+ };
+}
+
+void StringizeTests()
+{
+ std::cout << "================================================" << std::endl;
+ std::cout << " StringizeTests" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "ShouldHandleTypesWithStreamOperators" << std::endl;
+ {
+ WithStreamOperator a(12);
+ WithStreamOperator b(13);
+ AssertTestFails(Assert::That(a, Is().EqualTo(b)), "Expected: equal to 13\nActual: 12");
+ }
+
+ std::cout << "ShouldHandleTypesWithoutStreamOperators" << std::endl;
+ {
+ WithoutStreamOperator a(12);
+ WithoutStreamOperator b(13);
+ AssertTestFails(Assert::That(a, Is().EqualTo(b)), "Expected: equal to [unsupported type]\nActual: [unsupported type]");
+ }
+
+ std::cout << "ShouldHandleTypesWithTraits" << std::endl;
+ {
+ WithoutStreamOperatorButWithStringizer a(12);
+ WithoutStreamOperatorButWithStringizer b(13);
+ AssertTestFails(Assert::That(a, Is().EqualTo(b)), "Expected: equal to 13\nActual: 12");
+ }
+
+ std::cout << "================================================" << std::endl;
+ std::cout << " StringizeTestsExpressionTemplates" << std::endl;
+ std::cout << "================================================" << std::endl;
+
+ std::cout << "ShouldHandleTypesWithStreamOperators" << std::endl;
+ {
+ WithStreamOperator a(12);
+ WithStreamOperator b(13);
+ AssertTestFails(Assert::That(a, Equals(b)), "Expected: equal to 13\nActual: 12");
+ }
+
+ std::cout << "ShouldHandleTypesWithoutStreamOperators" << std::endl;
+ {
+ WithoutStreamOperator a(12);
+ WithoutStreamOperator b(13);
+ AssertTestFails(Assert::That(a, Equals(b)), "Expected: equal to [unsupported type]\nActual: [unsupported type]");
+ }
+
+ std::cout << "ShouldHandleTypesWithTraits" << std::endl;
+ {
+ WithoutStreamOperatorButWithStringizer a(12);
+ WithoutStreamOperatorButWithStringizer b(13);
+ AssertTestFails(Assert::That(a, Is().EqualTo(b)), "Expected: equal to 13\nActual: 12");
+ }
+}
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/tests.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/tests.h
new file mode 100644
index 00000000..9dd1d28c
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/example/tests.h
@@ -0,0 +1,16 @@
+#ifndef SNOWHOUSE_EXAMPLES_TEST_H
+#define SNOWHOUSE_EXAMPLES_TEST_H
+
+#define AssertTestFails(assertion, expected_error_text) \
+ std::string IGLOO_INTERNAL_expected_error = "Test did not fail"; \
+ try \
+ { \
+ assertion; \
+ } \
+ catch(const AssertionException& exception_from_igloo_assertion) \
+ { \
+ IGLOO_INTERNAL_expected_error = exception_from_igloo_assertion.GetMessage(); \
+ } \
+ Assert::That(IGLOO_INTERNAL_expected_error, Is().Containing(expected_error_text));
+
+#endif
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assert.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assert.h
index e25bf501..64981094 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assert.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assert.h
@@ -12,7 +12,27 @@
namespace snowhouse {
- class Assert
+ struct DefaultFailureHandler
+ {
+ template <class ExpectedType, class ActualType>
+ static void Handle(const ExpectedType& expected, const ActualType& actual, const char* file_name, int line_number)
+ {
+ std::ostringstream str;
+
+ str << "Expected: " << snowhouse::Stringize(expected) << std::endl;
+ str << "Actual: " << snowhouse::Stringize(actual) << std::endl;
+
+ throw AssertionException(str.str(), file_name, line_number);
+ }
+
+ static void Handle(const std::string& message)
+ {
+ throw AssertionException(message);
+ }
+ };
+
+ template<typename FailureHandler>
+ class ConfigurableAssert
{
public:
@@ -22,7 +42,7 @@ namespace snowhouse {
const char* no_file = "";
int line_number = 0;
- Assert::That(actual, expression, no_file, line_number);
+ ConfigurableAssert<FailureHandler>::That(actual, expression, no_file, line_number);
}
template <typename ActualType, typename ConstraintListType>
@@ -48,12 +68,12 @@ namespace snowhouse {
if (!result.top())
{
- throw AssertionException(CreateErrorText(expression, actual), file_name, line_number);
+ FailureHandler::Handle(expression, actual, file_name, line_number);
}
}
catch (const InvalidExpressionException& e)
{
- throw AssertionException("Malformed expression: \"" + snowhouse::Stringize(expression) + "\"\n" + e.Message());
+ FailureHandler::Handle("Malformed expression: \"" + snowhouse::Stringize(expression) + "\"\n" + e.Message());
}
}
@@ -76,7 +96,7 @@ namespace snowhouse {
{
if (!expression(actual))
{
- throw AssertionException(CreateErrorText(expression, actual), file_name, line_number);
+ FailureHandler::Handle(expression, actual, file_name, line_number);
}
}
@@ -90,27 +110,17 @@ namespace snowhouse {
{
if (!actual)
{
- throw AssertionException("Expected: true\nActual: false");
+ FailureHandler::Handle("Expected: true\nActual: false");
}
}
static void Failure(const std::string& message)
{
- throw AssertionException(message);
- }
-
- private:
- template <class ExpectedType, class ActualType>
- static std::string CreateErrorText(const ExpectedType& expected, const ActualType& actual)
- {
- std::ostringstream str;
-
- str << "Expected: " << snowhouse::Stringize(expected) << std::endl;
- str << "Actual: " << snowhouse::Stringize(actual) << std::endl;
-
- return str.str();
+ FailureHandler::Handle(message);
}
};
+
+ typedef ConfigurableAssert<DefaultFailureHandler> Assert;
}
#endif // IGLOO_ASSERT_H
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertionexception.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertionexception.h
index 77890a7e..d0747742 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertionexception.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertionexception.h
@@ -19,9 +19,19 @@ namespace snowhouse {
: m_message(message), m_fileName(fileName), m_line(line)
{}
+#if __cplusplus > 199711L
+ AssertionException(const AssertionException&) = default;
+#endif
+
+#if __cplusplus > 199711L
+ virtual ~AssertionException() noexcept
+ {
+ }
+#else
virtual ~AssertionException() throw()
{
}
+#endif
std::string GetMessage() const
{
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h
index 6ebdfe1f..df5b4b34 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h
@@ -9,7 +9,14 @@
#include "assert.h"
+#define SNOWHOUSE_ASSERT_THAT(p1,p2,FAILURE_HANDLER)\
+ ::snowhouse::ConfigurableAssert<FAILURE_HANDLER>::That((p1), (p2), __FILE__, __LINE__);\
+
+#ifndef SNOWHOUSE_NO_MACROS
+
#define AssertThat(p1,p2)\
- Assert::That((p1), (p2), __FILE__, __LINE__);\
+ SNOWHOUSE_ASSERT_THAT((p1), (p2), ::snowhouse::DefaultFailureHandler);\
+
+#endif // SNOWHOUSE_NO_MACROS
#endif // IGLOO_ASSERTMACRO_H
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/constraints.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/constraints.h
index ea7a53d1..a12433d1 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/constraints.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/constraints.h
@@ -12,7 +12,9 @@
#include "equalsconstraint.h"
#include "haslengthconstraint.h"
#include "isgreaterthanconstraint.h"
+#include "isgreaterthanorequaltoconstraint.h"
#include "islessthanconstraint.h"
+#include "islessthanorequaltoconstraint.h"
#include "startswithconstraint.h"
#include "fulfillsconstraint.h"
#include "equalswithdeltaconstraint.h"
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalsconstraint.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalsconstraint.h
index cbdc4054..a47f6bf4 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalsconstraint.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalsconstraint.h
@@ -7,6 +7,8 @@
#ifndef IGLOO_EQUALSCONSTRAINT_H
#define IGLOO_EQUALSCONSTRAINT_H
+#include <cstddef>
+
#include "./expressions/expression.h"
namespace snowhouse {
@@ -49,6 +51,13 @@ namespace snowhouse {
return EqualsConstraint<bool>(true);
}
+#if __cplusplus > 199711L
+ inline EqualsConstraint<std::nullptr_t> IsNull()
+ {
+ return EqualsConstraint<std::nullptr_t>(nullptr);
+ }
+#endif
+
template <>
struct Stringizer< EqualsConstraint< bool > >
{
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalscontainerconstraint.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalscontainerconstraint.h
index 6bb5d797..f8650952 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalscontainerconstraint.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/equalscontainerconstraint.h
@@ -45,7 +45,12 @@ namespace snowhouse {
const BinaryPredicate predicate_;
private:
- EqualsContainerConstraint& operator=(const EqualsContainerConstraint&) { return *this; }
+
+#if __cplusplus > 199711L
+#else
+ EqualsContainerConstraint& operator=(const EqualsContainerConstraint&) { return *this; }
+#endif
+
};
template< typename ExpectedType>
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/isgreaterthanorequaltoconstraint.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/isgreaterthanorequaltoconstraint.h
new file mode 100644
index 00000000..3752887b
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/isgreaterthanorequaltoconstraint.h
@@ -0,0 +1,55 @@
+
+// Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
+// 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 IGLOO_ISGREATERTHANOREQUALTOCONSTRAINT_H
+#define IGLOO_ISGREATERTHANOREQUALTOCONSTRAINT_H
+
+#include "./expressions/expression.h"
+
+namespace snowhouse {
+
+ template< typename ExpectedType >
+ struct IsGreaterThanOrEqualToConstraint : Expression < IsGreaterThanOrEqualToConstraint<ExpectedType> >
+ {
+ IsGreaterThanOrEqualToConstraint(const ExpectedType& expected)
+ : m_expected(expected)
+ {
+ }
+
+ template<typename ActualType>
+ bool operator()(const ActualType& actual) const
+ {
+ return (actual >= m_expected);
+ }
+
+ ExpectedType m_expected;
+ };
+
+ template< typename ExpectedType >
+ inline IsGreaterThanOrEqualToConstraint<ExpectedType> IsGreaterThanOrEqualTo(const ExpectedType& expected)
+ {
+ return IsGreaterThanOrEqualToConstraint<ExpectedType>(expected);
+ }
+
+ inline IsGreaterThanOrEqualToConstraint<std::string> IsGreaterThanOrEqualTo(const char* expected)
+ {
+ return IsGreaterThanOrEqualToConstraint<std::string>(expected);
+ }
+
+ template< typename ExpectedType >
+ struct Stringizer < IsGreaterThanOrEqualToConstraint< ExpectedType > >
+ {
+ static std::string ToString(const IsGreaterThanOrEqualToConstraint<ExpectedType>& constraint)
+ {
+ std::ostringstream builder;
+ builder << "greater than or equal to " << snowhouse::Stringize(constraint.m_expected);
+
+ return builder.str();
+ }
+ };
+}
+
+#endif
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/islessthanorequaltoconstraint.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/islessthanorequaltoconstraint.h
new file mode 100644
index 00000000..36e02ab4
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/constraints/islessthanorequaltoconstraint.h
@@ -0,0 +1,55 @@
+
+// Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
+// 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 IGLOO_ISLESSTHANOREQUALTOCONSTRAINT_H
+#define IGLOO_ISLESSTHANOREQUALTOCONSTRAINT_H
+
+#include "./expressions/expression.h"
+
+namespace snowhouse {
+
+ template< typename ExpectedType >
+ struct IsLessThanOrEqualToConstraint : Expression < IsLessThanOrEqualToConstraint<ExpectedType> >
+ {
+ IsLessThanOrEqualToConstraint(const ExpectedType& expected)
+ : m_expected(expected)
+ {
+ }
+
+ template<typename ActualType>
+ bool operator()(const ActualType& actual) const
+ {
+ return (actual <= m_expected);
+ }
+
+ ExpectedType m_expected;
+ };
+
+ template< typename ExpectedType >
+ inline IsLessThanOrEqualToConstraint<ExpectedType> IsLessThanOrEqualTo(const ExpectedType& expected)
+ {
+ return IsLessThanOrEqualToConstraint<ExpectedType>(expected);
+ }
+
+ inline IsLessThanOrEqualToConstraint<std::string> IsLessThanOrEqualTo(const char* expected)
+ {
+ return IsLessThanOrEqualToConstraint<std::string>(expected);
+ }
+
+ template< typename ExpectedType >
+ struct Stringizer < IsLessThanOrEqualToConstraint< ExpectedType > >
+ {
+ static std::string ToString(const IsLessThanOrEqualToConstraint<ExpectedType>& constraint)
+ {
+ std::ostringstream builder;
+ builder << "less than or equal to " << snowhouse::Stringize(constraint.m_expected);
+
+ return builder.str();
+ }
+ };
+}
+
+#endif
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/exceptions.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/exceptions.h
index 03b879ef..22ad11ef 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/exceptions.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/exceptions.h
@@ -15,37 +15,70 @@ namespace snowhouse {
class ExceptionStorage
{
public:
- static std::auto_ptr<ExceptionType>& last_exception()
+ static void last_exception(ExceptionType*** e, bool clear=false)
{
- static std::auto_ptr<ExceptionType> last;
- return last;
+ static ExceptionType* last = NULL;
+ if(clear && last)
+ {
+ delete last;
+ return;
+ }
+
+ *e = &last;
+ silly_warning_about_unused_arg(e);
+ }
+
+ static ExceptionType*** silly_warning_about_unused_arg(ExceptionType*** e)
+ {
+ return e;
+ }
+
+ static void store(const ExceptionType& e)
+ {
+ ExceptionType** last = NULL;
+ last_exception(&last);
+ if(*last)
+ {
+ delete *last;
+ *last = NULL;
+ }
+
+ *last = new ExceptionType(e);
}
void compiler_thinks_i_am_unused() {}
~ExceptionStorage()
{
- last_exception().reset(NULL);
+ ExceptionType** e = NULL;
+ last_exception(&e);
+ if(*e)
+ {
+ delete *e;
+ *e = NULL;
+ }
}
};
template <typename ExceptionType>
inline ExceptionType& LastException()
{
- if(ExceptionStorage<ExceptionType>::last_exception().get() == NULL)
+ ExceptionType** e = NULL;
+ ExceptionStorage<ExceptionType>::last_exception(&e);
+ if(*e == NULL)
{
Assert::Failure("No exception was stored");
}
- return *(ExceptionStorage<ExceptionType>::last_exception().get());
+ return **e;
}
}
#define IGLOO_CONCAT2(a, b) a##b
#define IGLOO_CONCAT(a, b) IGLOO_CONCAT2(a, b)
-#define AssertThrows(EXCEPTION_TYPE, METHOD) \
-ExceptionStorage<EXCEPTION_TYPE> IGLOO_CONCAT(IGLOO_storage_, __LINE__); IGLOO_CONCAT(IGLOO_storage_, __LINE__).compiler_thinks_i_am_unused(); \
+#define SNOWHOUSE_ASSERT_THROWS(EXCEPTION_TYPE, METHOD, FAILURE_HANDLER_TYPE) \
+::snowhouse::ExceptionStorage<EXCEPTION_TYPE> IGLOO_CONCAT(IGLOO_storage_, __LINE__); IGLOO_CONCAT(IGLOO_storage_, __LINE__).compiler_thinks_i_am_unused(); \
{ \
bool wrong_exception = false; \
bool no_exception = false; \
@@ -56,7 +89,7 @@ ExceptionStorage<EXCEPTION_TYPE> IGLOO_CONCAT(IGLOO_storage_, __LINE__); IGLOO_C
} \
catch (const EXCEPTION_TYPE& e) \
{ \
- ExceptionStorage<EXCEPTION_TYPE>::last_exception() = std::auto_ptr<EXCEPTION_TYPE>(new EXCEPTION_TYPE(e)); \
+ ::snowhouse::ExceptionStorage<EXCEPTION_TYPE>::store(e); \
} \
catch(...) \
{ \
@@ -66,16 +99,22 @@ ExceptionStorage<EXCEPTION_TYPE> IGLOO_CONCAT(IGLOO_storage_, __LINE__); IGLOO_C
{ \
std::ostringstream stm; \
stm << "Expected " << #EXCEPTION_TYPE << ". No exception was thrown."; \
- Assert::Failure(stm.str()); \
+ ::snowhouse::ConfigurableAssert<FAILURE_HANDLER_TYPE>::Failure(stm.str()); \
} \
if(wrong_exception) \
{ \
std::ostringstream stm; \
stm << "Expected " << #EXCEPTION_TYPE << ". Wrong exception was thrown."; \
- Assert::Failure(stm.str()); \
+ ::snowhouse::ConfigurableAssert<FAILURE_HANDLER_TYPE>::Failure(stm.str()); \
} \
}
+#ifndef SNOWHOUSE_NO_MACROS
+
+#define AssertThrows(EXCEPTION_TYPE, METHOD) SNOWHOUSE_ASSERT_THROWS(EXCEPTION_TYPE, (METHOD), ::snowhouse::DefaultFailureHandler)
+
+#endif // SNOWHOUSE_NO_MACROS
+
#endif
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/expressionbuilder.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/expressionbuilder.h
index 20bf1358..f0889f1d 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/expressionbuilder.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/expressionbuilder.h
@@ -7,6 +7,8 @@
#ifndef IGLOO_EXPRESSIONBUILDER_H
#define IGLOO_EXPRESSIONBUILDER_H
+#include <cstddef>
+
namespace snowhouse {
// ---- Evaluation of list of constraints
@@ -27,7 +29,7 @@ namespace snowhouse {
ExpressionBuilder(const ConstraintListType& list) : m_constraint_list(list)
{
}
-
+
template <typename ExpectedType>
ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<EqualsConstraint<ExpectedType> >, Nil> >::t>
EqualTo(const ExpectedType& expected)
@@ -79,24 +81,44 @@ namespace snowhouse {
return EqualTo<bool>(true);
}
+#if __cplusplus > 199711L
+ ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<EqualsConstraint<std::nullptr_t> >, Nil> >::t>
+ Null()
+ {
+ return EqualTo<std::nullptr_t>(nullptr);
+ }
+#endif
+
ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<EqualsConstraint<std::string> >, Nil> >::t>
EqualTo(const char* expected)
{
return EqualTo<std::string>(std::string(expected));
}
- template <typename ExpectedType>
- ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<IsGreaterThanConstraint<ExpectedType> >, Nil> >::t>
- GreaterThan(const ExpectedType& expected)
- {
- typedef ConstraintAdapter<IsGreaterThanConstraint<ExpectedType> > ConstraintAdapterType;
-
- typedef ExpressionBuilder< typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapterType, Nil> >::t > BuilderType;
- ConstraintAdapterType constraint(expected);
- ConstraintList<ConstraintAdapterType, Nil> node(constraint, Nil());
- return BuilderType(Concatenate(m_constraint_list, node));
- }
-
+ template <typename ExpectedType>
+ ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<IsGreaterThanConstraint<ExpectedType> >, Nil> >::t>
+ GreaterThan(const ExpectedType& expected)
+ {
+ typedef ConstraintAdapter<IsGreaterThanConstraint<ExpectedType> > ConstraintAdapterType;
+
+ typedef ExpressionBuilder< typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapterType, Nil> >::t > BuilderType;
+ ConstraintAdapterType constraint(expected);
+ ConstraintList<ConstraintAdapterType, Nil> node(constraint, Nil());
+ return BuilderType(Concatenate(m_constraint_list, node));
+ }
+
+ template <typename ExpectedType>
+ ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<IsGreaterThanOrEqualToConstraint<ExpectedType> >, Nil> >::t>
+ GreaterThanOrEqualTo(const ExpectedType& expected)
+ {
+ typedef ConstraintAdapter<IsGreaterThanOrEqualToConstraint<ExpectedType> > ConstraintAdapterType;
+
+ typedef ExpressionBuilder< typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapterType, Nil> >::t > BuilderType;
+ ConstraintAdapterType constraint(expected);
+ ConstraintList<ConstraintAdapterType, Nil> node(constraint, Nil());
+ return BuilderType(Concatenate(m_constraint_list, node));
+ }
+
template <typename ExpectedType>
ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<IsLessThanConstraint<ExpectedType> >, Nil> >::t>
LessThan(const ExpectedType& expected)
@@ -109,6 +131,18 @@ namespace snowhouse {
return BuilderType(Concatenate(m_constraint_list, node));
}
+ template <typename ExpectedType>
+ ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<IsLessThanOrEqualToConstraint<ExpectedType> >, Nil> >::t>
+ LessThanOrEqualTo(const ExpectedType& expected)
+ {
+ typedef ConstraintAdapter<IsLessThanOrEqualToConstraint<ExpectedType> > ConstraintAdapterType;
+
+ typedef ExpressionBuilder< typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapterType, Nil> >::t > BuilderType;
+ ConstraintAdapterType constraint(expected);
+ ConstraintList<ConstraintAdapterType, Nil> node(constraint, Nil());
+ return BuilderType(Concatenate(m_constraint_list, node));
+ }
+
template <typename ExpectedType>
ExpressionBuilder<typename type_concat<ConstraintListType, ConstraintList<ConstraintAdapter<ContainsConstraint<ExpectedType> >, Nil> >::t>
Containing(const ExpectedType& expected)
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/collections/collectionconstraintevaluator.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/collections/collectionconstraintevaluator.h
index cc9a3aef..3fa30f2c 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/collections/collectionconstraintevaluator.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/collections/collectionconstraintevaluator.h
@@ -8,7 +8,7 @@
#define IGLOO_COLLECTIONCONSTRAINTEVALUATOR_H
#include <string>
-#include "../../../assertionexception.h"
+#include "../invalidexpressionexception.h"
namespace snowhouse
{
@@ -91,7 +91,7 @@ private:
std::ostringstream stm;
stm << "This string seems to contain an invalid line ending at position "
<< newline << ":\n" << str << std::endl;
- throw AssertionException(stm.str());
+ throw InvalidExpressionException(stm.str());
}
};
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/constraintoperator.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/constraintoperator.h
index 31c19b50..eafe6c51 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/constraintoperator.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/constraintoperator.h
@@ -7,29 +7,20 @@
#ifndef IGLOO_CONTRAINTOPERATOR_H
#define IGLOO_CONTRAINTOPERATOR_H
-namespace snowhouse {
-
- struct InvalidExpressionException
- {
- InvalidExpressionException(const std::string& message) : m_message(message)
- {
- }
-
- const std::string& Message() const
- {
- return m_message;
- }
+#include "invalidexpressionexception.h"
- std::string m_message;
- };
+namespace snowhouse {
struct ConstraintOperator
{
+#if __cplusplus > 199711L
+#else
virtual ~ConstraintOperator() {}
-
+#endif
+
virtual void PerformOperation(ResultStack& result) = 0;
virtual int Precedence() const = 0;
-
+
template <typename ConstraintListType, typename ActualType>
static bool EvaluateElementAgainstRestOfExpression(ConstraintListType& list, const ActualType& actual)
{
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/invalidexpressionexception.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/invalidexpressionexception.h
new file mode 100644
index 00000000..404341f1
--- /dev/null
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/invalidexpressionexception.h
@@ -0,0 +1,28 @@
+
+// Copyright Joakim Karlsson & Kim Gräsman 2010-2012.
+// 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 IGLOO_INVALUDEXPRESSIONEXCEPTION_H
+#define IGLOO_INVALUDEXPRESSIONEXCEPTION_H
+
+namespace snowhouse {
+
+ struct InvalidExpressionException
+ {
+ InvalidExpressionException(const std::string& message) : m_message(message)
+ {
+ }
+
+ const std::string& Message() const
+ {
+ return m_message;
+ }
+
+ std::string m_message;
+ };
+
+}
+
+#endif // IGLOO_INVALUDEXPRESSIONEXCEPTION_H
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/snowhouse.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/snowhouse.h
index 4c36968e..38214aa7 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/snowhouse.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/snowhouse.h
@@ -1,7 +1,16 @@
#ifndef _SNOWHOUSE_H_JK_2013_06_28
#define _SNOWHOUSE_H_JK_2013_06_28
-#define SNOWHOUSE_VERSION "1.0.2"
+#define SNOWHOUSE_VERSION "2.1.0"
+
+#if __cplusplus > 199711L
+#ifdef _MSC_VER
+// Visual Studio (including 2013) does not support the noexcept keyword
+#define _ALLOW_KEYWORD_MACROS
+#define noexcept
+#endif
+#endif
+
#include <iostream>
#include <map>
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/stringize.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/stringize.h
index ba2a0175..42249f57 100644
--- a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/stringize.h
+++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/stringize.h
@@ -7,6 +7,8 @@
#ifndef IGLOO_STRINGIZE_H
#define IGLOO_STRINGIZE_H
+#include <cstddef>
+
namespace snowhouse {
namespace detail {
@@ -85,6 +87,18 @@ namespace snowhouse {
return detail::DefaultStringizer< T, detail::is_output_streamable<T>::value >::ToString(value);
}
};
+
+#if __cplusplus > 199711L
+ // We need this because nullptr_t has ambiguous overloads of operator<< in the standard library.
+ template<>
+ struct Stringizer<std::nullptr_t>
+ {
+ static std::string ToString(std::nullptr_t)
+ {
+ return "nullptr";
+ }
+ };
+#endif
}
#endif
diff --git a/vendor/bandit/bandit/bandit.h b/vendor/bandit/bandit/bandit.h
index 14566ffa..c9caeda9 100644
--- a/vendor/bandit/bandit/bandit.h
+++ b/vendor/bandit/bandit/bandit.h
@@ -1,6 +1,12 @@
#ifndef BANDIT_BANDIT_H
#define BANDIT_BANDIT_H
+#ifdef _MSC_VER
+// Visual Studio (including 2013) does not support the noexcept keyword
+#define _ALLOW_KEYWORD_MACROS
+#define noexcept
+#endif
+
#include <cassert>
#include <functional>
#include <iostream>
@@ -8,7 +14,7 @@
#include <deque>
#include <stdexcept>
-#define BANDIT_VERSION "1.1.4"
+#define BANDIT_VERSION "2.0.0"
namespace bandit { namespace detail {
typedef std::function<void ()> voidfunc_t;
@@ -17,6 +23,8 @@ namespace bandit { namespace detail {
#include <bandit/assertion_frameworks/snowhouse/snowhouse/snowhouse.h>
using namespace snowhouse;
+#include <bandit/assertion_frameworks/matchers/matchers.h>
+
#include <bandit/external/optionparser.h>
#include <bandit/options.h>
#include <bandit/test_run_error.h>
diff --git a/vendor/bandit/bandit/context.h b/vendor/bandit/bandit/context.h
index 087818ed..71194253 100644
--- a/vendor/bandit/bandit/context.h
+++ b/vendor/bandit/bandit/context.h
@@ -20,8 +20,8 @@ namespace bandit {
class bandit_context : public context
{
public:
- bandit_context(const char* desc, bool hard_skip)
- : desc_(desc), hard_skip_(hard_skip), is_executing_(false)
+ bandit_context(const char* desc, bool hard_skip_a)
+ : desc_(desc), hard_skip_(hard_skip_a), is_executing_(false)
{}
const std::string& name()
diff --git a/vendor/bandit/bandit/grammar.h b/vendor/bandit/bandit/grammar.h
index 6aaec23d..1f973344 100644
--- a/vendor/bandit/bandit/grammar.h
+++ b/vendor/bandit/bandit/grammar.h
@@ -46,6 +46,13 @@ namespace bandit {
detail::context_stack());
}
+ inline void xdescribe(const char* desc, detail::voidfunc_t func,
+ detail::listener& listener=detail::registered_listener(),
+ detail::contextstack_t& context_stack=detail::context_stack())
+ {
+ describe_skip(desc, func, listener, context_stack);
+ }
+
inline void before_each(detail::voidfunc_t func,
detail::contextstack_t& context_stack)
{
@@ -78,10 +85,15 @@ namespace bandit {
it_skip(desc, func, detail::registered_listener());
}
+ inline void xit(const char* desc, detail::voidfunc_t func, detail::listener& listener=detail::registered_listener())
+ {
+ it_skip(desc, func, listener);
+ }
+
inline void it(const char* desc, detail::voidfunc_t func, detail::listener& listener,
detail::contextstack_t& context_stack,
bandit::adapters::assertion_adapter& assertion_adapter,
- const detail::run_policy& run_policy)
+ detail::run_policy& run_policy)
{
if(!run_policy.should_run(desc, context_stack))
{
@@ -105,31 +117,59 @@ namespace bandit {
});
};
+ bool we_have_been_successful_so_far = false;
try
{
assertion_adapter.adapt_exceptions([&](){
run_before_eaches();
func();
- listener.it_succeeded(desc);
+ we_have_been_successful_so_far = true;
});
}
catch(const bandit::detail::assertion_exception& ex)
{
listener.it_failed(desc, ex);
+ run_policy.encountered_failure();
+ }
+ catch(const std::exception& ex)
+ {
+ std::string err = std::string("exception: ") + ex.what();
+ listener.it_failed(desc, bandit::detail::assertion_exception(err));
+ run_policy.encountered_failure();
}
catch(...)
{
listener.it_unknown_error(desc);
+ run_policy.encountered_failure();
}
try
{
- run_after_eaches();
+ assertion_adapter.adapt_exceptions([&](){
+ run_after_eaches();
+
+ if(we_have_been_successful_so_far)
+ {
+ listener.it_succeeded(desc);
+ }
+ });
+ }
+ catch(const bandit::detail::assertion_exception& ex)
+ {
+ listener.it_failed(desc, ex);
+ run_policy.encountered_failure();
+ }
+ catch(const std::exception& ex)
+ {
+ std::string err = std::string("exception: ") + ex.what();
+ listener.it_failed(desc, bandit::detail::assertion_exception(err));
+ run_policy.encountered_failure();
}
catch(...)
{
listener.it_unknown_error(desc);
+ run_policy.encountered_failure();
}
}
diff --git a/vendor/bandit/bandit/options.h b/vendor/bandit/bandit/options.h
index d07c1e5b..493512cf 100644
--- a/vendor/bandit/bandit/options.h
+++ b/vendor/bandit/bandit/options.h
@@ -71,9 +71,14 @@ namespace bandit { namespace detail {
return options_[ONLY].arg ? options_[ONLY].arg : "";
}
+ bool break_on_failure() const
+ {
+ return options_[BREAK_ON_FAILURE] != NULL;
+ }
+
private:
enum option_index { UNKNOWN, VERSION, HELP, REPORTER, NO_COLOR,
- FORMATTER, SKIP, ONLY };
+ FORMATTER, SKIP, ONLY, BREAK_ON_FAILURE };
static const option::Descriptor* usage()
{
@@ -83,11 +88,12 @@ namespace bandit { namespace detail {
"Options:" },
{VERSION, 0, "", "version", option::Arg::None, " --version, \tPrint version of bandit"},
{HELP, 0, "", "help", option::Arg::None, " --help, \tPrint usage and exit."},
- {REPORTER, 0, "", "reporter", option::Arg::Optional, " --reporter=<reporter>, \tSelect reporter (dots, singleline, xunit, spec)"},
+ {REPORTER, 0, "", "reporter", option::Arg::Optional, " --reporter=<reporter>, \tSelect reporter (dots, singleline, xunit, info, spec)"},
{NO_COLOR, 0, "", "no-color", option::Arg::None, " --no-color, \tSuppress colors in output"},
{FORMATTER, 0, "", "formatter", option::Arg::Optional, " --formatter=<formatter>, \tSelect formatting of errors (default, vs)"},
{SKIP, 0, "", "skip", option::Arg::Optional, " --skip=<substring>, \tskip all 'describe' and 'it' containing substring"},
{ONLY, 0, "", "only", option::Arg::Optional, " --only=<substring>, \tonly run 'describe' and 'it' containing substring"},
+ {BREAK_ON_FAILURE, 0, "", "break-on-failure", option::Arg::Optional, " --break-on-failure, \tstop test run on first failing test"},
{0, 0, 0, 0, 0, 0}
};
diff --git a/vendor/bandit/bandit/registration/registrar.h b/vendor/bandit/bandit/registration/registrar.h
index 55d36255..d57a1f46 100644
--- a/vendor/bandit/bandit/registration/registrar.h
+++ b/vendor/bandit/bandit/registration/registrar.h
@@ -16,4 +16,10 @@ namespace bandit { namespace detail {
#define go_bandit \
static bandit::detail::spec_registrar bandit_registrar
+#define SPEC_BEGIN(name) \
+go_bandit([]{
+
+#define SPEC_END \
+});
+
#endif
diff --git a/vendor/bandit/bandit/reporters/colorizer.h b/vendor/bandit/bandit/reporters/colorizer.h
index 217bdddf..e8979eec 100644
--- a/vendor/bandit/bandit/reporters/colorizer.h
+++ b/vendor/bandit/bandit/reporters/colorizer.h
@@ -2,7 +2,7 @@
#define BANDIT_REPORTERS_COLORIZER_H
#ifdef _WIN32
- #ifndef MINGW32
+ #ifndef NOMINMAX
#define NOMINMAX
#endif
@@ -31,6 +31,24 @@ namespace bandit { namespace detail {
return "";
}
+ const char* yellow() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
+ }
+ return "";
+ }
+
+ const char* blue() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(FOREGROUND_BLUE);
+ }
+ return "";
+ }
+
const char* red() const
{
if(colors_enabled_)
@@ -40,6 +58,15 @@ namespace bandit { namespace detail {
return "";
}
+ const char* white() const
+ {
+ if(colors_enabled_)
+ {
+ set_console_color(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
+ }
+ return "";
+ }
+
const char* reset() const
{
if(colors_enabled_)
@@ -52,7 +79,7 @@ namespace bandit { namespace detail {
private:
WORD get_console_color() const
{
- CONSOLE_SCREEN_BUFFER_INFO info = {0};
+ CONSOLE_SCREEN_BUFFER_INFO info{};
GetConsoleScreenBufferInfo(stdout_handle_, &info);
return info.wAttributes;
}
@@ -80,11 +107,26 @@ namespace bandit { namespace detail {
return colors_enabled_ ? "\033[1;32m" : "";
}
+ const char* yellow() const
+ {
+ return colors_enabled_ ? "\033[1;33m" : "";
+ }
+
+ const char* blue() const
+ {
+ return colors_enabled_ ? "\033[1;34m" : "";
+ }
+
const char* red() const
{
return colors_enabled_ ? "\033[1;31m" : "";
}
+ const char* white() const
+ {
+ return colors_enabled_ ? "\033[1;37m" : "";
+ }
+
const char* reset() const
{
return colors_enabled_ ? "\033[0m" : "";
diff --git a/vendor/bandit/bandit/reporters/info_reporter.h b/vendor/bandit/bandit/reporters/info_reporter.h
new file mode 100644
index 00000000..f9b987d0
--- /dev/null
+++ b/vendor/bandit/bandit/reporters/info_reporter.h
@@ -0,0 +1,194 @@
+#ifndef BANDIT_INFO_REPORTER_H
+#define BANDIT_INFO_REPORTER_H
+
+namespace bandit {
+namespace detail {
+
+struct info_reporter : public progress_reporter
+{
+ info_reporter(std::ostream &stm, const failure_formatter &failure_formatter,
+ const detail::colorizer &colorizer)
+ : progress_reporter(failure_formatter)
+ , stm_(stm)
+ , colorizer_(colorizer)
+ , indentation_(0)
+ {}
+
+ info_reporter(const failure_formatter &failure_formatter, const detail::colorizer &colorizer)
+ : progress_reporter(failure_formatter)
+ , stm_(std::cout)
+ , colorizer_(colorizer)
+ , indentation_(0)
+ {}
+
+ info_reporter &operator=(const info_reporter &)
+ {
+ return *this;
+ }
+
+ void summary()
+ {
+ stm_
+ << colorizer_.white()
+ << "Tests run: " << specs_run_
+ << std::endl;
+ if (specs_skipped_ > 0) {
+ stm_
+ << colorizer_.yellow()
+ << "Skipped: " << specs_skipped_
+ << std::endl;
+ }
+ if (specs_succeeded_ > 0) {
+ stm_
+ << colorizer_.green()
+ << "Passed: " << specs_succeeded_
+ << std::endl;
+ }
+ if (specs_failed_ > 0) {
+ stm_
+ << colorizer_.red()
+ << "Failed: " << specs_failed_
+ << std::endl;
+ std::for_each(failures_.begin(), failures_.end(), [&](const std::string &failure) {
+ stm_
+ << colorizer_.white()
+ << " (*) "
+ << colorizer_.red()
+ << failure << std::endl;
+ });
+ }
+ if (test_run_errors_.size() > 0) {
+ stm_
+ << colorizer_.red()
+ << "Errors: " << test_run_errors_.size()
+ << std::endl;
+ std::for_each(test_run_errors_.begin(), test_run_errors_.end(), [&](const std::string &error) {
+ stm_
+ << colorizer_.white()
+ << " (*) "
+ << colorizer_.red()
+ << error << std::endl;
+ });
+ }
+ stm_
+ << colorizer_.reset()
+ << std::endl;
+ }
+
+ void test_run_complete()
+ {
+ progress_reporter::test_run_complete();
+ stm_ << std::endl;
+ summary();
+ stm_.flush();
+ }
+
+ void test_run_error(const char *desc, const struct test_run_error &err)
+ {
+ progress_reporter::test_run_error(desc, err);
+
+ std::stringstream ss;
+ ss << std::endl;
+ ss << "Failed to run \"" << current_context_name() << "\": error \"" << err.what() << "\"" << std::endl;
+
+ test_run_errors_.push_back(ss.str());
+ }
+
+ virtual void context_starting(const char *desc)
+ {
+ progress_reporter::context_starting(desc);
+
+ stm_
+ << indent()
+ << colorizer_.blue()
+ << "begin "
+ << colorizer_.white()
+ << desc
+ << colorizer_.reset()
+ << std::endl;
+ ++indentation_;
+ stm_.flush();
+
+ }
+
+ virtual void context_ended(const char *desc)
+ {
+ progress_reporter::context_ended(desc);
+ --indentation_;
+ stm_
+ << indent()
+ << colorizer_.blue()
+ << "end "
+ << colorizer_.reset()
+ << desc << std::endl;
+ }
+
+ virtual void it_starting(const char *desc)
+ {
+ progress_reporter::it_starting(desc);
+ stm_
+ << indent()
+ << colorizer_.yellow()
+ << "[ TEST ]"
+ << colorizer_.reset()
+ << " it " << desc;
+ ++indentation_;
+ stm_.flush();
+ }
+
+ virtual void it_succeeded(const char *desc)
+ {
+ progress_reporter::it_succeeded(desc);
+ --indentation_;
+ stm_
+ << "\r" << indent()
+ << colorizer_.green()
+ << "[ PASS ]"
+ << colorizer_.reset()
+ << " it " << desc
+ << std::endl;
+ stm_.flush();
+ }
+
+ virtual void it_failed(const char *desc, const assertion_exception &ex)
+ {
+ progress_reporter::it_failed(desc, ex);
+ --indentation_;
+ stm_
+ << "\r" << indent()
+ << colorizer_.red()
+ << "[ FAIL ]"
+ << colorizer_.reset()
+ << " it " << desc
+ << std::endl;
+ stm_.flush();
+ }
+
+ virtual void it_unknown_error(const char *desc)
+ {
+ progress_reporter::it_unknown_error(desc);
+ --indentation_;
+ stm_
+ << "\r" << indent()
+ << colorizer_.red()
+ << "-ERROR->"
+ << colorizer_.reset()
+ << " it " << desc
+ << std::endl;
+ stm_.flush();
+ }
+
+private:
+ std::string indent()
+ {
+ return std::string(2*indentation_, ' ');
+ }
+
+ std::ostream &stm_;
+ const detail::colorizer &colorizer_;
+ int indentation_;
+};
+}
+}
+
+#endif
diff --git a/vendor/bandit/bandit/reporters/reporters.h b/vendor/bandit/bandit/reporters/reporters.h
index 1a9a761a..12179270 100644
--- a/vendor/bandit/bandit/reporters/reporters.h
+++ b/vendor/bandit/bandit/reporters/reporters.h
@@ -7,6 +7,7 @@
#include <bandit/reporters/dots_reporter.h>
#include <bandit/reporters/single_line_reporter.h>
#include <bandit/reporters/xunit_reporter.h>
+#include <bandit/reporters/info_reporter.h>
#include <bandit/reporters/spec_reporter.h>
namespace bandit { namespace detail {
diff --git a/vendor/bandit/bandit/run_policies/bandit_run_policy.h b/vendor/bandit/bandit/run_policies/bandit_run_policy.h
index 6e150d8d..4a5c0808 100644
--- a/vendor/bandit/bandit/run_policies/bandit_run_policy.h
+++ b/vendor/bandit/bandit/run_policies/bandit_run_policy.h
@@ -5,12 +5,17 @@ namespace bandit { namespace detail {
struct bandit_run_policy : public run_policy
{
- bandit_run_policy(const char* skip_pattern, const char* only_pattern)
- : skip_pattern_(skip_pattern), only_pattern_(only_pattern)
+ bandit_run_policy(const char* skip_pattern, const char* only_pattern, bool break_on_failure)
+ : run_policy(), skip_pattern_(skip_pattern), only_pattern_(only_pattern), break_on_failure_(break_on_failure)
{}
bool should_run(const char* it_name, const contextstack_t& contexts) const
{
+ if(break_on_failure_ && has_encountered_failure())
+ {
+ return false;
+ }
+
//
// Never run if a context has been marked as skip
// using 'describe_skip'
@@ -148,6 +153,7 @@ namespace bandit { namespace detail {
private:
std::string skip_pattern_;
std::string only_pattern_;
+ bool break_on_failure_;
};
}}
diff --git a/vendor/bandit/bandit/run_policies/run_policy.h b/vendor/bandit/bandit/run_policies/run_policy.h
index 7440e1cd..4a6e8e1d 100644
--- a/vendor/bandit/bandit/run_policies/run_policy.h
+++ b/vendor/bandit/bandit/run_policies/run_policy.h
@@ -5,8 +5,25 @@ namespace bandit { namespace detail {
struct run_policy
{
+ run_policy() : encountered_failure_(false) {}
+ run_policy(const run_policy& other) = default;
+ run_policy(run_policy&&) = default;
virtual ~run_policy() {}
+
virtual bool should_run(const char* it_name, const contextstack_t& contexts) const = 0;
+
+ virtual void encountered_failure()
+ {
+ encountered_failure_ = true;
+ }
+
+ virtual bool has_encountered_failure() const
+ {
+ return encountered_failure_;
+ }
+
+ private:
+ bool encountered_failure_;
};
typedef std::unique_ptr<run_policy> run_policy_ptr;
diff --git a/vendor/bandit/bandit/runner.h b/vendor/bandit/bandit/runner.h
index 5df11005..1f8dcd11 100644
--- a/vendor/bandit/bandit/runner.h
+++ b/vendor/bandit/bandit/runner.h
@@ -7,7 +7,7 @@ namespace bandit {
inline run_policy_ptr create_run_policy(const options& opt)
{
- return run_policy_ptr(new bandit_run_policy(opt.skip(), opt.only()));
+ return run_policy_ptr(new bandit_run_policy(opt.skip(), opt.only(), opt.break_on_failure()));
}
inline listener_ptr create_reporter(const options& opt,
@@ -25,6 +25,11 @@ namespace bandit {
return std::unique_ptr<detail::listener>(new xunit_reporter(*formatter));
}
+ if(name == "info")
+ {
+ return std::unique_ptr<detail::listener>(new info_reporter(*formatter, colorizer));
+ }
+
if(name == "spec")
{
return std::unique_ptr<detail::listener>(new spec_reporter(*formatter, colorizer));