Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
98   538   26   3.77
0   294   0.27   26
26     1  
1    
 
  FormulaCheckerLogicalConnectivesTest       Line # 30 98 26 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 logical connectives.
26    *
27    * @version $Revision: 1.1 $
28    * @author Michael Meyling
29    */
 
30    public class FormulaCheckerLogicalConnectivesTest extends AbstractFormulaChecker {
31   
32    private ModuleContext context;
33   
 
34  24 toggle protected void setUp() throws Exception {
35  24 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"), "getElement()");
36    }
37   
 
38  24 toggle protected void tearDown() throws Exception {
39  24 context = null;
40    }
41   
42    /**
43    * Function: checkFormula(Element)
44    * Type: positive
45    * Data: A & B
46    *
47    * @throws Exception Test failed.
48    */
 
49  1 toggle public void testLogicalConnectivePositive01() throws Exception {
50  1 final Element ele = TestParser.createElement(
51    "<AND><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></AND>");
52    // System.out.println(ele.toString());
53  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
54  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
55  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
56    .hasErrors());
57    }
58   
59    /**
60    * Function: checkFormula(Element)
61    * Type: positive
62    * Data: A v B
63    *
64    * @throws Exception Test failed.
65    */
 
66  1 toggle public void testLogicalConnectivePositive02() throws Exception {
67  1 final Element ele = TestParser.createElement(
68    "<OR><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></OR>");
69    // System.out.println(ele.toString());
70  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
71  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
72  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
73    .hasErrors());
74    }
75   
76    /**
77    * Function: checkFormula(Element)
78    * Type: positive
79    * Data: A -> B
80    *
81    * @throws Exception Test failed.
82    */
 
83  1 toggle public void testLogicalConnectivePositive03() throws Exception {
84  1 final Element ele = TestParser.createElement(
85    "<IMPL><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></IMPL>");
86    // System.out.println(ele.toString());
87  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
88  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
89  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
90    .hasErrors());
91    }
92   
93    /**
94    * Function: checkFormula(Element)
95    * Type: positive
96    * Data: A <-> B
97    *
98    * @throws Exception Test failed.
99    */
 
100  1 toggle public void testLogicalConnectivePositive04() throws Exception {
101  1 final Element ele = TestParser.createElement(
102    "<EQUI><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/></EQUI>");
103    // System.out.println(ele.toString());
104  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
105  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
106  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
107    .hasErrors());
108    }
109   
110    /**
111    * Function: checkFormula(Element)
112    * Type: positive
113    * Data: A & B & C
114    *
115    * @throws Exception Test failed.
116    */
 
117  1 toggle public void testLogicalConnectivePositive05() throws Exception {
118  1 final Element ele = TestParser.createElement(
119    "<AND><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/><PREDVAR id=\"C\"/></AND>");
120    // System.out.println(ele.toString());
121  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
122  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
123  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
124    .hasErrors());
125    }
126   
127    /**
128    * Function: checkFormula(Element)
129    * Type: positive
130    * Data: A v B v C
131    *
132    * @throws Exception Test failed.
133    */
 
134  1 toggle public void testLogicalConnectivePositive06() throws Exception {
135  1 final Element ele = TestParser.createElement(
136    "<OR><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/><PREDVAR id=\"C\"/></OR>");
137    // System.out.println(ele.toString());
138  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
139  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
140  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
141    .hasErrors());
142    }
143   
144    /**
145    * Function: checkFormula(Element)
146    * Type: positive
147    * Data: A <-> B <--> C
148    *
149    * @throws Exception Test failed.
150    */
 
151  1 toggle public void testLogicalConnectivePositive07() throws Exception {
152  1 final Element ele = TestParser.createElement(
153    "<EQUI><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/><PREDVAR id=\"C\"/></EQUI>");
154    // System.out.println(ele.toString());
155  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
156  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
157  1 assertFalse(FormulaChecker.checkFormula(ele, context, getCheckerWithoutClass())
158    .hasErrors());
159    }
160   
161    /**
162    * Function: checkFormula(Element)
163    * Type: negative, code 30740
164    * Data: &
165    *
166    * @throws Exception Test failed.
167    */
 
168  1 toggle public void testLogicalConnectiveNegative01() throws Exception {
169  1 final Element ele = TestParser.createElement("<AND />");
170    // System.out.println(ele.toString());
171  1 LogicalCheckExceptionList list =
172    FormulaChecker.checkFormula(ele, context, getChecker());
173  1 assertEquals(1, list.size());
174  1 assertEquals(30740, list.get(0).getErrorCode());
175    }
176   
177    /**
178    * Function: checkFormula(Element)
179    * Type: negative, code 30740
180    * Data: v
181    *
182    * @throws Exception Test failed.
183    */
 
