Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
27   146   8   3.38
0   63   0.3   8
8     1  
1    
 
  FormulaCheckerFormulaTest       Line # 31 27 8 100% 1.0
 
No Tests
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, 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.bo.logic.common.FormulaChecker;
19    import org.qedeq.kernel.bo.logic.common.LogicalCheckExceptionList;
20    import org.qedeq.kernel.se.base.list.Element;
21    import org.qedeq.kernel.se.common.DefaultModuleAddress;
22    import org.qedeq.kernel.se.common.ModuleContext;
23    import org.qedeq.kernel.xml.parser.BasicParser;
24   
25    /**
26    * For testing the {@link org.qedeq.kernel.bo.logic.FormulaChecker}.
27    * Testing formulas.
28    *
29    * @author Michael Meyling
30    */
 
31    public class FormulaCheckerFormulaTest extends AbstractFormulaChecker {
32   
33    private ModuleContext context;
34   
35    private FormulaChecker checker;
36   
 
37  6 toggle protected void setUp() throws Exception {
38  6 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"), "getElement()");
39  6 checker = new FormulaCheckerImpl();
40    }
41   
 
42  6 toggle protected void tearDown() throws Exception {
43  6 context = null;
44    }
45   
46    /**
47    * Function: checkFormula(Element)
48    * Type: positive
49    * Data: A
50    *
51    * @throws Exception Test failed.
52    */
 
53  1 toggle public void testFormulaPositive01() throws Exception {
54  1 final Element ele = BasicParser.createElement(
55    "<PREDVAR id=\"A\"/>");
56    // System.out.println(ele.toString());
57  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
58  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
59  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
60    .hasErrors());
61    }
62   
63    /**
64    * Function: checkFormula(Element)
65    * Type: positive
66    * Data: -A
67    *
68    * @throws Exception Test failed.
69    */
 
70  1 toggle public void testFormulaPositive02() throws Exception {
71  1 final Element ele = BasicParser.createElement(
72    "<NOT><PREDVAR id=\"A\"/></NOT>");
73    // System.out.println(ele.toString());
74  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
75  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
76  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
77    .hasErrors());
78    }
79   
80    /**
81    * Function: checkFormula(Element)
82    * Type: positive
83    * Data: true
84    *
85    * @throws Exception Test failed.
86    */
 
87  1 toggle public void testFormulaPositive03() throws Exception {
88  1 final Element ele = BasicParser.createElement(
89    "<PREDCON id=\"true\"/>");
90    // System.out.println(ele.toString());
91  1 assertFalse(checker.checkFormula(ele, context).hasErrors());
92  1 assertFalse(checker.checkFormula(ele, context, getChecker()).hasErrors());
93  1 assertFalse(checker.checkFormula(ele, context, getCheckerWithoutClass())
94    .hasErrors());
95    }
96   
97    /**
98    * Function: checkFormula(Element)
99    * Type: negative, code 30530, unknown formula operator
100    * Data: x
101    *
102    * @throws Exception Test failed.
103    */
 
104  1 toggle public void testFormulaNegative01() throws Exception {
105  1 final Element ele = BasicParser.createElement("<VAR id=\"x\" />");
106    // System.out.println(ele.toString());
107  1 LogicalCheckExceptionList list =
108    checker.checkFormula(ele, context, getChecker());
109  1 assertEquals(1, list.size());
110  1 assertEquals(30530, list.get(0).getErrorCode());
111    }
112   
113    /**
114    * Function: checkFormula(Element)
115    * Type: negative, code 30530, unknown formula operator
116    * Data: f(x)
117    *
118    * @throws Exception Test failed.
119    */
 
120  1 toggle public void testFormulaNegative02() throws Exception {
121  1 final Element ele = BasicParser.createElement("<FUNVAR id=\"f\"><VAR id=\"x\" /></FUNVAR>");
122    // System.out.println(ele.toString());
123  1 LogicalCheckExceptionList list =
124    checker.checkFormula(ele, context, getChecker());
125  1 assertEquals(1, list.size());
126  1 assertEquals(30530, list.get(0).getErrorCode());
127    }
128   
129    /**
130    * Function: checkFormula(Element)
131    * Type: negative, code 30530, unknown formula operator
132    * Data: {}
133    *
134    * @throws Exception Test failed.
135    */
 
136  1 toggle public void testFormulaNegative03() throws Exception {
137  1 final Element ele = BasicParser.createElement("<FUNCON id=\"empty\"></FUNCON>");
138    // System.out.println(ele.toString());
139  1 LogicalCheckExceptionList list =
140    checker.checkFormula(ele, context, getChecker());
141  1 assertEquals(1, list.size());
142  1 assertEquals(30530, list.get(0).getErrorCode());
143    }
144   
145   
146    }