Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../../img/srcFileCovDistChart6.png 73% of files have more coverage
157   797   122   1.29
0   503   0.78   122
122     1  
1    
 
  FormulaCheckerGlobalTest       Line # 35 157 122 53.4% 0.53405017
 
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 java.util.List;
19   
20    import org.qedeq.kernel.base.list.Atom;
21    import org.qedeq.kernel.base.list.Element;
22    import org.qedeq.kernel.base.list.ElementList;
23    import org.qedeq.kernel.bo.logic.FormulaChecker;
24    import org.qedeq.kernel.common.DefaultModuleAddress;
25    import org.qedeq.kernel.common.ModuleContext;
26    import org.qedeq.kernel.dto.list.DefaultAtom;
27    import org.qedeq.kernel.dto.list.DefaultElementList;
28   
29    /**
30    * For testing the {@link org.qedeq.kernel.bo.logic.FormulaChecker}.
31    *
32    * @version $Revision: 1.1 $
33    * @author Michael Meyling
34    */
 
35    public class FormulaCheckerGlobalTest extends AbstractFormulaChecker {
36   
37    /** Module context for module access. */
38    private ModuleContext context;
39   
 
40  19 toggle protected void setUp() throws Exception {
41  19 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"),
42    "getElement()");
43    }
44   
 
45  19 toggle protected void tearDown() throws Exception {
46  19 context = null;
47    }
48   
49    /**
50    * Function: checkFormula(Element).
51    * Type: positive
52    * Data: y = { x | phi(x)} <-> (all z: z in y <-> z in {x | phi(x)})
53    *
54    * @throws Exception Test failed.
55    */
 
56  1 toggle public void testGlobalFormulaPositive() throws Exception {
57  1 final Element ele = new DefaultElementList("EQUI", new Element[] {
58    new DefaultElementList("PREDCON", new Element[] {
59    new DefaultAtom("equal"),
60    new DefaultElementList("VAR", new Element[] {
61    new DefaultAtom("y"),
62    }),
63    new DefaultElementList("CLASS", new Element[] {
64    new DefaultElementList("VAR", new Element[] {
65    new DefaultAtom("x"),
66    }),
67    new DefaultElementList("PREDVAR", new Element[] {
68    new DefaultAtom("\\phi"),
69    new DefaultElementList("VAR", new Element[] {
70    new DefaultAtom("x"),
71    })
72    })
73    })
74    }),
75    new DefaultElementList("FORALL", new Element[] {
76    new DefaultElementList("VAR", new Element[] {
77    new DefaultAtom("z"),
78    }),
79    new DefaultElementList("EQUI", new Element[] {
80    new DefaultElementList("PREDCON", new Element[] {
81    new DefaultAtom("in"),
82    new DefaultElementList("VAR", new Element[] {
83    new DefaultAtom("z"),
84    }),
85    new DefaultElementList("VAR", new Element[] {
86    new DefaultAtom("y"),
87    })
88    }),
89    new DefaultElementList("PREDCON", new Element[] {
90    new DefaultAtom("in"),
91    new DefaultElementList("VAR", new Element[] {
92    new DefaultAtom("z"),
93    }),
94    new DefaultElementList("CLASS", new Element[] {
95    new DefaultElementList("VAR", new Element[] {
96    new DefaultAtom("x"),
97    }),
98    new DefaultElementList("PREDVAR", new Element[] {
99    new DefaultAtom("\\phi"),
100    new DefaultElementList("VAR", new Element[] {
101    new DefaultAtom("x"),
102    })
103    })
104    })
105    })
106    })
107    })
108    });
109    // System.out.println(ele.toString());
110  1 assertFalse(FormulaChecker.checkFormula(ele, context).hasErrors());
111  1 assertFalse(FormulaChecker.checkFormula(ele, context, getChecker()).hasErrors());
112    }
113   
114    /**
115    * Function: checkFormula(Element).
116    * Type: negative, code 30400
117    * Data: element null
118    *
119    * @throws Exception Test failed.
120    */
 
121  1 toggle public void testGlobalFormulaNegative01() throws Exception {
122  1 LogicalCheckExceptionList list =
123    FormulaChecker.checkFormula(null, context);
124  1 assertEquals(1, list.size());
125  1 assertEquals(30400, list.get(0).getErrorCode());
126    }
127   
128    /**
129    * Function: checkTerm(Element).
130    * Type: negative, code 30400
131    * Data: element null
132    *
133    * @throws Exception Test failed.
134    */
 
