Clover Coverage Report
Coverage timestamp: Sat Sep 18 2010 04:09:52 UTC
62   166   12   6.89
0   121   0.19   9
9     1.33  
1    
 
  SourceAreaTest       Line # 27 62 12 95.8% 0.9577465
 
  (7)
 
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.base.io;
17   
18    import org.qedeq.base.io.SourceArea;
19    import org.qedeq.base.io.SourcePosition;
20    import org.qedeq.base.test.QedeqTestCase;
21   
22    /**
23    * Test {@link SourceArea}.
24    *
25    * @author Michael Meyling
26    */
 
27    public class SourceAreaTest extends QedeqTestCase {
28   
29    /** Test object 1. */
30    private SourceArea object1;
31   
32    /** Test object 2. */
33    private SourceArea object2;
34   
35    /** Test object 3. */
36    private SourceArea object3;
37   
38    /** Test object 4. */
39    private SourceArea object4;
40   
41    /** Test object 5. */
42    private SourceArea object5;
43   
 
44  7 toggle protected void setUp() throws Exception {
45  7 super.setUp();
46  7 object1 = new SourceArea("file:///var/opt/qedeq/001/set_theory_v1.qedeq",
47    new SourcePosition(12, 17),
48    new SourcePosition(13, 19)
49    );
50  7 object2 = new SourceArea("file:///var/opt/qedeq/001/set_theory_v1.qedeq",
51    new SourcePosition(12, 17),
52    new SourcePosition(13, 19)
53    );
54  7 object3 = new SourceArea("file:///var/opt/qedeq/001/set_theory_v2.qedeq",
55    new SourcePosition(12, 17),
56    new SourcePosition(13, 19)
57    );
58  7 object4 = new SourceArea("file:///var/opt/qedeq/001/set_theory_v1.qedeq",
59    new SourcePosition(13, 17),
60    new SourcePosition(13, 19)
61    );
62  7 object5 = new SourceArea("file:///var/opt/qedeq/001/set_theory_v1.qedeq",
63    new SourcePosition(12, 19),
64    new SourcePosition(13, 19)
65    );
66    }
67   
 
68  7 toggle protected void tearDown() throws Exception {
69  7 super.tearDown();
70    }
71   
 
72  1 toggle public void testSourceArea() {
73  1 try {
74  1 new SourceArea(null,
75    new SourcePosition(12, 17),
76    new SourcePosition(13, 19)
77    );
78  0 fail("RuntimeException expected");
79    } catch (NullPointerException e) {
80    // expected
81    }
82  1 try {
83  1 new SourceArea("file:///var/opt/qedeq/001/set_theory_v1.qedeq",
84    null,
85    new SourcePosition(13, 19)
86    );
87  0 fail("RuntimeException expected");
88    } catch (NullPointerException e) {
89    // expected
90    }
91  1 try {
92  1 new SourceArea("file:///var/opt/qedeq/001/set_theory_v1.qedeq",
93    new SourcePosition(12, 17),
94    null
95    );
96  0 fail("RuntimeException expected");
97    } catch (NullPointerException e) {
98    // expected
99    }
100    }
101   
 
102  1 toggle public void testGetAddress() {
103  1 assertEquals("file:///var/opt/qedeq/001/set_theory_v1.qedeq", object1.getAddress());
104  1 assertEquals("file:///var/opt/qedeq/001/set_theory_v1.qedeq", object2.getAddress());
105  1 assertEquals("file:///var/opt/qedeq/001/set_theory_v2.qedeq", object3.getAddress());
106    }
107   
 
108  1 toggle public void testGetStartPosition() {
109  1 assertEquals(new SourcePosition(12, 17), object1.getStartPosition());
110  1 assertEquals(new SourcePosition(12, 17), object2.getStartPosition());
111  1 assertEquals(new SourcePosition(12, 17), object3.getStartPosition());
112  1 assertEquals(new SourcePosition(13, 17), object4.getStartPosition());
113    }
114   
 
115  1 toggle public void testGetEndPosition() {
116  1 assertEquals(new SourcePosition(13, 19), object1.getEndPosition());
117  1 assertEquals(new SourcePosition(13, 19), object2.getEndPosition());
118  1 assertEquals(new SourcePosition(13, 19), object3.getEndPosition());
119  1 assertEquals(new SourcePosition(13, 19), object5.getEndPosition());
120    }
121   
 
122  1 toggle public void testHashCode() {
123  1 assertEquals(object1.hashCode(), object2.hashCode());
124  1 assertTrue(object1.hashCode() != object3.hashCode());
125  1 assertTrue(object1.hashCode() != object4.hashCode());
126  1 assertTrue(object1.hashCode() != object5.hashCode());
127  1 assertTrue(object2.hashCode() != object3.hashCode());
128  1 assertTrue(object2.hashCode() != object4.hashCode());
129  1 assertTrue(object2.hashCode() != object5.hashCode());
130    }
131   
 
132  1 toggle public void testEqualsObject() {
133  1 assertEquals(object1, object2);
134  1 assertEquals(object2, object1);
135  1 assertTrue(!object1.equals(object3));
136  1 assertTrue(!object3.equals(object1));
137  1 assertTrue(!object1.equals(object4));
138  1 assertTrue(!object4.equals(object1));
139  1 assertTrue(!object1.equals(object5));
140  1 assertTrue(!object5.equals(object1));
141  1 assertTrue(!object2.equals(object3));
142  1 assertTrue(!object3.equals(object2));
143  1 assertTrue(!object2.equals(object4));
144  1 assertTrue(!object4.equals(object2));
145  1 assertTrue(!object2.equals(object5));
146  1 assertTrue(!object5.equals(object2));
147    }
148   
 
149  1 toggle public void testToString() {
150  1 assertEquals(object1.toString(), object2.toString());
151  1 assertEquals(object2.toString(), object1.toString());
152  1 assertTrue(!object1.toString().equals(object3.toString()));
153  1 assertTrue(!object3.toString().equals(object1.toString()));
154  1 assertTrue(!object1.toString().equals(object4.toString()));
155  1 assertTrue(!object4.toString().equals(object1.toString()));
156  1 assertTrue(!object1.toString().equals(object5.toString()));
157  1 assertTrue(!object5.toString().equals(object1.toString()));
158  1 assertTrue(!object2.toString().equals(object3.toString()));
159  1 assertTrue(!object3.toString().equals(object2.toString()));
160  1 assertTrue(!object2.toString().equals(object4.toString()));
161  1 assertTrue(!object4.toString().equals(object2.toString()));
162  1 assertTrue(!object2.toString().equals(object5.toString()));
163  1 assertTrue(!object5.toString().equals(object2.toString()));
164    }
165   
166    }