Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
54   293   16   3.38
0   139   0.3   16
16     1  
1    
 
  FormulaCheckerTermTest       Line # 30 54 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.
26    *
27    * @version $Revision: 1.1 $
28    * @author Michael Meyling
29    */
 
30    public class FormulaCheckerTermTest 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: {x | x in a & x in b}
46    *
47    * @throws Exception Test failed.
48    */
 
49  1 toggle public void testTermPositive01() throws Exception {
50  1 final Element ele = TestParser.createElement(
51    "<CLASS>" +
52    " <VAR id=\"x\" />" +
53    " <AND>" +
54    " <PREDCON id=\"in\">" +
55    " <VAR id=\"x\" />" +
56    " <VAR id=\"a\" />" +
57    " </PREDCON>" +
58    " <PREDCON id=\"in\">" +
59    " <VAR id=\"x\" />" +
60    " <VAR id=\"b\" />" +
61    " </PREDCON>" +
62    " </AND>" +
63    "</CLASS>");
64    // System.out.println(ele.toString());
65  1 assertFalse(FormulaChecker.checkTerm(ele, context).hasErrors());
66  1 assertFalse(FormulaChecker.checkTerm(ele, context, getChecker()).hasErrors());
67    }
68   
69    /**
70    * Function: checkTerm(Element)
71    * Type: positive
72    * Data: f(x, y, x)
73    *
74    * @throws Exception Test failed.
75    */
 
76  1 toggle public void testTermPositive02() throws Exception {
77  1 final Element ele = TestParser.createElement(
78    "<FUNVAR id=\"f\">" +
79    " <VAR id=\"x\" />" +
80    " <VAR id=\"y\" />" +
81    " <VAR id=\"x\" />" +
82    "</FUNVAR>");
83    // System.out.println(ele.toString());
84  1 assertFalse(FormulaChecker.checkTerm(ele, context).hasErrors());
85  1 assertFalse(FormulaChecker.checkTerm(ele, context, getChecker()).hasErrors());
86    }
87   
88    /**
89    * Function: checkTerm(Element)
90    * Type: positive
91    * Data: Power(x union y)
92    *
93    * @throws Exception Test failed.
94    */
 
95  1 toggle public void testTermPositive03() throws Exception {
96  1 final Element ele = TestParser.createElement(
97    "<FUNCON id=\"power\">" +
98    " <FUNCON id=\"union\">" +
99    " <VAR id=\"x\" />" +
100    " <VAR id=\"y\" />" +
101    " </FUNCON>" +
102    "</FUNCON>");
103    // System.out.println(ele.toString());
104  1 assertFalse(FormulaChecker.checkTerm(ele, context).hasErrors());
105  1 assertFalse(FormulaChecker.checkTerm(ele, context, getChecker()).hasErrors());
106    }
107   
108    /**
109    * Function: checkTerm(Element)
110    * Type: positive
111    * Data: x
112    *
113    * @throws Exception Test failed.
114    */
 
115  1 toggle public void testTermPositive04() throws Exception {
116  1 final Element ele = TestParser.createElement(
117    "<VAR id=\"x\" />");
118    // System.out.println(ele.toString());
119  1 assertFalse(FormulaChecker.checkTerm(ele, context).hasErrors());
120  1 assertFalse(FormulaChecker.checkTerm(ele, context, getChecker()).hasErrors());
121    }
122   
123    /**
124    * Function: checkTerm(Element)
125    * Type: negative, code 30620, unknown term operator
126    * Data: A & B
127    *
128    * @throws Exception Test failed.
129    */
 
130  1 toggle public void testTermNegative01() throws Exception {
131  1 final Element ele = TestParser.createElement(
132    "<AND><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></AND>");
133    // System.out.println(ele.toString());
134  1 LogicalCheckExceptionList list =
135    FormulaChecker.checkTerm(ele, context, getChecker());
136  1 assertEquals(1, list.size());
137  1 assertEquals(30620, list.get(0).getErrorCode());
138    }
139   
140    /**
141    * Function: checkTerm(Element)
142    * Type: negative, code 30620, unknown term operator
143    * Data: UNKNOWN(A & B)
144    *
145    * @throws Exception Test failed.
146    */
 
147  1 toggle public void testTermNegative02() throws Exception {
148  1 final Element ele = TestParser.createElement(
149    "<UNKNOWN><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></UNKNOWN>");
150    // System.out.println(ele.toString());
151  1 LogicalCheckExceptionList list =
152    FormulaChecker.checkTerm(ele, context, getChecker());
153  1 assertEquals(1, list.size());
154  1 assertEquals(30620, list.get(0).getErrorCode());
155    }
156   
157    /**
158    * Function: checkTerm(Element)
159    * Type: negative, code 30620, unknown term operator
160    * Data: A v B
161    *
162    * @throws Exception Test failed.
163    */
 
