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