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