]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[trac981] Tests for the NOT operator
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Mon, 4 Jul 2011 11:39:58 +0000 (13:39 +0200)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Mon, 4 Jul 2011 11:39:58 +0000 (13:39 +0200)
src/lib/acl/logic_check.h
src/lib/acl/tests/logic_check_test.cc

index 6e1c567a9645847f0ae8ecebfac164e42eb52803..70e657affc16f6403d08bf391f89a155d69cbdbe 100644 (file)
@@ -200,6 +200,21 @@ private:
     const std::string name_;
 };
 
+template<typename Context>
+class NotCheck : public CompoundCheck<Context> {
+public:
+    NotCheck(const boost::shared_ptr<Check<Context> >& expr) {
+
+    }
+    virtual typename CompoundCheck<Context>::Checks getSubexpressions() const {
+
+    }
+    virtual bool matches(const Context& context) const {
+    }
+private:
+    const boost::shared_ptr<Check<Context> > expr_;
+};
+
 }
 }
 
index eec6d51b8a42105df6e11857ceb5a672c462d249..3bf13dc5e4a623af9b68f3647929e0098f656a4b 100644 (file)
@@ -242,4 +242,24 @@ TEST_F(LogicCreatorTest, nested) {
     log_.checkFirst(2);
 }
 
+void notTest(bool value) {
+    NotCheck<Log> notOp(shared_ptr<Check<Log> >(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);
+}
+
 }