libept
expression.test.h
Go to the documentation of this file.
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 <tagcoll/expression.h>
23 #include <ept/debtags/vocabulary.h>
24 
25 #include "debtags.test.h"
26 
27 using namespace tagcoll;
28 using namespace std;
29 using namespace ept::debtags;
30 
33 
34  Test _1()
35 {
36  set<std::string> test;
37  test.insert("use::editing");
38  test.insert("use::viewing");
39  test.insert("works-with::text");
40 
41  assert_eq(test.size(), 3u);
42 
43  Expression e1("use::editing");
44  assert(e1(test));
45 
46  Expression e2("use::editing && use::viewing");
47  assert(e2(test));
48 
49  e1 = Expression("!use::editing");
50  assert(!e1(test));
51 
52  e1 = Expression("use::editing || sugo");
53  assert(e1(test));
54 
55  e1 = Expression("use::editing && !sugo");
56  assert(e1(test));
57 
58  e1 = Expression("use::editing && !use::viewing");
59  assert(!e1(test));
60 
61  e1 = Expression("(use::editing || sugo) && (use::viewing && works-with::text)");
62  assert(e1(test));
63 
64  e1 = Expression("!(use::editinuse::editingra && works-with::text)");
65  assert(e1(test));
66 
67  e1 = Expression("works-with::*");
68  assert(e1(test));
69 
70  e1 = Expression("*::text");
71  assert(e1(test));
72 
73  e1 = Expression("!*::antani");
74  assert(e1(test));
75 
76  e1 = Expression("*::antani");
77  assert(!e1(test));
78 }
79 
80 };
81 
82 // vim:set ts=4 sw=4:
Definition: test.h:35
Definition: packagerecord.test.h:22
Definition: debtags.cc:50
Definition: vocabulary.h:149
Definition: debdbparser.h:31
Vocabulary voc
Definition: expression.test.h:32
Test _1()
Definition: expression.test.h:34
Definition: expression.test.h:31