164  1 toggle public void testTermNegative03() throws Exception {
165  1 final Element ele = TestParser.createElement(
166    "<OR><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></OR>");
167    // System.out.println(ele.toString());
168  1 LogicalCheckExceptionList list =
169    FormulaChecker.checkTerm(ele, context, getChecker());
170  1 assertEquals(1, list.size());
171  1 assertEquals(30620, list.get(0).getErrorCode());
172    }
173   
174    /**
175    * Function: checkTerm(Element)
176    * Type: negative, code 30620, unknown term operator
177    * Data: A -> B
178    *
179    * @throws Exception Test failed.
180    */
 
181  1 toggle public void testTermNegative04() throws Exception {
182  1 final Element ele = TestParser.createElement(
183    "<IMPL><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></IMPL>");
184    // System.out.println(ele.toString());
185  1 LogicalCheckExceptionList list =
186    FormulaChecker.checkTerm(ele, context, getChecker());
187  1 assertEquals(1, list.size());
188  1 assertEquals(30620, list.get(0).getErrorCode());
189    }
190   
191    /**
192    * Function: checkTerm(Element)
193    * Type: negative, code 30620, unknown term operator
194    * Data: A <-> B
195    *
196    * @throws Exception Test failed.
197    */
 
198  1 toggle public void testTermNegative05() throws Exception {
199  1 final Element ele = TestParser.createElement(
200    "<EQUI><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></EQUI>");
201    // System.out.println(ele.toString());
202  1 LogicalCheckExceptionList list =
203    FormulaChecker.checkTerm(ele, context, getChecker());
204  1 assertEquals(1, list.size());
205  1 assertEquals(30620, list.get(0).getErrorCode());
206    }
207   
208    /**
209    * Function: checkTerm(Element)
210    * Type: negative, code 30620, unknown term operator
211    * Data: -A
212    *
213    * @throws Exception Test failed.
214    */
 
215  1 toggle public void testTermNegative06() throws Exception {
216  1 final Element ele = TestParser.createElement(
217    "<NOT><PREDVAR id=\"A\"/></NOT>");
218    // System.out.println(ele.toString());
219  1 LogicalCheckExceptionList list =
220    FormulaChecker.checkTerm(ele, context, getChecker());
221  1 assertEquals(1, list.size());
222  1 assertEquals(30620, list.get(0).getErrorCode());
223    }
224   
225    /**
226    * Function: checkTerm(Element)
227    * Type: negative, code 30620, unknown term operator
228    * Data: A
229    *
230    * @throws Exception Test failed.
231    */
 
232  1 toggle public void testTermNegative07() throws Exception {
233  1 final Element ele = TestParser.createElement(
234    "<PREDVAR id=\"A\"/>");
235    // System.out.println(ele.toString());
236  1 LogicalCheckExceptionList list =
237    FormulaChecker.checkTerm(ele, context, getChecker());
238  1 assertEquals(1, list.size());
239  1 assertEquals(30620, list.get(0).getErrorCode());
240    }
241   
242    /**
243    * Function: checkTerm(Element)
244    * Type: negative, code 30620, unknown term operator
245    * Data: all x A
246    *
247    * @throws Exception Test failed.
248    */
 
249  1 toggle public void testTermNegative08() throws Exception {
250  1 final Element ele = TestParser.createElement(
251    "<FORALL><VAR id=\"x\" /><PREDVAR id=\"A\"/></FORALL>");
252    // System.out.println(ele.toString());
253  1 LogicalCheckExceptionList list =
254    FormulaChecker.checkTerm(ele, context, getChecker());
255  1 assertEquals(1, list.size());
256  1 assertEquals(30620, list.get(0).getErrorCode());
257    }
258   
259    /**
260    * Function: checkTerm(Element)
261    * Type: negative, code 30620, unknown term operator
262    * Data: exists x A
263    *
264    * @throws Exception Test failed.
265    */
 
266  1 toggle public void testTermNegative09() throws Exception {
267  1 final Element ele = TestParser.createElement(
268    "<EXISTS><VAR id=\"x\" /><PREDVAR id=\"A\"/></EXISTS>");
269    // System.out.println(ele.toString());
270  1 LogicalCheckExceptionList list =
271    FormulaChecker.checkTerm(ele, context, getChecker());
272  1 assertEquals(1, list.size());
273  1 assertEquals(30620, list.get(0).getErrorCode());
274    }
275   
276    /**
277    * Function: checkTerm(Element)
278    * Type: negative, code 30620, unknown term operator
279    * Data: exists! x A
280    *
281    * @throws Exception Test failed.
282    */
 
283  1 toggle public void testTermNegative10() throws Exception {
284  1 final Element ele = TestParser.createElement(
285    "<EXISTSU><VAR id=\"x\" /><PREDVAR id=\"A\"/></EXISTSU>");
286    // System.out.println(ele.toString());
287  1 LogicalCheckExceptionList list =
288    FormulaChecker.checkTerm(ele, context, getChecker());
289  1 assertEquals(1, list.size());
290  1 assertEquals(30620, list.get(0).getErrorCode());
291    }
292   
293    }