135  1 toggle public void testGlobalTermNegative01() throws Exception {
136  1 LogicalCheckExceptionList list =
137    FormulaChecker.checkFormula(null, context);
138  1 assertEquals(1, list.size());
139  1 assertEquals(30400, list.get(0).getErrorCode());
140    }
141   
142    /**
143    * Function: checkFormula(Element).
144    * Type: negative, code 30410
145    * Data: element getAtom() null
146    *
147    * @throws Exception Test failed.
148    */
 
149  1 toggle public void testGlobalFormulaNegative03() throws Exception {
150  1 LogicalCheckExceptionList list =
151    FormulaChecker.checkFormula(new DefaultElementList("PREDVAR", new Element[]{new Atom() {
152   
 
153  0 toggle public String getString() {
154  0 return null;
155    }
156   
 
157  1 toggle public boolean isAtom() {
158  1 return true;
159    }
160   
 
161  1 toggle public Atom getAtom() {
162  1 return null;
163    }
164   
 
165  0 toggle public boolean isList() {
166  0 return false;
167    }
168   
 
169  0 toggle public ElementList getList() {
170  0 return null;
171    }
172   
 
173  0 toggle public Element copy() {
174  0 return null;
175    }
176   
 
177  0 toggle public Element replace(final Element search, final Element replacement) {
178  0 return null;
179    }
180    }
181    }), context);
182  1 assertEquals(1, list.size());
183  1 assertEquals(30410, list.get(0).getErrorCode());
184    }
185   
186    /**
187    * Function: checkTerm(Element).
188    * Type: negative, code 30410
189    * Data: element getAtom() null
190    *
191    * @throws Exception Test failed.
192    */
 
193  1 toggle public void testGlobalFormulaNegative04() throws Exception {
194  1 LogicalCheckExceptionList list =
195    FormulaChecker.checkTerm(new DefaultElementList("FUNCON", new Element[] {new Atom() {
196   
 
197  0 toggle public String getString() {
198  0 return null;
199    }
200   
 
201  1 toggle public boolean isAtom() {
202  1 return true;
203    }
204   
 
205  1 toggle public Atom getAtom() {
206  1 return null;
207    }
208   
 
209  0 toggle public boolean isList() {
210  0 return false;
211    }
212   
 
213  0 toggle public ElementList getList() {
214  0 return null;
215    }
216   
 
217  0 toggle public Element copy() {
218  0 return null;
219    }
220   
 
221  0 toggle public Element replace(final Element search, final Element replacement) {
222  0 return null;
223    }
224    }
225    }), context);
226  1 assertEquals(1, list.size());
227  1 assertEquals(30410, list.get(0).getErrorCode());
228    }
229   
230    /**
231    * Function: checkFormula(Element).
232    * Type: negative, code 30420
233    * Data: element getList() null
234    *
235    * @throws Exception Test failed.
236    */
 
237  1 toggle public void testGlobalFormulaNegative05() throws Exception {
238  1 LogicalCheckExceptionList list =
239    FormulaChecker.checkFormula(new Element() {
240   
 
241  0 toggle public boolean isAtom() {
242  0 return false;
243    }
244   
 
245  0 toggle public Atom getAtom() {
246  0 return null;
247    }
248   
 
249  1 toggle public boolean isList() {
250  1 return true;
251    }
252   
 
253  1 toggle public ElementList getList() {
254  1 return null;
255    }
256   
 
257  0 toggle public Element copy() {
258  0 return null;
259    }
260   
 
261  0 toggle public Element replace(final Element search, final Element replacement) {
262  0 return null;
263    }
264    }, context);
265  1 assertEquals(1, list.size());
266  1 assertEquals(30420, list.get(0).getErrorCode());
267    }
268   
269    /**
270    * Function: checkTerm(Element).
271    * Type: negative, code 30420
272    * Data: element getList() null
273    *
274    * @throws Exception Test failed.
275    */
 
276  1 toggle public void testGlobalFormulaNegative06() throws Exception {
277  1 LogicalCheckExceptionList list =
278    FormulaChecker.checkTerm(new Element() {
279   
 
280  0 toggle public boolean isAtom() {
281  0 return false;
282    }
283   
 
284  0 toggle public Atom getAtom() {
285  0 return null;
286    }
287   
 
288  1 toggle public boolean isList() {
289  1 return true;
290    }
291   
 
292  1 toggle public ElementList getList() {
293  1 return null;
294    }
295   
 
296  0 toggle public Element copy() {
297  0 return null;
298    }
299   
 
300  0 toggle public Element replace(final Element search, final Element replacement) {
301  0 return null;
302    }
303    }, context);
304  1 assertEquals(1, list.size());
305  1 assertEquals(30420, list.get(0).getErrorCode());
306    }
307   
308    /**
309    * Function: checkFormula(Element).
310    * Type: negative, code 30430
311    * Data: PREDVAR(null) (atom content is null)
312    *
313    * @throws Exception Test failed.
314    */
 
