Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
68   172   17   4.86
0   112   0.25   14
14     1.21  
1    
 
  DefaultAtomTest       Line # 26 68 17 93.9% 0.9390244
 
  (10)
 
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.se.dto.list;
17   
18    import org.qedeq.base.test.QedeqTestCase;
19    import org.qedeq.kernel.se.base.list.Element;
20   
21    /**
22    * Test class.
23    *
24    * @author Michael Meyling
25    */
 
26    public class DefaultAtomTest extends QedeqTestCase {
27   
28    private DefaultAtom empty;
29   
30    private DefaultAtom one;
31   
32    private DefaultAtom two;
33   
34    private DefaultAtom three;
35   
 
36  0 toggle public DefaultAtomTest(){
37  0 super();
38    }
39   
 
40  10 toggle public DefaultAtomTest(final String name){
41  10 super(name);
42    }
43   
 
44  10 toggle protected void setUp() throws Exception {
45  10 super.setUp();
46  10 empty = new DefaultAtom("");
47  10 one = new DefaultAtom("one");
48  10 two = new DefaultAtom("two");
49  10 three = new DefaultAtom("two");
50    }
51   
 
52  10 toggle protected void tearDown() throws Exception {
53  10 empty = null;
54  10 one = null;
55  10 two = null;
56  10 three = null;
57  10 super.tearDown();
58    }
59   
60   
61    /**
62    * Test constructor.
63    */
 
64  1 toggle public void testConstructor() {
65  1 try {
66  1 new DefaultAtom(null);
67  0 fail("Exception expected");
68    } catch (Exception e) {
69    // ok
70    }
71    }
72   
73    /**
74    * Test getter.
75    */
 
76  1 toggle public void testGet() {
77  1 assertEquals("", empty.getString());
78  1 assertEquals("one", one.getString());
79  1 assertEquals("two", two.getString());
80  1 assertEquals("two", three.getString());
81    }
82   
83    /**
84    * Test toString.
85    */
 
86  1 toggle public void testToString() {
87  1 assertEquals("\"\"", empty.toString());
88  1 assertEquals("\"one\"", one.toString());
89  1 assertEquals("\"two\"", two.toString());
90  1 assertEquals("\"two\"", three.toString());
91  1 assertEquals("\"ho\"\"hi\"", new DefaultAtom("ho\"hi").toString());
92    }
93   
 
94  1 toggle public void testGetList() {
95  1 try {
96  1 empty.getList();
97  0 fail("Exception expected");
98    } catch (Exception e) {
99    // ok
100    }
101  1 try {
102  1 two.getList();
103  0 fail("Exception expected");
104    } catch (Exception e) {
105    // ok
106    }
107    }
108   
 
109  1 toggle public void testIsAtom() {
110  1 assertTrue(empty.isAtom());
111  1 assertTrue(one.isAtom());
112  1 assertTrue(two.isAtom());
113    }
114   
 
115  1 toggle public void testIsList() {
116  1 assertFalse(empty.isList());
117  1 assertFalse(one.isList());
118  1 assertFalse(two.isList());
119    }
120   
 
121  1 toggle public void testGetAtom() {
122  1 assertEquals(empty, empty.getAtom());
123  1 assertEquals(one, one.getAtom());
124  1 assertEquals(two, two.getAtom());
125  1 assertEquals(two, three.getAtom());
126    }
127   
 
128  1 toggle public void testReplace() {
129  1 assertEquals(empty, empty.replace(null, null));
130  1 assertEquals(empty, empty.replace(one, null));
131  1 assertEquals(empty, empty.replace(one, two));
132  1 assertEquals(two, one.replace(one, two));
133  1 assertEquals(one, one.replace(two, one));
134  1 assertEquals(one, one.replace(new DefaultElementList("neu", new Element[]{ one}), two));
135  1 Element list = new DefaultElementList("two", new Element[] { new DefaultAtom("atom"),
136    new DefaultElementList("deep")});
137  1 assertEquals(list, one.replace(one, list));
138    }
139   
140    /**
141    * Test hashCode.
142    */
 
143  1 toggle public void testHashCode() {
144  1 assertFalse(0 == empty.hashCode());
145  1 assertFalse(empty.hashCode() == one.hashCode());
146  1 assertFalse(two.hashCode() == one.hashCode());
147  1 assertTrue(two.hashCode() == three.hashCode());
148    }
149   
150    /**
151    * Test equals.
152    */
 
153  1 toggle public void testEquals() {
154  1 assertFalse(empty.equals(null));
155  1 assertFalse(empty.equals(one));
156  1 assertFalse(empty.equals(two));
157  1 assertFalse(empty.equals(three));
158  1 assertFalse(one.equals(null));
159  1 assertTrue(one.equals(one));
160  1 assertFalse(one.equals(two));
161  1 assertFalse(one.equals(three));
162  1 assertFalse(two.equals(null));
163  1 assertFalse(two.equals(one));
164  1 assertTrue(two.equals(two));
165  1 assertTrue(two.equals(three));
166  1 assertFalse(three.equals(null));
167  1 assertFalse(three.equals(one));
168  1 assertTrue(three.equals(two));
169  1 assertTrue(three.equals(three));
170    }
171   
172    }