Browse Source

[trac981] Implementation of NOT

Michal 'vorner' Vaner 14 years ago
parent
commit
faa2bca675
2 changed files with 9 additions and 6 deletions
  1. 7 4
      src/lib/acl/logic_check.h
  2. 2 2
      src/lib/acl/tests/logic_check_test.cc

+ 7 - 4
src/lib/acl/logic_check.h

@@ -203,13 +203,16 @@ private:
 template<typename Context>
 class NotCheck : public CompoundCheck<Context> {
 public:
-    NotCheck(const boost::shared_ptr<Check<Context> >& expr) {
-
-    }
+    NotCheck(const boost::shared_ptr<Check<Context> >& expr) :
+        expr_(expr)
+    { }
     virtual typename CompoundCheck<Context>::Checks getSubexpressions() const {
-
+        typename CompoundCheck<Context>::Checks result;
+        result.push_back(expr_.get());
+        return (result);
     }
     virtual bool matches(const Context& context) const {
+        return (!expr_->matches(context));
     }
 private:
     const boost::shared_ptr<Check<Context> > expr_;

+ 2 - 2
src/lib/acl/tests/logic_check_test.cc

@@ -258,8 +258,8 @@ TEST(Not, trueValue) {
     notTest(true);
 }
 
-TEST(Not, trueValue) {
-    notTest(true);
+TEST(Not, falseValue) {
+    notTest(false);
 }
 
 }