315  1 toggle public void testGlobalFormulaNegative07() throws Exception {
316  1 LogicalCheckExceptionList list =
317    FormulaChecker.checkFormula(new DefaultElementList("PREDVAR", new Element[]{new Atom() {
318   
 
319  1 toggle public String getString() {
320  1 return null;
321    }
322   
 
323  1 toggle public boolean isAtom() {
324  1 return true;
325    }
326   
 
327  1 toggle public Atom getAtom() {
328  1 return this;
329    }
330   
 
331  0 toggle public boolean isList() {
332  0 return false;
333    }
334   
 
335  0 toggle public ElementList getList() {
336  0 return null;
337    }
338   
 
339  0 toggle public Element copy() {
340  0 return null;
341    }
342   
 
343  0 toggle public Element replace(final Element search, final Element replacement) {
344  0 return null;
345    }
346    }
347    }), context);
348  1 assertEquals(1, list.size());
349  1 assertEquals(30430, list.get(0).getErrorCode());
350    }
351   
352    /**
353    * Function: checkTerm(Element).
354    * Type: negative, code 30430
355    * Data: FUNCON(null) (atom content is null)
356    *
357    * @throws Exception Test failed.
358    */
 
359  1 toggle public void testGlobalFormulaNegative08() throws Exception {
360  1 LogicalCheckExceptionList list =
361    FormulaChecker.checkTerm(new DefaultElementList("FUNCON", new Element[]{new Atom() {
362   
 
363  1 toggle public String getString() {
364  1 return null;
365    }
366   
 
367  1 toggle public boolean isAtom() {
368  1 return true;
369    }
370   
 
371  1 toggle public Atom getAtom() {
372  1 return this;
373    }
374   
 
375  0 toggle public boolean isList() {
376  0 return false;
377    }
378   
 
379  0 toggle public ElementList getList() {
380  0 return null;
381    }
382   
 
383  0 toggle public Element copy() {
384  0 return null;
385    }
386   
 
387  0 toggle public Element replace(final Element search, final Element replacement) {
388  0 return null;
389    }
390    }
391    }), context);
392  1 assertEquals(1, list.size());
393  1 assertEquals(30430, list.get(0).getErrorCode());
394    }
395   
396    /**
397    * Function: checkFormula(Element).
398    * Type: negative, code 30440
399    * Data: PREDVAR("") (atom contents has length 0)
400    *
401    * @throws Exception Test failed.
402    */
 
403  1 toggle public void testGlobalFormulaNegative09() throws Exception {
404  1 LogicalCheckExceptionList list =
405    FormulaChecker.checkFormula(new DefaultElementList("PREDVAR", new Element[]{new Atom() {
406   
 
407  2 toggle public String getString() {
408  2 return "";
409    }
410   
 
411  1 toggle public boolean isAtom() {
412  1 return true;
413    }
414   
 
415  1 toggle public Atom getAtom() {
416  1 return this;
417    }
418   
 
419  0 toggle public boolean isList() {
420  0 return false;
421    }
422   
 
423  0 toggle public ElementList getList() {
424  0 return null;
425    }
426   
 
427  0 toggle public Element copy() {
428  0 return null;
429    }
430   
 
431  0 toggle public Element replace(final Element search, final Element replacement) {
432  0 return null;
433    }
434    }
435    }), context);
436  1 assertEquals(1, list.size());
437  1 assertEquals(30440, list.get(0).getErrorCode());
438    }
439   
440    /**
441    * Function: checkFormula(Element).
442    * Type: negative, code 30440
443    * Data: PREDCON("") (atom contents has length 0)
444    *
445    * @throws Exception Test failed.
446    */
 
447  1 toggle public void testGlobalFormulaNegative11() throws Exception {
448  1 final Element ele = new DefaultElementList("PREDCON", new Element[] {
449    new DefaultAtom("")});
450    // System.out.println(ele.toString());
451  1 LogicalCheckExceptionList list =
452    FormulaChecker.checkFormula(ele, context);
453  1 assertEquals(1, list.size());
454  1 assertEquals(30440, list.get(0).getErrorCode());
455    }
456   
457    /**
458    * Function: checkTerm(Element).
459    * Type: negative, code 30440
460    * Data: FUNCON("") (atom contents has length 0)
461    *
462    * @throws Exception Test failed.
463    */
 