184  1 toggle public void testLogicalConnectiveNegative02() throws Exception {
185  1 final Element ele = TestParser.createElement("<OR />");
186    // System.out.println(ele.toString());
187  1 LogicalCheckExceptionList list =
188    FormulaChecker.checkFormula(ele, context, getChecker());
189  1 assertEquals(1, list.size());
190  1 assertEquals(30740, list.get(0).getErrorCode());
191    }
192   
193    /**
194    * Function: checkFormula(Element)
195    * Type: negative, code 30740
196    * Data: ->
197    *
198    * @throws Exception Test failed.
199    */
 
200  1 toggle public void testLogicalConnectiveNegative03() throws Exception {
201  1 final Element ele = TestParser.createElement("<IMPL />");
202    // System.out.println(ele.toString());
203  1 LogicalCheckExceptionList list =
204    FormulaChecker.checkFormula(ele, context, getChecker());
205  1 assertEquals(1, list.size());
206  1 assertEquals(30740, list.get(0).getErrorCode());
207    }
208   
209    /**
210    * Function: checkFormula(Element)
211    * Type: negative, code 30740
212    * Data: <->
213    *
214    * @throws Exception Test failed.
215    */
 
216  1 toggle public void testLogicalConnectiveNegative04() throws Exception {
217  1 final Element ele = TestParser.createElement("<EQUI />");
218    // System.out.println(ele.toString());
219  1 LogicalCheckExceptionList list =
220    FormulaChecker.checkFormula(ele, context, getChecker());
221  1 assertEquals(1, list.size());
222  1 assertEquals(30740, list.get(0).getErrorCode());
223    }
224   
225    /**
226    * Function: checkFormula(Element)
227    * Type: negative, code 30740
228    * Data: A &
229    *
230    * @throws Exception Test failed.
231    */
 
232  1 toggle public void testLogicalConnectiveNegative05() throws Exception {
233  1 final Element ele = TestParser.createElement("<AND><PREDVAR id=\"A\"/></AND>");
234    // System.out.println(ele.toString());
235  1 LogicalCheckExceptionList list =
236    FormulaChecker.checkFormula(ele, context, getChecker());
237  1 assertEquals(1, list.size());
238  1 assertEquals(30740, list.get(0).getErrorCode());
239    }
240   
241    /**
242    * Function: checkFormula(Element)
243    * Type: negative, code 30740
244    * Data: A v
245    *
246    * @throws Exception Test failed.
247    */
 
248  1 toggle public void testLogicalConnectiveNegative06() throws Exception {
249  1 final Element ele = TestParser.createElement("<OR><PREDVAR id=\"A\"/></OR>");
250    // System.out.println(ele.toString());
251  1 LogicalCheckExceptionList list =
252    FormulaChecker.checkFormula(ele, context, getChecker());
253  1 assertEquals(1, list.size());
254  1 assertEquals(30740, list.get(0).getErrorCode());
255    }
256   
257    /**
258    * Function: checkFormula(Element)
259    * Type: negative, code 30740
260    * Data: A ->
261    *
262    * @throws Exception Test failed.
263    */
 
264  1 toggle public void testLogicalConnectiveNegative07() throws Exception {
265  1 final Element ele = TestParser.createElement("<IMPL><PREDVAR id=\"A\"/></IMPL>");
266    // System.out.println(ele.toString());
267  1 LogicalCheckExceptionList list =
268    FormulaChecker.checkFormula(ele, context, getChecker());
269  1 assertEquals(1, list.size());
270  1 assertEquals(30740, list.get(0).getErrorCode());
271    }
272   
273    /**
274    * Function: checkFormula(Element)
275    * Type: negative, code 30740
276    * Data: A <->
277    *
278    * @throws Exception Test failed.
279    */
 
280  1 toggle public void testLogicalConnectiveNegative08() throws Exception {
281  1 final Element ele = TestParser.createElement("<EQUI><PREDVAR id=\"A\"/></EQUI>");
282    // System.out.println(ele.toString());
283  1 LogicalCheckExceptionList list =
284    FormulaChecker.checkFormula(ele, context, getChecker());
285  1 assertEquals(1, list.size());
286  1 assertEquals(30740, list.get(0).getErrorCode());
287    }
288   
289    /**
290    * Function: checkFormula(Element)
291    * Type: negative, code 30760
292    * Data: A -> B --> C
293    *
294    * @throws Exception Test failed.
295    */
 
