Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
54   269   15   3.6
0   122   0.28   15
15     1  
1    
 
  FormulaCheckerPredicateFormulaTest       Line # 30 54 15 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 formulas made of predicate variables and predicate constants.
26    *
27    * @version $Revision: 1.1 $
28    * @author Michael Meyling
29    */
 
30    public class FormulaCheckerPredicateFormulaTest extends AbstractFormulaChecker {
31   
32    private ModuleContext context;
33   
 
34  13 toggle protected void setUp() throws Exception {
35  13 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"), "getElement()");
36    }
37   
 
38  13 toggle protected void tearDown() throws Exception {
39  13 context = null;
40    }
41   
42    /**
43    * Function: checkFormula(Element)
44    * Type: positive
45    * Data: A
46    *
47    * @throws Exception Test failed.
48    */
 
49  1 toggle public void testPredicateFormulaPositive01() throws Exception {
50  1 final Element ele = TestParser.createElement("<PREDVAR id=\"A\"/>");
51    // System.out.println(ele.toString());
52  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
53  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
54  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
55    .hasErrors());
56    }
57   
58    /**
59    * Function: checkFormula(Element)
60    * Type: positive
61    * Data: V
62    *
63    * @throws Exception Test failed.
64    */
 
65  1 toggle public void testPredicateFormulaPositive02() throws Exception {
66  1 final Element ele = TestParser.createElement("<PREDCON ref=\"true\"/>");
67    // System.out.println(ele.toString());
68  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
69  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
70  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
71    .hasErrors());
72    }
73   
74    /**
75    * Function: checkFormula(Element)
76    * Type: negative, code 30720
77    * Data: no function variable name
78    *
79    * @throws Exception Test failed.
80    */
 
81  1 toggle public void testPredicateFormulaNegative01() throws Exception {
82  1 final Element ele = TestParser.createElement("<PREDVAR />");
83    // System.out.println(ele.toString());
84  1 LogicalCheckExceptionList list =
85    FormulaChecker.checkFormula(ele, context, getChecker());
86  1 assertEquals(1, list.size());
87  1 assertEquals(30720, list.get(0).getErrorCode());
88    }
89   
90    /**
91    * Function: checkFormula(Element)
92    * Type: negative, code 30720
93    * Data: no function constant name
94    *
95    * @throws Exception Test failed.
96    */
 
97  1 toggle public void testPredicateFormulaNegative02() throws Exception {
98  1 final Element ele = TestParser.createElement("<PREDCON />");
99    // System.out.println(ele.toString());
100  1 LogicalCheckExceptionList list =
101    FormulaChecker.checkFormula(ele, context, getChecker());
102  1 assertEquals(1, list.size());
103  1 assertEquals(30720, list.get(0).getErrorCode());
104    }
105   
106    /**
107    * Function: checkFormula(Element)
108    * Type: negative, code 30730
109    * Data: function name missing (but list instead of name)
110    *
111    * @throws Exception Test failed.
112    */
 
113  1 toggle public void testPredicateFormulaNegative09() throws Exception {
114  1 final Element ele = TestParser.createElement("<PREDVAR > <VAR id=\"x\" /> </PREDVAR>");
115    // System.out.println(ele.toString());
116  1 LogicalCheckExceptionList list =
117    FormulaChecker.checkFormula(ele, context, getChecker());
118  1 assertEquals(1, list.size());
119  1 assertEquals(30730, list.get(0).getErrorCode());
120    }
121   
122   
123    /**
124    * Function: checkFormula(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 testPredicateFormulaNegative10() throws Exception {
131  1 final Element ele = TestParser.createElement("<PREDCON > <VAR id=\"x\" /> </PREDCON>");
132    // System.out.println(ele.toString());
133  1 LogicalCheckExceptionList list =
134    FormulaChecker.checkFormula(ele, context, getChecker());
135  1 assertEquals(1, list.size());
136  1 assertEquals(30730, list.get(0).getErrorCode());
137    }
138   
139   
140    /**
141    * Function: checkFormula(Element)
142    * Type: negative, code 30730
143    * Data: function name missing
144    *
145    * @throws Exception Test failed.
146    */
 
147  1 toggle public void testPredicateFormulaNegative13() throws Exception {
148  1 final Element ele = TestParser.createElement("<PREDVAR> <A/> </PREDVAR>");
149    // System.out.println(ele.toString());
150  1 LogicalCheckExceptionList list =
151    FormulaChecker.checkFormula(ele, context, getChecker());
152  1 assertEquals(1, list.size());
153  1 assertEquals(30730, list.get(0).getErrorCode());
154    }
155   
156    /**
157    * Function: checkFormula(Element)
158    * Type: negative, code 30730
159    * Data: function name missing
160    *
161    * @throws Exception Test failed.
162    */
 