464  1 toggle public void testGlobalFormulaNegative12() throws Exception {
465  1 final Element ele = new DefaultElementList("FUNCON", new Element[] {
466    new DefaultAtom("")});
467    // System.out.println(ele.toString());
468  1 LogicalCheckExceptionList list =
469    FormulaChecker.checkTerm(ele, context);
470  1 assertEquals(1, list.size());
471  1 assertEquals(30440, list.get(0).getErrorCode());
472    }
473   
474    /**
475    * Function: checkFormula(Element).
476    * Type: negative, code 30450
477    * Data: operator is null
478    *
479    * @throws Exception Test failed.
480    */
 
481  1 toggle public void testGlobalFormulaNegative13() throws Exception {
482  1 final Element ele = new ElementList() {
483   
 
484  0 toggle public int size() {
485  0 return 0;
486    }
487   
 
488  1 toggle public String getOperator() {
489  1 return null;
490    }
491   
 
492  0 toggle public Element getElement(final int i) {
493  0 return null;
494    }
495   
 
496  0 toggle public List getElements() {
497  0 return null;
498    }
499   
 
500  0 toggle public void add(final Element element) {
501   
502    }
503   
 
504  0 toggle public void insert(final int position, final Element element) {
505    }
506   
 
507  0 toggle public void replace(final int position, final Element element) {
508    }
509   
 
510  0 toggle public void remove(final int i) {
511    }
512   
 
513  0 toggle public boolean isAtom() {
514  0 return false;
515    }
516   
 
517  0 toggle public Atom getAtom() {
518  0 return null;
519    }
520   
 
521  1 toggle public boolean isList() {
522  1 return true;
523    }
524   
 
525  1 toggle public ElementList getList() {
526  1 return this;
527    }
528   
 
529  0 toggle public Element copy() {
530  0 return null;
531    }
532   
 
533  0 toggle public Element replace(final Element search, final Element replacement) {
534  0 return null;
535    }
536   
537    };
538    // System.out.println(ele.toString());
539  1 LogicalCheckExceptionList list =
540    FormulaChecker.checkFormula(ele, context);
541  1 assertEquals(1, list.size());
542  1 assertEquals(30450, list.get(0).getErrorCode());
543    }
544   
545    /**
546    * Function: checkTerm(Element).
547    * Type: negative, code 30450
548    * Data: operator is null
549    *
550    * @throws Exception Test failed.
551    */
 
552  1 toggle public void testGlobalFormulaNegative14() throws Exception {
553  1 final Element ele = new ElementList() {
554   
 
555  0 toggle public int size() {
556  0 return 0;
557    }
558   
 
559  1 toggle public String getOperator() {
560  1 return null;
561    }
562   
 
563  0 toggle public Element getElement(final int i) {
564  0 return null;
565    }
566   
 
567  0 toggle public List getElements() {
568  0 return null;
569    }
570   
 
571  0 toggle public void add(final Element element) {
572   
573    }
574   
 
575  0 toggle public void insert(final int position, final Element element) {
576    }
577   
 
578  0 toggle public void replace(final int position, final Element element) {
579    }
580   
 
581  0 toggle public void remove(final int i) {
582    }
583   
 
584  0 toggle public boolean isAtom() {
585  0 return false;
586    }
587   
 
588  0 toggle public Atom getAtom() {
589  0 return null;
590    }
591   
 
592  1 toggle public boolean isList() {
593  1 return true;
594    }
595   
 
596  1 toggle public ElementList getList() {
597  1 return this;
598    }
599   
 
600  0 toggle public Element copy() {
601  0 return null;
602    }
603   
 
604  0 toggle public Element replace(final Element search, final Element replacement) {
605  0 return null;
606    }
607    };
608    // System.out.println(ele.toString());
609  1 LogicalCheckExceptionList list =
610    FormulaChecker.checkTerm(ele, context);
611  1 assertEquals(1, list.size());
612  1 assertEquals(30450, list.get(0).getErrorCode());
613    }
614   
615    /**
616    * Function: checkFormula(Element).
617    * Type: negative, code 30460
618    * Data: operator has length 0
619    *
620    * @throws Exception Test failed.
621    */
 