296  1 toggle public void testLogicalConnectiveNegative09() throws Exception {
297  1 final Element ele = TestParser.createElement(
298    "<IMPL><PREDVAR id=\"A\"/><PREDVAR id=\"B\"/><PREDVAR id=\"C\"/></IMPL>");
299    // System.out.println(ele.toString());
300  1 LogicalCheckExceptionList list =
301    FormulaChecker.checkFormula(ele, context, getChecker());
302  1 assertEquals(1, list.size());
303  1 assertEquals(30760, list.get(0).getErrorCode());
304    }
305   
306    /**
307    * Function: checkFormula(Element)
308    * Type: negative, code 30770, free and bound variables mixed
309    * Data: (x = x) & (y = {x | phi})
310    *
311    * @throws Exception Test failed.
312    */
 
313  1 toggle public void testLogicalConnectiveNegative10() throws Exception {
314  1 final Element ele = TestParser.createElement(
315    "<AND>" +
316    "<PREDVAR id=\"equal\">" +
317    "<VAR id=\"x\" />" +
318    "<VAR id=\"x\" />" +
319    "</PREDVAR>" +
320    "<PREDVAR id=\"equal\">" +
321    "<VAR id=\"y\" />" +
322    "<CLASS>" +
323    "<VAR id=\"x\" />" +
324    "<PREDVAR id=\"phi\" />" +
325    "</CLASS>" +
326    "</PREDVAR>" +
327    "</AND>");
328    // System.out.println(ele.toString());
329  1 LogicalCheckExceptionList list =
330    FormulaChecker.checkFormula(ele, context, getChecker());
331  1 assertEquals(1, list.size());
332  1 assertEquals(30770, list.get(0).getErrorCode());
333    }
334   
335    /**
336    * Function: checkFormula(Element)
337    * Type: negative, code 30780, free and bound variables mixed
338    * Data: (y = {x | phi}) & (x = x)
339    *
340    * @throws Exception Test failed.
341    */
 
342  1 toggle public void testLogicalConnectiveNegative11() throws Exception {
343  1 final Element ele = TestParser.createElement(
344    "<AND>" +
345    "<PREDVAR id=\"equal\">" +
346    "<VAR id=\"y\" />" +
347    "<CLASS>" +
348    "<VAR id=\"x\" />" +
349    "<PREDVAR id=\"phi\" />" +
350    "</CLASS>" +
351    "</PREDVAR>" +
352    "<PREDVAR id=\"equal\">" +
353    "<VAR id=\"x\" />" +
354    "<VAR id=\"x\" />" +
355    "</PREDVAR>" +
356    "</AND>");
357    // System.out.println(ele.toString());
358  1 LogicalCheckExceptionList list =
359    FormulaChecker.checkFormula(ele, context, getChecker());
360  1 assertEquals(1, list.size());
361  1 assertEquals(30780, list.get(0).getErrorCode());
362    }
363   
364    /**
365    * Function: checkFormula(Element)
366    * Type: negative, code 30770, free and bound variables mixed
367    * Data: (x = x) v (y = {x | phi})
368    *
369    * @throws Exception Test failed.
370    */
 
371  1 toggle public void testLogicalConnectiveNegative12() throws Exception {
372  1 final Element ele = TestParser.createElement(
373    "<OR>" +
374    "<PREDVAR id=\"equal\">" +
375    "<VAR id=\"x\" />" +
376    "<VAR id=\"x\" />" +
377    "</PREDVAR>" +
378    "<PREDVAR id=\"equal\">" +
379    "<VAR id=\"y\" />" +
380    "<CLASS>" +
381    "<VAR id=\"x\" />" +
382    "<PREDVAR id=\"phi\" />" +
383    "</CLASS>" +
384    "</PREDVAR>" +
385    "</OR>");
386    // System.out.println(ele.toString());
387  1 LogicalCheckExceptionList list =
388    FormulaChecker.checkFormula(ele, context, getChecker());
389  1 assertEquals(1, list.size());
390  1 assertEquals(30770, list.get(0).getErrorCode());
391    }
392   
393    /**
394    * Function: checkFormula(Element)
395    * Type: negative, code 30780, free and bound variables mixed
396    * Data: (y = {x | phi}) v (x = x)
397    *
398    * @throws Exception Test failed.
399    */
 
400  1 toggle public void testLogicalConnectiveNegative13() throws Exception {
401  1 final Element ele = TestParser.createElement(
402    "<OR>" +
403    "<PREDVAR id=\"equal\">" +
404    "<VAR id=\"y\" />" +
405    "<CLASS>" +
406    "<VAR id=\"x\" />" +
407    "<PREDVAR id=\"phi\" />" +
408    "</CLASS>" +
409    "</PREDVAR>" +
410    "<PREDVAR id=\"equal\">" +
411    "<VAR id=\"x\" />" +
412    "<VAR id=\"x\" />" +
413    "</PREDVAR>" +
414    "</OR>");
415    // System.out.println(ele.toString());
416  1 LogicalCheckExceptionList list =
417    FormulaChecker.checkFormula(ele, context, getChecker());
418  1 assertEquals(1, list.size());
419  1 assertEquals(30780, list.get(0).getErrorCode());
420    }
421   
422    /**
423    * Function: checkFormula(Element)
424    * Type: negative, code 30770, free and bound variables mixed
425    * Data: (x = x) -> (y = {x | phi})
426    *
427    * @throws Exception Test failed.
428    */
 
