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 <ept/debtags/maint/path.h>
23 #include <tagcoll/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 
34 
35  Test _1()
36 {
37  set<std::string> test;
38  test.insert("use::editing");
39  test.insert("use::viewing");
40  test.insert("works-with::text");
41 
42  assert_eq(test.size(), 3u);
43 
44  Expression e1("use::editing");
45  assert(e1(test));
46 
47  Expression e2("use::editing && use::viewing");
48  assert(e2(test));
49 
50  e1 = Expression("!use::editing");
51  assert(!e1(test));
52 
53  e1 = Expression("use::editing || sugo");
54  assert(e1(test));
55 
56  e1 = Expression("use::editing && !sugo");
57  assert(e1(test));
58 
59  e1 = Expression("use::editing && !use::viewing");
60  assert(!e1(test));
61 
62  e1 = Expression("(use::editing || sugo) && (use::viewing && works-with::text)");
63  assert(e1(test));
64 
65  e1 = Expression("!(use::editinuse::editingra && works-with::text)");
66  assert(e1(test));
67 
68  e1 = Expression("works-with::*");
69  assert(e1(test));
70 
71  e1 = Expression("*::text");
72  assert(e1(test));
73 
74  e1 = Expression("!*::antani");
75  assert(e1(test));
76 
77  e1 = Expression("*::antani");
78  assert(!e1(test));
79 }
80 
81 };
82 
83 // vim:set ts=4 sw=4: