Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
../../../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
26   142   8   3.25
0   59   0.31   8
8     1  
1    
 
  FormulaCheckerFormulaTest       Line # 30 26 8 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.
26    *
27    * @version $Revision: 1.1 $
28    * @author Michael Meyling
29    */
 
30    public class FormulaCheckerFormulaTest extends AbstractFormulaChecker {
31   
32    private ModuleContext context;
33   
 
34  6 toggle protected void setUp() throws Exception {
35  6 context = new ModuleContext(new DefaultModuleAddress("http://memory.org/sample.xml"), "getElement()");
36    }
37   
 
38  6 toggle protected void tearDown() throws Exception {
39  6 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 testFormulaPositive01() throws Exception {
50  1 final Element ele = TestParser.createElement(
51    "<PREDVAR id=\"A\"/>");
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
63    *
64    * @throws Exception Test failed.
65    */
 
66  1 toggle public void testFormulaPositive02() throws Exception {
67  1 final Element ele = TestParser.createElement(
68    "<NOT><PREDVAR id=\"A\"/></NOT>");
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: true
80    *
81    * @throws Exception Test failed.
82    */
 
83  1 toggle public void testFormulaPositive03() throws Exception {
84  1 final Element ele = TestParser.createElement(
85    "<PREDCON id=\"true\"/>");
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: negative, code 30530, unknown formula operator
96    * Data: x
97    *
98    * @throws Exception Test failed.
99    */
 
100  1 toggle public void testFormulaNegative01() throws Exception {
101  1 final Element ele = TestParser.createElement("<VAR id=\"x\" />");
102    // System.out.println(ele.toString());
103  1 LogicalCheckExceptionList list =
104    FormulaChecker.checkFormula(ele, context, getChecker());
105  1 assertEquals(1, list.size());
106  1 assertEquals(30530, list.get(0).getErrorCode());
107    }
108   
109    /**
110    * Function: checkFormula(Element)
111    * Type: negative, code 30530, unknown formula operator
112    * Data: f(x)
113    *
114    * @throws Exception Test failed.
115    */
 
116  1 toggle public void testFormulaNegative02() throws Exception {
117  1 final Element ele = TestParser.createElement("<FUNVAR id=\"f\"><VAR id=\"x\" /></FUNVAR>");
118    // System.out.println(ele.toString());
119  1 LogicalCheckExceptionList list =
120    FormulaChecker.checkFormula(ele, context, getChecker());
121  1 assertEquals(1, list.size());
122  1 assertEquals(30530, list.get(0).getErrorCode());
123    }
124   
125    /**
126    * Function: checkFormula(Element)
127    * Type: negative, code 30530, unknown formula operator
128    * Data: {}
129    *
130    * @throws Exception Test failed.
131    */
 
132  1 toggle public void testFormulaNegative03() throws Exception {
133  1 final Element ele = TestParser.createElement("<FUNCON id=\"empty\"></FUNCON>");
134    // System.out.println(ele.toString());
135  1 LogicalCheckExceptionList list =
136    FormulaChecker.checkFormula(ele, context, getChecker());
137  1 assertEquals(1, list.size());
138  1 assertEquals(30530, list.get(0).getErrorCode());
139    }
140   
141   
142    }