622  1 toggle public void testGlobalFormulaNegative15() throws Exception {
623  1 final Element ele = new Element() {
624   
 
625  0 toggle public boolean isAtom() {
626  0 return false;
627    }
628   
 
629  0 toggle public Atom getAtom() {
630  0 return null;
631    }
632   
 
633  1 toggle public boolean isList() {
634  1 return true;
635    }
636   
 
637  1 toggle public ElementList getList() {
638  1 return new DefaultElementList("", new Element[] {});
639    }
640   
 
641  0 toggle public Element copy() {
642  0 return null;
643    }
644   
 
645  0 toggle public Element replace(final Element search, final Element replacement) {
646  0 return null;
647    }
648    };
649  1 LogicalCheckExceptionList list =
650    FormulaChecker.checkFormula(ele, context);
651  1 assertEquals(1, list.size());
652  1 assertEquals(30460, list.get(0).getErrorCode());
653    }
654   
655    /**
656    * Function: checkTerm(Element).
657    * Type: negative, code 30460
658    * Data: operator has length 0
659    *
660    * @throws Exception Test failed.
661    */
 
662  1 toggle public void testGlobalFormulaNegative16() throws Exception {
663  1 final Element ele = new Element() {
664   
 
665  0 toggle public boolean isAtom() {
666  0 return false;
667    }
668   
 
669  0 toggle public Atom getAtom() {
670  0 return null;
671    }
672   
 
673  1 toggle public boolean isList() {
674  1 return true;
675    }
676   
 
677  1 toggle public ElementList getList() {
678  1 return new DefaultElementList("", new Element[] {});
679    }
680   
 
681  0 toggle public Element copy() {
682  0 return null;
683    }
684   
 
685  0 toggle public Element replace(final Element search, final Element replacement) {
686  0 return null;
687    }
688    };
689  1 LogicalCheckExceptionList list =
690    FormulaChecker.checkTerm(ele, context);
691  1 assertEquals(1, list.size());
692  1 assertEquals(30460, list.get(0).getErrorCode());
693    }
694   
695    /**
696    * Function: checkFormula(Element).
697    * Type: negative, code 30460
698    * Data: operator has length 0
699    *
700    * @throws Exception Test failed.
701    */
 
702  1 toggle public void testGlobalFormulaNegative21() throws Exception {
703  1 final Element ele = new ElementList() {
704   
 
705  0 toggle public int size() {
706  0 return 0;
707    }
708   
 
709  1 toggle public String getOperator() {
710  1 return "";
711    }
712   
 
713  0 toggle public Element getElement(final int i) {
714  0 return null;
715    }
716   
 
717  0 toggle public List getElements() {
718  0 return null;
719    }
720   
 
721  0 toggle public void add(final Element element) {
722   
723    }
724   
 
725  0 toggle public void insert(final int position, final Element element) {
726    }
727   
 
728  0 toggle public void replace(final int position, final Element element) {
729    }
730   
 
731  0 toggle public void remove(final int i) {
732    }
733   
 
734  0 toggle public boolean isAtom() {
735  0 return false;
736    }
737   
 
738  0 toggle public Atom getAtom() {
739  0 return null;
740    }
741   
 
742  1 toggle public boolean isList() {
743  1 return true;
744    }
745   
 
746  1 toggle public ElementList getList() {
747  1 return this;
748    }
749   
 
750  0 toggle public Element copy() {
751  0 return null;
752    }
753   
 
754  0 toggle public Element replace(final Element search, final Element replacement) {
755  0 return null;
756    }
757    };
758    // System.out.println(ele.toString());
759  1 LogicalCheckExceptionList list =
760    FormulaChecker.checkFormula(ele, context);
761  1 assertEquals(1, list.size());
762  1 assertEquals(30460, list.get(0).getErrorCode());
763    }
764   
765    /**
766    * Function: checkFormula(Element).
767    * Type: negative, code 30470
768    * Data:
769    *
770    * @throws Exception Test failed.
771    */
 
772  1 toggle public void testGlobalFormulaNegative23() throws Exception {
773  1 final Element ele = new DefaultAtom("Atom");
774    // System.out.println(ele.toString());
775  1 LogicalCheckExceptionList list =
776    FormulaChecker.checkFormula(ele, context);
777  1 assertEquals(1, list.size());
778  1 assertEquals(30470, list.get(0).getErrorCode());
779    }
780   
781    /**
782    * Function: checkTerm(Element).
783    * Type: negative, code 30470
784    * Data:
785    *
786    * @throws Exception Test failed.
787    */
 
788  1 toggle public void testGlobalFormulaNegative24() throws Exception {
789  1 final Element ele = new DefaultAtom("Atom");
790    // System.out.println(ele.toString());
791  1 LogicalCheckExceptionList list =
792    FormulaChecker.checkTerm(ele, context);
793  1 assertEquals(1, list.size());
794  1 assertEquals(30470, list.get(0).getErrorCode());
795    }
796   
797    }