Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
55   273   15   3.67
0   126   0.27   15
15     1  
1    
 
  FormulaCheckerPredicateFormulaTest       Line # 31 55 15 100% 1.0
 
No Tests
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.logic.wf;
17   
18    import org.qedeq.kernel.bo.logic.common.FormulaChecker;
19    import org.qedeq.kernel.bo.logic.common.LogicalCheckExceptionList;
20    import org.qedeq.kernel.se.base.list.Element;
21    import org.qedeq.kernel.se.common.DefaultModuleAddress;
22    import org.qedeq.kernel.se.common.ModuleContext;
23    import org.qedeq.kernel.xml.parser.BasicParser;
24   
25    /**
26    * For testing the {@link org.qedeq.kernel.bo.logic.FormulaChecker}.
27    * Testing formulas made of predicate variables and predicate constants.
28    *
29    * @author Michael Meyling
30    */
 
31    public class FormulaCheckerPredicateFormulaTest extends AbstractFormulaChecker {
32   
33    private ModuleContext context;
34   
35    private FormulaChecker checker;
36   
 
37  13 toggle protected void setUp() throws Exception {
38  13 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"), "getElement()");
39  13 checker = new FormulaCheckerImpl();
40    }
41   
 
42  13 toggle protected void tearDown() throws Exception {
43  13 context = null;
44    }
45   
46    /**
47    * Function: checkFormula(Element)
48    * Type: positive
49    * Data: A
50    *
51    * @throws Exception Test failed.
52    */
 
53  1 toggle public void testPredicateFormulaPositive01() throws Exception {
54  1 final Element ele = BasicParser.createElement("<PREDVAR id=\"A\"/>");
55    // System.out.println(ele.toString());
56  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
57  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
58  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
59    .hasErrors());
60    }
61   
62    /**
63    * Function: checkFormula(Element)
64    * Type: positive
65    * Data: V
66    *
67    * @throws Exception Test failed.
68    */
 
69  1 toggle public void testPredicateFormulaPositive02() throws Exception {
70  1 final Element ele = BasicParser.createElement("<PREDCON ref=\"true\"/>");
71    // System.out.println(ele.toString());
72  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
73  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
74  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
75    .hasErrors());
76    }
77   
78    /**
79    * Function: checkFormula(Element)
80    * Type: negative, code 30720
81    * Data: no function variable name
82    *
83    * @throws Exception Test failed.
84    */
 
85  1 toggle public void testPredicateFormulaNegative01() throws Exception {
86  1 final Element ele = BasicParser.createElement("<PREDVAR />");
87    // System.out.println(ele.toString());
88  1 LogicalCheckExceptionList list =
89    checker.checkFormula(ele, context, getChecker());
90  1 assertEquals(1, list.size());
91  1 assertEquals(30720, list.get(0).getErrorCode());
92    }
93   
94    /**
95    * Function: checkFormula(Element)
96    * Type: negative, code 30720
97    * Data: no function constant name
98    *
99    * @throws Exception Test failed.
100    */
 
101  1 toggle public void testPredicateFormulaNegative02() throws Exception {
102  1 final Element ele = BasicParser.createElement("<PREDCON />");
103    // System.out.println(ele.toString());
104  1 LogicalCheckExceptionList list =
105    checker.checkFormula(ele, context, getChecker());
106  1 assertEquals(1, list.size());
107  1 assertEquals(30720, list.get(0).getErrorCode());
108    }
109   
110    /**
111    * Function: checkFormula(Element)
112    * Type: negative, code 30730
113    * Data: function name missing (but list instead of name)
114    *
115    * @throws Exception Test failed.
116    */
 
117  1 toggle public void testPredicateFormulaNegative09() throws Exception {
118  1 final Element ele = BasicParser.createElement("<PREDVAR > <VAR id=\"x\" /> </PREDVAR>");
119    // System.out.println(ele.toString());
120  1 LogicalCheckExceptionList list =
121    checker.checkFormula(ele, context, getChecker());
122  1 assertEquals(1, list.size());
123  1 assertEquals(30730, list.get(0).getErrorCode());
124    }
125   
126   
127    /**
128    * Function: checkFormula(Element)
129    * Type: negative, code 30730
130    * Data: function name missing (but list instead of name)
131    *
132    * @throws Exception Test failed.
133    */
 
134  1 toggle public void testPredicateFormulaNegative10() throws Exception {
135  1 final Element ele = BasicParser.createElement("<PREDCON > <VAR id=\"x\" /> </PREDCON>");
136    // System.out.println(ele.toString());
137  1 LogicalCheckExceptionList list =
138    checker.checkFormula(ele, context, getChecker());
139  1 assertEquals(1, list.size());
140  1 assertEquals(30730, list.get(0).getErrorCode());
141    }
142   
143   
144    /**
145    * Function: checkFormula(Element)
146    * Type: negative, code 30730
147    * Data: function name missing
148    *
149    * @throws Exception Test failed.
150    */
 
