LCOV - lcov.info - ept/debtags/expression.test.h

LTP GCOV extension - code coverage report
Current view: | directory - ept/debtags - expression.test.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 32
Code covered: | 100.0 % |  | Executed lines: | 32

           1                 : /*
           2                 :  * Match tag expressions against sets of Debtags Tags
           3                 :  *
           4                 :  * Copyright (C) 2005,2006,2007  Enrico Zini <enrico@debian.org>
           5                 :  *
           6                 :  * This program is free software; you can redistribute it and/or modify
           7                 :  * it under the terms of the GNU General Public License as published by
           8                 :  * the Free Software Foundation; either version 2 of the License, or
           9                 :  * (at your option) any later version.
          10                 :  *
          11                 :  * This program is distributed in the hope that it will be useful,
          12                 :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
          13                 :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          14                 :  * GNU General Public License for more details.
          15                 :  *
          16                 :  * You should have received a copy of the GNU General Public License
          17                 :  * along with this program; if not, write to the Free Software
          18                 :  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
          19                 :  */
          20                 :
          21                 : #include <wibble/test.h>
          22                 : #include <ept/debtags/maint/path.h>
          23                 : #include <ept/debtags/expression.h>
          24                 : #include <ept/debtags/vocabulary.h>
          25                 :
          26                 : #include "debtags.test.h"
          27                 :
          28                 : using namespace tagcoll;
          29                 : using namespace std;
          30                 : using namespace ept::debtags;
          31                 :
          32               2 : struct TestExpression : DebtagsTestEnvironment {
          33                 :         Vocabulary voc;
          34                 :
          35               1 :         Test _1()
          36                 : {
          37               1 :         set<Tag> test;
          38               1 :         test.insert(voc.tagByName("use::editing"));
          39               2 :         test.insert(voc.tagByName("use::viewing"));
          40               2 :         test.insert(voc.tagByName("works-with::text"));
          41                 :
          42               2 :         assert_eq(test.size(), 3u);
          43                 :
          44               2 :         Expression e1("use::editing");
          45               2 :         assert(e1(test));
          46                 :
          47               2 :         Expression e2("use::editing && use::viewing");
          48               2 :         assert(e2(test));
          49                 :
          50               2 :         e1 = Expression("!use::editing");
          51               2 :         assert(!e1(test));
          52                 :
          53               2 :         e1 = Expression("use::editing || sugo");
          54               2 :         assert(e1(test));
          55                 :
          56               2 :         e1 = Expression("use::editing && !sugo");
          57               2 :         assert(e1(test));
          58                 :
          59               2 :         e1 = Expression("use::editing && !use::viewing");
          60               2 :         assert(!e1(test));
          61                 :
          62               2 :         e1 = Expression("(use::editing || sugo) && (use::viewing && works-with::text)");
          63               2 :         assert(e1(test));
          64                 :
          65               2 :         e1 = Expression("!(use::editinuse::editingra && works-with::text)");
          66               2 :         assert(e1(test));
          67                 :
          68               2 :         e1 = Expression("works-with::*");
          69               2 :         assert(e1(test));
          70                 :
          71               2 :         e1 = Expression("*::text");
          72               2 :         assert(e1(test));
          73                 :
          74               2 :         e1 = Expression("!*::antani");
          75               2 :         assert(e1(test));
          76                 :
          77               2 :         e1 = Expression("*::antani");
          78               2 :         assert(!e1(test));
          79               1 : }
          80                 :
          81                 : };
          82                 :
          83                 : // vim:set ts=4 sw=4:

Generated by: LTP GCOV extension version 1.6