diff options
author | Bardur Arantsson <bardur@scientician.net> | 2015-02-23 09:11:55 +0100 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2015-02-23 09:11:55 +0100 |
commit | 062cd07342edc2b003555e90dd2cee0514b9f64a (patch) | |
tree | 3c73893dae8a9380c9f24e9c5822c5ec6bf671d5 /vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/notoperator.h | |
parent | ffee481435ac0afe3f9a5a3eb07b2f2a46467089 (diff) |
Add BanditCpp 1.1.4 test harness
Diffstat (limited to 'vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/notoperator.h')
-rw-r--r-- | vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/notoperator.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/notoperator.h b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/notoperator.h new file mode 100644 index 00000000..709c8413 --- /dev/null +++ b/vendor/bandit/bandit/assertion_frameworks/snowhouse/snowhouse/fluent/operators/notoperator.h @@ -0,0 +1,53 @@ + +// 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_NOTOPERATOR_H +#define IGLOO_NOTOPERATOR_H + +namespace snowhouse { + + struct NotOperator : public ConstraintOperator + { + template <typename ConstraintListType, typename ActualType> + void Evaluate(ConstraintListType& list, ResultStack& result, OperatorStack& operators, const ActualType& actual) + { + EvaluateOperatorsWithLessOrEqualPrecedence(*this, operators, result); + + operators.push(this); + + EvaluateConstraintList(list.m_tail, result, operators, actual); + } + + void PerformOperation(ResultStack& result) + { + if(result.size() < 1) + { + throw InvalidExpressionException("The expression contains a not operator without any operand"); + } + + bool right = result.top(); + result.pop(); + + result.push(!right); + } + + int Precedence() const + { + return 2; + } + }; + + template<> + struct Stringizer<NotOperator> + { + static std::string ToString(const NotOperator&) + { + return "not"; + } + }; +} + +#endif |