151  1 toggle public void testPredicateFormulaNegative13() throws Exception {
152  1 final Element ele = BasicParser.createElement("<PREDVAR> <A/> </PREDVAR>");
153    // System.out.println(ele.toString());
154  1 LogicalCheckExceptionList list =
155    checker.checkFormula(ele, context, getChecker());
156  1 assertEquals(1, list.size());
157  1 assertEquals(30730, list.get(0).getErrorCode());
158    }
159   
160    /**
161    * Function: checkFormula(Element)
162    * Type: negative, code 30730
163    * Data: function name missing
164    *
165    * @throws Exception Test failed.
166    */
 
167  1 toggle public void testPredicateFormulaNegative14() throws Exception {
168  1 final Element ele = BasicParser.createElement("<PREDCON> <A/> </PREDCON>");
169    // System.out.println(ele.toString());
170  1 LogicalCheckExceptionList list =
171    checker.checkFormula(ele, context, getChecker());
172  1 assertEquals(1, list.size());
173  1 assertEquals(30730, list.get(0).getErrorCode());
174    }
175   
176    /**
177    * Function: checkFormula(Element)
178    * Type: negative, code 30770
179    * Data: f(x, {x| phi})
180    *
181    * @throws Exception Test failed.
182    */
 
183  1 toggle public void testPredicateFormulaNegative15() throws Exception {
184  1 final Element ele = BasicParser.createElement(
185    "<PREDVAR id=\"f\">"
186    + "<VAR id=\"x\"/>"
187    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
188    + "</PREDVAR>");
189    // System.out.println(ele.toString());
190  1 LogicalCheckExceptionList list =
191    checker.checkFormula(ele, context, getChecker());
192  1 assertEquals(1, list.size());
193  1 assertEquals(30770, list.get(0).getErrorCode());
194    }
195   
196    /**
197    * Function: checkFormula(Element)
198    * Type: negative, code 30770
199    * Data: x in {x| phi}
200    *
201    * @throws Exception Test failed.
202    */
 
203  1 toggle public void testPredicateFormulaNegative16() throws Exception {
204  1 final Element ele = BasicParser.createElement(
205    "<PREDCON ref=\"in\">"
206    + "<VAR id=\"x\"/>"
207    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
208    + "</PREDCON>");
209    // System.out.println(ele.toString());
210  1 LogicalCheckExceptionList list =
211    checker.checkFormula(ele, context, getChecker());
212  1 assertEquals(1, list.size());
213  1 assertEquals(30770, list.get(0).getErrorCode());
214    }
215   
216    /**
217    * Function: checkFormula(Element)
218    * Type: negative, code 30780
219    * Data: f({x| phi}, x)
220    *
221    * @throws Exception Test failed.
222    */
 
223  1 toggle public void testPredicateFormulaNegative19() throws Exception {
224  1 final Element ele = BasicParser.createElement(
225    "<PREDVAR id=\"f\">"
226    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
227    + "<VAR id=\"x\"/>"
228    + "</PREDVAR>");
229    // System.out.println(ele.toString());
230  1 LogicalCheckExceptionList list =
231    checker.checkFormula(ele, context, getChecker());
232  1 assertEquals(1, list.size());
233  1 assertEquals(30780, list.get(0).getErrorCode());
234    }
235   
236    /**
237    * Function: checkFormula(Element)
238    * Type: negative, code 30780
239    * Data: {x| phi} in x
240    *
241    * @throws Exception Test failed.
242    */
 
243  1 toggle public void testPredicateFormulaNegative20() throws Exception {
244  1 final Element ele = BasicParser.createElement(
245    "<PREDCON id=\"in\">"
246    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
247    + "<VAR id=\"x\"/>"
248    + "</PREDCON>");
249    // System.out.println(ele.toString());
250  1 LogicalCheckExceptionList list =
251    checker.checkFormula(ele, context, getChecker());
252  1 assertEquals(1, list.size());
253  1 assertEquals(30780, list.get(0).getErrorCode());
254    }
255   
256    /**
257    * Function: checkFormula(Element)
258    * Type: negative, code 30590
259    * Data: F(x) (unknown predicate constant)
260    *
261    * @throws Exception Test failed.
262    */
 
263  1 toggle public void testPredicateFormulaNegative22() throws Exception {
264  1 final Element ele = BasicParser.createElement(
265    "<PREDCON id=\"F\" />");
266    // System.out.println(ele.toString());
267  1 LogicalCheckExceptionList list =
268    checker.checkFormula(ele, context, getChecker());
269  1 assertEquals(1, list.size());
270  1 assertEquals(30590, list.get(0).getErrorCode());
271    }
272   
273    }