1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.ezmorph.test;
18
19 import junit.framework.AssertionFailedError;
20 import junit.framework.Test;
21 import junit.framework.TestCase;
22 import junit.framework.TestSuite;
23 import junit.textui.TestRunner;
24
25
26
27
28 public class IntArrayAssertionsTest extends TestCase
29 {
30 public static void main( String[] args )
31 {
32 TestRunner.run( suite() );
33 }
34
35 public static Test suite()
36 {
37 TestSuite suite = new TestSuite( IntArrayAssertionsTest.class );
38 suite.setName( "IntArrayAssertions Tests" );
39 return suite;
40 }
41
42 public IntArrayAssertionsTest( String name )
43 {
44 super( name );
45 }
46
47
48
49 public void testAssertEquals_int_int()
50 {
51 int[] expecteds = new int[] { 1, 2 };
52 int[] actuals = new int[] { 1, 2 };
53 ArrayAssertions.assertEquals( expecteds, actuals );
54 }
55
56 public void testAssertEquals_int_int_actuals_is_null()
57 {
58 boolean errorThrown = false;
59 int[] expecteds = new int[] { 1, 2 };
60 try{
61 ArrayAssertions.assertEquals( expecteds, (int[]) null );
62 }
63 catch( AssertionFailedError expected ){
64 errorThrown = true;
65 }
66 assertTrue( "Expected a failure", errorThrown );
67 }
68
69 public void testAssertEquals_int_int_different_length()
70 {
71 int[] expecteds = new int[] { 1 };
72 int[] actuals = new int[] { 1, 2 };
73 boolean errorThrown = false;
74 try{
75 ArrayAssertions.assertEquals( expecteds, actuals );
76 }
77 catch( AssertionFailedError expected ){
78 errorThrown = true;
79 }
80 assertTrue( "Expected a failure", errorThrown );
81 }
82
83 public void testAssertEquals_int_int_expecteds_is_null()
84 {
85 boolean errorThrown = false;
86 int[] actuals = new int[] { 1, 2 };
87 try{
88 ArrayAssertions.assertEquals( (int[]) null, actuals );
89 }
90 catch( AssertionFailedError expected ){
91 errorThrown = true;
92 }
93 assertTrue( "Expected a failure", errorThrown );
94 }
95
96 public void testAssertEquals_int_Integer()
97 {
98 int[] expecteds = new int[] { 1, 2 };
99 Integer[] actuals = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
100 ArrayAssertions.assertEquals( expecteds, actuals );
101 }
102
103 public void testAssertEquals_int_Integer_actuals_is_null()
104 {
105 boolean errorThrown = false;
106 int[] expecteds = new int[] { 1, 2 };
107 try{
108 ArrayAssertions.assertEquals( expecteds, (Integer[]) null );
109 }
110 catch( AssertionFailedError expected ){
111 errorThrown = true;
112 }
113 assertTrue( "Expected a failure", errorThrown );
114 }
115
116 public void testAssertEquals_int_Integer_different_length()
117 {
118 int[] expecteds = new int[] { 1 };
119 Integer[] actuals = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
120 boolean errorThrown = false;
121 try{
122 ArrayAssertions.assertEquals( expecteds, actuals );
123 }
124 catch( AssertionFailedError expected ){
125 errorThrown = true;
126 }
127 assertTrue( "Expected a failure", errorThrown );
128 }
129
130 public void testAssertEquals_int_Integer_expecteds_is_null()
131 {
132 boolean errorThrown = false;
133 Integer[] actuals = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
134 try{
135 ArrayAssertions.assertEquals( (int[]) null, actuals );
136 }
137 catch( AssertionFailedError expected ){
138 errorThrown = true;
139 }
140 assertTrue( "Expected a failure", errorThrown );
141 }
142
143 public void testAssertEquals_Integer_int()
144 {
145 Integer[] expecteds = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
146 int[] actuals = new int[] { 1, 2 };
147 ArrayAssertions.assertEquals( expecteds, actuals );
148 }
149
150 public void testAssertEquals_Integer_int_actuals_is_null()
151 {
152 boolean errorThrown = false;
153 Integer[] expecteds = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
154 try{
155 ArrayAssertions.assertEquals( expecteds, (int[]) null );
156 }
157 catch( AssertionFailedError expected ){
158 errorThrown = true;
159 }
160 assertTrue( "Expected a failure", errorThrown );
161 }
162
163 public void testAssertEquals_Integer_int_different_length()
164 {
165 Integer[] expecteds = new Integer[] { new Integer( 1 ) };
166 int[] actuals = new int[] { 1, 2 };
167 boolean errorThrown = false;
168 try{
169 ArrayAssertions.assertEquals( expecteds, actuals );
170 }
171 catch( AssertionFailedError expected ){
172 errorThrown = true;
173 }
174 assertTrue( "Expected a failure", errorThrown );
175 }
176
177 public void testAssertEquals_Integer_int_expecteds_is_null()
178 {
179 boolean errorThrown = false;
180 int[] actuals = new int[] { 1, 2 };
181 try{
182 ArrayAssertions.assertEquals( (Integer[]) null, actuals );
183 }
184 catch( AssertionFailedError expected ){
185 errorThrown = true;
186 }
187 assertTrue( "Expected a failure", errorThrown );
188 }
189
190 public void testAssertEquals_Integer_Integer()
191 {
192 Integer[] expecteds = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
193 Integer[] actuals = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
194 ArrayAssertions.assertEquals( expecteds, actuals );
195 }
196
197 public void testAssertEquals_multi_int_int()
198 {
199 int[][] expecteds = new int[][] { { 1, 2 }, { 1, 2 } };
200 int[][] actuals = new int[][] { { 1, 2 }, { 1, 2 } };
201 ArrayAssertions.assertEquals( expecteds, actuals );
202 }
203
204 public void testAssertEquals_multi_int_Integer()
205 {
206 int[][] expecteds = new int[][] { { 1, 2 }, { 1, 2 } };
207 Integer[][] actuals = new Integer[][] { { new Integer( 1 ), new Integer( 2 ) },
208 { new Integer( 1 ), new Integer( 2 ) } };
209 ArrayAssertions.assertEquals( expecteds, actuals );
210 }
211
212 public void testAssertEquals_multi_Integer_int()
213 {
214 Integer[][] expecteds = new Integer[][] { { new Integer( 1 ), new Integer( 2 ) },
215 { new Integer( 1 ), new Integer( 2 ) } };
216 int[][] actuals = new int[][] { { 1, 2 }, { 1, 2 } };
217 ArrayAssertions.assertEquals( expecteds, actuals );
218 }
219
220 public void testAssertEquals_multi_Integer_Integer()
221 {
222 Integer[][] expecteds = new Integer[][] { { new Integer( 1 ), new Integer( 2 ) },
223 { new Integer( 1 ), new Integer( 2 ) } };
224 Integer[][] actuals = new Integer[][] { { new Integer( 1 ), new Integer( 2 ) },
225 { new Integer( 1 ), new Integer( 2 ) } };
226 ArrayAssertions.assertEquals( expecteds, actuals );
227 }
228
229 public void testAssertEquals_OO_int_double()
230 {
231 boolean errorThrown = false;
232 Object expecteds = new int[] { 1, 2 };
233 Object actuals = new double[] { 1, 2 };
234 try{
235 ArrayAssertions.assertEquals( expecteds, actuals );
236 }
237 catch( AssertionFailedError expected ){
238 errorThrown = true;
239 }
240 assertTrue( "Expected a failure", errorThrown );
241 }
242
243 public void testAssertEquals_OO_int_int()
244 {
245 Object expecteds = new int[] { 1, 2 };
246 Object actuals = new int[] { 1, 2 };
247 ArrayAssertions.assertEquals( expecteds, actuals );
248 }
249
250 public void testAssertEquals_OO_int_Integer()
251 {
252 Object expecteds = new int[] { 1, 2 };
253 Object actuals = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
254 ArrayAssertions.assertEquals( expecteds, actuals );
255 }
256
257 public void testAssertEquals_OO_int_Object_array()
258 {
259 Object expecteds = new int[] { 1, 2 };
260 Object actuals = new Object[] { new Integer( 1 ), new Integer( 2 ) };
261 ArrayAssertions.assertEquals( expecteds, actuals );
262 }
263
264 public void testAssertEquals_OO_Integer_int()
265 {
266 Object expecteds = new Integer[] { new Integer( 1 ), new Integer( 2 ) };
267 Object actuals = new int[] { 1, 2 };
268 ArrayAssertions.assertEquals( expecteds, actuals );
269 }
270
271 public void testAssertEquals_OO_Object_array_int()
272 {
273 Object expecteds = new Object[] { new Integer( 1 ), new Integer( 2 ) };
274 Object actuals = new int[] { 1, 2 };
275 ArrayAssertions.assertEquals( expecteds, actuals );
276 }
277
278 public void testAssertEquals_OO_Object_array_Object_array()
279 {
280 Object expecteds = new Object[] { new Integer( 1 ), new Integer( 2 ) };
281 Object actuals = new Object[] { new Integer( 1 ), new Integer( 2 ) };
282 ArrayAssertions.assertEquals( expecteds, actuals );
283 }
284 }