Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
59   293   16   3.69
0   137   0.27   16
16     1  
1    
 
  FormulaCheckerFunctionTermTest       Line # 31 59 16 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 terms made of function variables and function constants.
28    *
29    * @author Michael Meyling
30    */
 
31    public class FormulaCheckerFunctionTermTest extends AbstractFormulaChecker {
32   
33    private ModuleContext context;
34   
35    private FormulaChecker checker;
36   
 
37  14 toggle protected void setUp() throws Exception {
38  14 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"), "getElement()");
39  14 checker = new FormulaCheckerImpl();
40    }
41   
 
42  14 toggle protected void tearDown() throws Exception {
43  14 context = null;
44    }
45   
46    /**
47    * Function: checkTerm(Element)
48    * Type: positive
49    * Data: f(x)
50    *
51    * @throws Exception Test failed.
52    */
 
53  1 toggle public void testFunctionTermPositive01() throws Exception {
54  1 final Element ele = BasicParser.createElement(
55    "<FUNVAR id=\"f\">" +
56    " <VAR id=\"x\" />" +
57    "</FUNVAR>");
58    // System.out.println(ele.toString());
59  1 assertFalse(checker.checkTerm(ele, context).hasErrors());
60  1 assertFalse(checker.checkTerm(ele, context, getChecker()).hasErrors());
61  1 assertFalse(checker.checkTerm(ele, context, getCheckerWithoutClass()).hasErrors());
62    }
63   
64    /**
65    * Function: checkTerm(Element)
66    * Type: positive
67    * Data: V
68    *
69    * @throws Exception Test failed.
70    */
 
71  1 toggle public void testFunctionTermPositive02() throws Exception {
72  1 final Element ele = BasicParser.createElement("<FUNCON ref=\"empty\"/>");
73    // System.out.println(ele.toString());
74  1 assertFalse(checker.checkTerm(ele, context).hasErrors());
75  1 assertFalse(checker.checkTerm(ele, context, getChecker()).hasErrors());
76  1 assertFalse(checker.checkTerm(ele, context, getCheckerWithoutClass()).hasErrors());
77    }
78   
79    /**
80    * Function: checkTerm(Element)
81    * Type: negative, code 30740
82    * Data: no function variable name and no argument
83    *
84    * @throws Exception Test failed.
85    */
 
86  1 toggle public void testFunctionTermNegative01() throws Exception {
87  1 final Element ele = BasicParser.createElement("<FUNVAR />");
88    // System.out.println(ele.toString());
89  1 LogicalCheckExceptionList list =
90    checker.checkTerm(ele, context, getChecker());
91  1 assertEquals(1, list.size());
92  1 assertEquals(30740, list.get(0).getErrorCode());
93    }
94   
95    /**
96    * Function: checkTerm(Element)
97    * Type: negative, code 30740
98    * Data: f() (no function argument)
99    *
100    * @throws Exception Test failed.
101    */
 
102  1 toggle public void testFunctionTermNegative01b() throws Exception {
103  1 final Element ele = BasicParser.createElement("<FUNVAR id=\"f\"/>");
104    // System.out.println(ele.toString());
105  1 LogicalCheckExceptionList list =
106    checker.checkTerm(ele, context, getChecker());
107  1 assertEquals(1, list.size());
108  1 assertEquals(30740, list.get(0).getErrorCode());
109    }
110   
111    /**
112    * Function: checkTerm(Element)
113    * Type: negative, code 30720
114    * Data: no function constant name
115    *
116    * @throws Exception Test failed.
117    */
 
118  1 toggle public void testFunctionTermNegative02() throws Exception {
119  1 final Element ele = BasicParser.createElement("<FUNCON />");
120    // System.out.println(ele.toString());
121  1 LogicalCheckExceptionList list =
122    checker.checkTerm(ele, context, getChecker());
123  1 assertEquals(1, list.size());
124  1 assertEquals(30720, list.get(0).getErrorCode());
125    }
126   
127    /**
128    * Function: checkTerm(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 testFunctionTermNegative09() throws Exception {
135  1 final Element ele = BasicParser.createElement(
136    "<FUNVAR>" +
137    " <VAR id=\"x\" /> <VAR id=\"x\" />" +
138    "</FUNVAR>");
139    // System.out.println(ele.toString());
140  1 LogicalCheckExceptionList list =
141    checker.checkTerm(ele, context, getChecker());
142  1 assertEquals(1, list.size());
143  1 assertEquals(30730, list.get(0).getErrorCode());
144    }
145   
146   
147    /**
148    * Function: checkTerm(Element)
149    * Type: negative, code 30730
150    * Data: function name missing (but list instead of name)
151    *
152    * @throws Exception Test failed.
153    */
 
154  1 toggle public void testFunctionTermNegative10() throws Exception {
155  1 final Element ele = BasicParser.createElement("<FUNCON > <VAR id=\"x\" /> </FUNCON>");
156    // System.out.println(ele.toString());
157  1 LogicalCheckExceptionList list =
158    checker.checkTerm(ele, context, getChecker());
159  1 assertEquals(1, list.size());
160  1 assertEquals(30730, list.get(0).getErrorCode());
161    }
162   
163   
164    /**
165    * Function: checkTerm(Element)
166    * Type: negative, code 30730
167    * Data: function name missing
168    *
169    * @throws Exception Test failed.
170    */
 
171  1 toggle public void testFunctionTermNegative13() throws Exception {
172  1 final Element ele = BasicParser.createElement("<FUNVAR> <A/> <A/></FUNVAR>");
173    // System.out.println(ele.toString());
174  1 LogicalCheckExceptionList list =
175    checker.checkTerm(ele, context, getChecker());
176  1 assertEquals(1, list.size());
177  1 assertEquals(30730, list.get(0).getErrorCode());
178    }
179   
180    /**
181    * Function: checkTerm(Element)
182    * Type: negative, code 30730
183    * Data: function name missing
184    *
185    * @throws Exception Test failed.
186    */
 
187  1 toggle public void testFunctionTermNegative14() throws Exception {
188  1 final Element ele = BasicParser.createElement("<FUNCON> <A/> </FUNCON>");
189    // System.out.println(ele.toString());
190  1 LogicalCheckExceptionList list =
191    checker.checkTerm(ele, context, getChecker());
192  1 assertEquals(1, list.size());
193  1 assertEquals(30730, list.get(0).getErrorCode());
194    }
195   
196    /**
197    * Function: checkTerm(Element)
198    * Type: negative, code 30770
199    * Data: f(x, {x| phi})
200    *
201    * @throws Exception Test failed.
202    */
 
203  1 toggle public void testFunctionTermNegative15() throws Exception {
204  1 final Element ele = BasicParser.createElement(
205    "<FUNVAR id=\"f\">"
206    + "<VAR id=\"x\"/>"
207    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
208    + "</FUNVAR>");
209    // System.out.println(ele.toString());
210  1 LogicalCheckExceptionList list =
211    checker.checkTerm(ele, context, getChecker());
212  1 assertEquals(1, list.size());
213  1 assertEquals(30770, list.get(0).getErrorCode());
214    }
215   
216    /**
217    * Function: checkTerm(Element)
218    * Type: negative, code 30770
219    * Data: x union {x| phi}
220    *
221    * @throws Exception Test failed.
222    */
 
223  1 toggle public void testFunctionTermNegative16() throws Exception {
224  1 final Element ele = BasicParser.createElement(
225    "<FUNCON ref=\"union\">"
226    + "<VAR id=\"x\"/>"
227    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
228    + "</FUNCON>");
229    // System.out.println(ele.toString());
230  1 LogicalCheckExceptionList list =
231    checker.checkTerm(ele, context, getChecker());
232  1 assertEquals(1, list.size());
233  1 assertEquals(30770, list.get(0).getErrorCode());
234    }
235   
236    /**
237    * Function: checkTerm(Element)
238    * Type: negative, code 30780
239    * Data: f({x| phi}, x)
240    *
241    * @throws Exception Test failed.
242    */
 
243  1 toggle public void testFunctionTermNegative19() throws Exception {
244  1 final Element ele = BasicParser.createElement(
245    "<FUNVAR id=\"f\">"
246    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
247    + "<VAR id=\"x\"/>"
248    + "</FUNVAR>");
249    // System.out.println(ele.toString());
250  1 LogicalCheckExceptionList list =
251    checker.checkTerm(ele, context, getChecker());
252  1 assertEquals(1, list.size());
253  1 assertEquals(30780, list.get(0).getErrorCode());
254    }
255   
256    /**
257    * Function: checkTerm(Element)
258    * Type: negative, code 30780
259    * Data: {x| phi} union x
260    *
261    * @throws Exception Test failed.
262    */
 
263  1 toggle public void testFunctionTermNegative20() throws Exception {
264  1 final Element ele = BasicParser.createElement(
265    "<FUNCON id=\"union\">"
266    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
267    + "<VAR id=\"x\"/>"
268    + "</FUNCON>");
269    // System.out.println(ele.toString());
270  1 LogicalCheckExceptionList list =
271    checker.checkTerm(ele, context, getChecker());
272  1 assertEquals(1, list.size());
273  1 assertEquals(30780, list.get(0).getErrorCode());
274    }
275   
276    /**
277    * Function: checkTerm(Element)
278    * Type: negative, code 30690
279    * Data: F(x) (unknown function constant)
280    *
281    * @throws Exception Test failed.
282    */
 
283  1 toggle public void testFunctionTermNegative22() throws Exception {
284  1 final Element ele = BasicParser.createElement(
285    "<FUNCON id=\"F\" />");
286    // System.out.println(ele.toString());
287  1 LogicalCheckExceptionList list =
288    checker.checkTerm(ele, context, getChecker());
289  1 assertEquals(1, list.size());
290  1 assertEquals(30690, list.get(0).getErrorCode());
291    }
292   
293    }