From: Michal 'vorner' Vaner Date: Mon, 4 Jul 2011 11:39:58 +0000 (+0200) Subject: [trac981] Tests for the NOT operator X-Git-Tag: perftcpdns_before_epoll~263^2~1^2~1^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2e29bef63a7fa200af54b9b0fc69e5cf2573b467;p=thirdparty%2Fkea.git [trac981] Tests for the NOT operator --- diff --git a/src/lib/acl/logic_check.h b/src/lib/acl/logic_check.h index 6e1c567a96..70e657affc 100644 --- a/src/lib/acl/logic_check.h +++ b/src/lib/acl/logic_check.h @@ -200,6 +200,21 @@ private: const std::string name_; }; +template +class NotCheck : public CompoundCheck { +public: + NotCheck(const boost::shared_ptr >& expr) { + + } + virtual typename CompoundCheck::Checks getSubexpressions() const { + + } + virtual bool matches(const Context& context) const { + } +private: + const boost::shared_ptr > expr_; +}; + } } diff --git a/src/lib/acl/tests/logic_check_test.cc b/src/lib/acl/tests/logic_check_test.cc index eec6d51b8a..3bf13dc5e4 100644 --- a/src/lib/acl/tests/logic_check_test.cc +++ b/src/lib/acl/tests/logic_check_test.cc @@ -242,4 +242,24 @@ TEST_F(LogicCreatorTest, nested) { log_.checkFirst(2); } +void notTest(bool value) { + NotCheck notOp(shared_ptr >(new ConstCheck(value, 0))); + Log log; + // It returns negated value + EXPECT_EQ(!value, notOp.matches(log)); + // And runs the only one thing there + log.checkFirst(1); + // Check the getSubexpressions does sane things + ASSERT_EQ(1, notOp.getSubexpressions().size()); + EXPECT_EQ(value, notOp.getSubexpressions()[0]->matches(log)); +} + +TEST(Not, trueValue) { + notTest(true); +} + +TEST(Not, trueValue) { + notTest(true); +} + }