libept
|
00001 /* 00002 * Match tag expressions against sets of Debtags Tags 00003 * 00004 * Copyright (C) 2005,2006,2007 Enrico Zini <enrico@debian.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 00021 #include <wibble/test.h> 00022 #include <ept/debtags/maint/path.h> 00023 #include <tagcoll/expression.h> 00024 #include <ept/debtags/vocabulary.h> 00025 00026 #include "debtags.test.h" 00027 00028 using namespace tagcoll; 00029 using namespace std; 00030 using namespace ept::debtags; 00031 00032 struct TestExpression : DebtagsTestEnvironment { 00033 Vocabulary voc; 00034 00035 Test _1() 00036 { 00037 set<std::string> test; 00038 test.insert("use::editing"); 00039 test.insert("use::viewing"); 00040 test.insert("works-with::text"); 00041 00042 assert_eq(test.size(), 3u); 00043 00044 Expression e1("use::editing"); 00045 assert(e1(test)); 00046 00047 Expression e2("use::editing && use::viewing"); 00048 assert(e2(test)); 00049 00050 e1 = Expression("!use::editing"); 00051 assert(!e1(test)); 00052 00053 e1 = Expression("use::editing || sugo"); 00054 assert(e1(test)); 00055 00056 e1 = Expression("use::editing && !sugo"); 00057 assert(e1(test)); 00058 00059 e1 = Expression("use::editing && !use::viewing"); 00060 assert(!e1(test)); 00061 00062 e1 = Expression("(use::editing || sugo) && (use::viewing && works-with::text)"); 00063 assert(e1(test)); 00064 00065 e1 = Expression("!(use::editinuse::editingra && works-with::text)"); 00066 assert(e1(test)); 00067 00068 e1 = Expression("works-with::*"); 00069 assert(e1(test)); 00070 00071 e1 = Expression("*::text"); 00072 assert(e1(test)); 00073 00074 e1 = Expression("!*::antani"); 00075 assert(e1(test)); 00076 00077 e1 = Expression("*::antani"); 00078 assert(!e1(test)); 00079 } 00080 00081 }; 00082 00083 // vim:set ts=4 sw=4: