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