163  1 toggle public void testPredicateFormulaNegative14() throws Exception {
164  1 final Element ele = TestParser.createElement("<PREDCON> <A/> </PREDCON>");
165    // System.out.println(ele.toString());
166  1 LogicalCheckExceptionList list =
167    FormulaChecker.checkFormula(ele, context, getChecker());
168  1 assertEquals(1, list.size());
169  1 assertEquals(30730, list.get(0).getErrorCode());
170    }
171   
172    /**
173    * Function: checkFormula(Element)
174    * Type: negative, code 30770
175    * Data: f(x, {x| phi})
176    *
177    * @throws Exception Test failed.
178    */
 
179  1 toggle public void testPredicateFormulaNegative15() throws Exception {
180  1 final Element ele = TestParser.createElement(
181    "<PREDVAR id=\"f\">"
182    + "<VAR id=\"x\"/>"
183    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
184    + "</PREDVAR>");
185    // System.out.println(ele.toString());
186  1 LogicalCheckExceptionList list =
187    FormulaChecker.checkFormula(ele, context, getChecker());
188  1 assertEquals(1, list.size());
189  1 assertEquals(30770, list.get(0).getErrorCode());
190    }
191   
192    /**
193    * Function: checkFormula(Element)
194    * Type: negative, code 30770
195    * Data: x in {x| phi}
196    *
197    * @throws Exception Test failed.
198    */
 
199  1 toggle public void testPredicateFormulaNegative16() throws Exception {
200  1 final Element ele = TestParser.createElement(
201    "<PREDCON ref=\"in\">"
202    + "<VAR id=\"x\"/>"
203    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
204    + "</PREDCON>");
205    // System.out.println(ele.toString());
206  1 LogicalCheckExceptionList list =
207    FormulaChecker.checkFormula(ele, context, getChecker());
208  1 assertEquals(1, list.size());
209  1 assertEquals(30770, list.get(0).getErrorCode());
210    }
211   
212    /**
213    * Function: checkFormula(Element)
214    * Type: negative, code 30780
215    * Data: f({x| phi}, x)
216    *
217    * @throws Exception Test failed.
218    */
 
219  1 toggle public void testPredicateFormulaNegative19() throws Exception {
220  1 final Element ele = TestParser.createElement(
221    "<PREDVAR id=\"f\">"
222    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
223    + "<VAR id=\"x\"/>"
224    + "</PREDVAR>");
225    // System.out.println(ele.toString());
226  1 LogicalCheckExceptionList list =
227    FormulaChecker.checkFormula(ele, context, getChecker());
228  1 assertEquals(1, list.size());
229  1 assertEquals(30780, list.get(0).getErrorCode());
230    }
231   
232    /**
233    * Function: checkFormula(Element)
234    * Type: negative, code 30780
235    * Data: {x| phi} in x
236    *
237    * @throws Exception Test failed.
238    */
 
239  1 toggle public void testPredicateFormulaNegative20() throws Exception {
240  1 final Element ele = TestParser.createElement(
241    "<PREDCON id=\"in\">"
242    + "<CLASS> <VAR id=\"x\"/> <PREDVAR id=\"\\phi\" /> </CLASS>"
243    + "<VAR id=\"x\"/>"
244    + "</PREDCON>");
245    // System.out.println(ele.toString());
246  1 LogicalCheckExceptionList list =
247    FormulaChecker.checkFormula(ele, context, getChecker());
248  1 assertEquals(1, list.size());
249  1 assertEquals(30780, list.get(0).getErrorCode());
250    }
251   
252    /**
253    * Function: checkFormula(Element)
254    * Type: negative, code 30590
255    * Data: F(x) (unknown predicate constant)
256    *
257    * @throws Exception Test failed.
258    */
 
259  1 toggle public void testPredicateFormulaNegative22() throws Exception {
260  1 final Element ele = TestParser.createElement(
261    "<PREDCON id=\"F\" />");
262    // System.out.println(ele.toString());
263  1 LogicalCheckExceptionList list =
264    FormulaChecker.checkFormula(ele, context, getChecker());
265  1 assertEquals(1, list.size());
266  1 assertEquals(30590, list.get(0).getErrorCode());
267    }
268   
269    }