KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > junitx > framework > ComparableAssertTest


1 package junitx.framework;
2
3 import junit.framework.AssertionFailedError;
4 import junit.framework.TestCase;
5
6 /**
7  * @version $Revision: 1.2 $ $Date: 2003/01/20 10:44:50 $
8  * @author <a HREF="mailto:vbossica@users.sourceforge.net">Vladimir R. Bossicard</a>
9  */

10 public class ComparableAssertTest
11         extends TestCase {
12
13     public ComparableAssertTest(String JavaDoc name) {
14         super(name);
15     }
16
17     public void testSuccessLesser() {
18         ComparableAssert.assertLesser(new Integer JavaDoc(3), new Integer JavaDoc(2));
19     }
20
21     public void testFailLesser() {
22         try {
23             ComparableAssert.assertLesser(new Integer JavaDoc(2), new Integer JavaDoc(3));
24         } catch (AssertionFailedError e) {
25             return;
26         }
27         fail();
28     }
29
30     public void testFailLesserEquals() {
31         try {
32             ComparableAssert.assertLesser(new Integer JavaDoc(3), new Integer JavaDoc(3));
33         } catch (AssertionFailedError e) {
34             return;
35         }
36         fail();
37     }
38
39     public void testFailLesserNullLimit() {
40         try {
41             ComparableAssert.assertLesser(null, new Integer JavaDoc(3));
42         } catch (AssertionFailedError e) {
43             return;
44         }
45         fail();
46     }
47
48     public void testFailLesserNullActual() {
49         try {
50             ComparableAssert.assertLesser(new Integer JavaDoc(2), null);
51         } catch (AssertionFailedError e) {
52             return;
53         }
54         fail();
55     }
56
57     public void testSuccessGreater() {
58         ComparableAssert.assertGreater(new Integer JavaDoc(1), new Integer JavaDoc(3));
59     }
60
61     public void testFailGreater() {
62         try {
63             ComparableAssert.assertGreater(new Integer JavaDoc(5), new Integer JavaDoc(3));
64         } catch (AssertionFailedError e) {
65             return;
66         }
67         fail();
68     }
69
70     public void testFailGreaterEquals() {
71         try {
72             ComparableAssert.assertGreater(new Integer JavaDoc(3), new Integer JavaDoc(3));
73         } catch (AssertionFailedError e) {
74             return;
75         }
76         fail();
77     }
78
79     public void testFailGreaterNullLimit() {
80         try {
81             ComparableAssert.assertGreater(null, new Integer JavaDoc(3));
82         } catch (AssertionFailedError e) {
83             return;
84         }
85         fail();
86     }
87
88     public void testFailGreaterNullActual() {
89         try {
90             ComparableAssert.assertGreater(new Integer JavaDoc(3), null);
91         } catch (AssertionFailedError e) {
92             return;
93         }
94         fail();
95     }
96
97     public void testSuccessNotLesser() {
98         ComparableAssert.assertNotLesser(new Integer JavaDoc(2), new Integer JavaDoc(5));
99     }
100
101     public void testSuccessNotLesserEquals() {
102         ComparableAssert.assertNotLesser(new Integer JavaDoc(5), new Integer JavaDoc(5));
103     }
104
105     public void testFailNotLesser() {
106         try {
107             ComparableAssert.assertNotLesser(new Integer JavaDoc(2), new Integer JavaDoc(1));
108         } catch (AssertionFailedError e) {
109             return;
110         }
111         fail();
112     }
113
114     public void testFailNotLesserNullLimit() {
115         try {
116             ComparableAssert.assertNotLesser(null, new Integer JavaDoc(1));
117         } catch (AssertionFailedError e) {
118             return;
119         }
120         fail();
121     }
122
123     public void testFailNotLesserNullActual() {
124         try {
125             ComparableAssert.assertNotLesser(new Integer JavaDoc(1), null);
126         } catch (AssertionFailedError e) {
127             return;
128         }
129         fail();
130     }
131
132     public void testSuccessNotGreater() {
133         ComparableAssert.assertNotGreater(new Integer JavaDoc(3), new Integer JavaDoc(2));
134     }
135
136     public void testSuccessNotGreaterEquals() {
137         ComparableAssert.assertNotGreater(new Integer JavaDoc(5), new Integer JavaDoc(5));
138     }
139
140     public void testFailNotGreater() {
141         try {
142             ComparableAssert.assertNotGreater(new Integer JavaDoc(2), new Integer JavaDoc(5));
143         } catch (AssertionFailedError e) {
144             return;
145         }
146         fail();
147     }
148
149     public void testFailNotGreaterNullLimit() {
150         try {
151             ComparableAssert.assertNotGreater(null, new Integer JavaDoc(5));
152         } catch (AssertionFailedError e) {
153             return;
154         }
155         fail();
156     }
157
158     public void testFailNotGreaterNullActual() {
159         try {
160             ComparableAssert.assertNotGreater(new Integer JavaDoc(2), null);
161         } catch (AssertionFailedError e) {
162             return;
163         }
164         fail();
165     }
166
167     public void testSuccessEquals() {
168         ComparableAssert.assertEquals(new Integer JavaDoc(3), new Integer JavaDoc(3));
169     }
170
171     public void testFailEquals() {
172         try {
173             ComparableAssert.assertEquals(new Integer JavaDoc(2), new Integer JavaDoc(3));
174         } catch (AssertionFailedError e) {
175             return;
176         }
177         fail();
178     }
179
180     public void testSuccessNotEquals() {
181         ComparableAssert.assertNotEquals(new Integer JavaDoc(2), new Integer JavaDoc(3));
182     }
183
184     public void testFailNotEquals() {
185         try {
186             ComparableAssert.assertNotEquals(new Integer JavaDoc(3), new Integer JavaDoc(3));
187         } catch (AssertionFailedError e) {
188             return;
189         }
190         fail();
191     }
192
193 }
194
Popular Tags