429  1 toggle public void testLogicalConnectiveNegative14() throws Exception {
430  1 final Element ele = TestParser.createElement(
431    "<IMPL>" +
432    "<PREDVAR id=\"equal\">" +
433    "<VAR id=\"x\" />" +
434    "<VAR id=\"x\" />" +
435    "</PREDVAR>" +
436    "<PREDVAR id=\"equal\">" +
437    "<VAR id=\"y\" />" +
438    "<CLASS>" +
439    "<VAR id=\"x\" />" +
440    "<PREDVAR id=\"phi\" />" +
441    "</CLASS>" +
442    "</PREDVAR>" +
443    "</IMPL>");
444    // System.out.println(ele.toString());
445  1 LogicalCheckExceptionList list =
446    FormulaChecker.checkFormula(ele, context, getChecker());
447  1 assertEquals(1, list.size());
448  1 assertEquals(30770, list.get(0).getErrorCode());
449    }
450   
451    /**
452    * Function: checkFormula(Element)
453    * Type: negative, code 30780, free and bound variables mixed
454    * Data: (y = {x | phi}) -> (x = x)
455    *
456    * @throws Exception Test failed.
457    */
 
458  1 toggle public void testLogicalConnectiveNegative15() throws Exception {
459  1 final Element ele = TestParser.createElement(
460    "<IMPL>" +
461    "<PREDVAR id=\"equal\">" +
462    "<VAR id=\"y\" />" +
463    "<CLASS>" +
464    "<VAR id=\"x\" />" +
465    "<PREDVAR id=\"phi\" />" +
466    "</CLASS>" +
467    "</PREDVAR>" +
468    "<PREDVAR id=\"equal\">" +
469    "<VAR id=\"x\" />" +
470    "<VAR id=\"x\" />" +
471    "</PREDVAR>" +
472    "</IMPL>");
473    // System.out.println(ele.toString());
474  1 LogicalCheckExceptionList list =
475    FormulaChecker.checkFormula(ele, context, getChecker());
476  1 assertEquals(1, list.size());
477  1 assertEquals(30780, list.get(0).getErrorCode());
478    }
479   
480    /**
481    * Function: checkFormula(Element)
482    * Type: negative, code 30770, free and bound variables mixed
483    * Data: (x = x) <-> (y = {x | phi})
484    *
485    * @throws Exception Test failed.
486    */
 
487  1 toggle public void testLogicalConnectiveNegative16() throws Exception {
488  1 final Element ele = TestParser.createElement(
489    "<EQUI>" +
490    "<PREDVAR id=\"equal\">" +
491    "<VAR id=\"x\" />" +
492    "<VAR id=\"x\" />" +
493    "</PREDVAR>" +
494    "<PREDVAR id=\"equal\">" +
495    "<VAR id=\"y\" />" +
496    "<CLASS>" +
497    "<VAR id=\"x\" />" +
498    "<PREDVAR id=\"phi\" />" +
499    "</CLASS>" +
500    "</PREDVAR>" +
501    "</EQUI>");
502    // System.out.println(ele.toString());
503  1 LogicalCheckExceptionList list =
504    FormulaChecker.checkFormula(ele, context, getChecker());
505  1 assertEquals(1, list.size());
506  1 assertEquals(30770, list.get(0).getErrorCode());
507    }
508   
509    /**
510    * Function: checkFormula(Element)
511    * Type: negative, code 30780, free and bound variables mixed
512    * Data: (y = {x | phi}) <-> (x = x)
513    *
514    * @throws Exception Test failed.
515    */
 
516  1 toggle public void testLogicalConnectiveNegative17() throws Exception {
517  1 final Element ele = TestParser.createElement(
518    "<EQUI>" +
519    "<PREDVAR id=\"equal\">" +
520    "<VAR id=\"y\" />" +
521    "<CLASS>" +
522    "<VAR id=\"x\" />" +
523    "<PREDVAR id=\"phi\" />" +
524    "</CLASS>" +
525    "</PREDVAR>" +
526    "<PREDVAR id=\"equal\">" +
527    "<VAR id=\"x\" />" +
528    "<VAR id=\"x\" />" +
529    "</PREDVAR>" +
530    "</EQUI>");
531    // System.out.println(ele.toString());
532  1 LogicalCheckExceptionList list =
533    FormulaChecker.checkFormula(ele, context, getChecker());
534  1 assertEquals(1, list.size());
535  1 assertEquals(30780, list.get(0).getErrorCode());
536    }
537   
538    }