KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > lang > ArrayUtilsRemoveTest


1 /*
2  * Copyright 2002-2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.commons.lang;
18
19 import java.util.Arrays JavaDoc;
20
21 import junit.framework.Test;
22 import junit.framework.TestCase;
23 import junit.framework.TestSuite;
24 import junit.textui.TestRunner;
25
26 /**
27  * Tests ArrayUtils remove and removeElement methods.
28  *
29  * @author Maarten Coene
30  * @version $Id: ArrayUtilsRemoveTest.java 161244 2005-04-14 06:16:36Z ggregory $
31  */

32 public class ArrayUtilsRemoveTest extends TestCase {
33     public static void main(String JavaDoc[] args) {
34         TestRunner.run(suite());
35     }
36
37     public static Test suite() {
38         TestSuite suite = new TestSuite(ArrayUtilsRemoveTest.class);
39         suite.setName("ArrayUtils remove Tests");
40         return suite;
41     }
42
43     public void testRemoveObjectArray() {
44         Object JavaDoc[] array;
45         array = ArrayUtils.remove(new Object JavaDoc[] {"a"}, 0);
46         assertTrue(Arrays.equals(ArrayUtils.EMPTY_OBJECT_ARRAY, array));
47         assertEquals(Object JavaDoc.class, array.getClass().getComponentType());
48         array = ArrayUtils.remove(new Object JavaDoc[] {"a", "b"}, 0);
49         assertTrue(Arrays.equals(new Object JavaDoc[] {"b"}, array));
50         assertEquals(Object JavaDoc.class, array.getClass().getComponentType());
51         array = ArrayUtils.remove(new Object JavaDoc[] {"a", "b"}, 1);
52         assertTrue(Arrays.equals(new Object JavaDoc[] {"a"}, array));
53         assertEquals(Object JavaDoc.class, array.getClass().getComponentType());
54         array = ArrayUtils.remove(new Object JavaDoc[] {"a", "b", "c"}, 1);
55         assertTrue(Arrays.equals(new Object JavaDoc[] {"a", "c"}, array));
56         assertEquals(Object JavaDoc.class, array.getClass().getComponentType());
57         try {
58             ArrayUtils.remove(new Object JavaDoc[] {"a", "b"}, -1);
59             fail("IndexOutOfBoundsException expected");
60         } catch (IndexOutOfBoundsException JavaDoc e) {}
61         try {
62             ArrayUtils.remove(new Object JavaDoc[] {"a", "b"}, 2);
63             fail("IndexOutOfBoundsException expected");
64         } catch (IndexOutOfBoundsException JavaDoc e) {}
65         try {
66             ArrayUtils.remove((Object JavaDoc[]) null, 0);
67             fail("IndexOutOfBoundsException expected");
68         } catch (IndexOutOfBoundsException JavaDoc e) {}
69     }
70     
71     public void testRemoveBooleanArray() {
72         boolean[] array;
73         array = ArrayUtils.remove(new boolean[] {true}, 0);
74         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, array));
75         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
76         array = ArrayUtils.remove(new boolean[] {true, false}, 0);
77         assertTrue(Arrays.equals(new boolean[] {false}, array));
78         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
79         array = ArrayUtils.remove(new boolean[] {true, false}, 1);
80         assertTrue(Arrays.equals(new boolean[] {true}, array));
81         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
82         array = ArrayUtils.remove(new boolean[] {true, false, true}, 1);
83         assertTrue(Arrays.equals(new boolean[] {true, true}, array));
84         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
85         try {
86             ArrayUtils.remove(new boolean[] {true, false}, -1);
87             fail("IndexOutOfBoundsException expected");
88         } catch (IndexOutOfBoundsException JavaDoc e) {}
89         try {
90             ArrayUtils.remove(new boolean[] {true, false}, 2);
91             fail("IndexOutOfBoundsException expected");
92         } catch (IndexOutOfBoundsException JavaDoc e) {}
93         try {
94             ArrayUtils.remove((boolean[]) null, 0);
95             fail("IndexOutOfBoundsException expected");
96         } catch (IndexOutOfBoundsException JavaDoc e) {}
97     }
98     
99     public void testRemoveByteArray() {
100         byte[] array;
101         array = ArrayUtils.remove(new byte[] {1}, 0);
102         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BYTE_ARRAY, array));
103         assertEquals(Byte.TYPE, array.getClass().getComponentType());
104         array = ArrayUtils.remove(new byte[] {1, 2}, 0);
105         assertTrue(Arrays.equals(new byte[] {2}, array));
106         assertEquals(Byte.TYPE, array.getClass().getComponentType());
107         array = ArrayUtils.remove(new byte[] {1, 2}, 1);
108         assertTrue(Arrays.equals(new byte[] {1}, array));
109         assertEquals(Byte.TYPE, array.getClass().getComponentType());
110         array = ArrayUtils.remove(new byte[] {1, 2, 1}, 1);
111         assertTrue(Arrays.equals(new byte[] {1, 1}, array));
112         assertEquals(Byte.TYPE, array.getClass().getComponentType());
113         try {
114             ArrayUtils.remove(new byte[] {1, 2}, -1);
115             fail("IndexOutOfBoundsException expected");
116         } catch (IndexOutOfBoundsException JavaDoc e) {}
117         try {
118             ArrayUtils.remove(new byte[] {1, 2}, 2);
119             fail("IndexOutOfBoundsException expected");
120         } catch (IndexOutOfBoundsException JavaDoc e) {}
121         try {
122             ArrayUtils.remove((byte[]) null, 0);
123             fail("IndexOutOfBoundsException expected");
124         } catch (IndexOutOfBoundsException JavaDoc e) {}
125     }
126     
127     public void testRemoveCharArray() {
128         char[] array;
129         array = ArrayUtils.remove(new char[] {'a'}, 0);
130         assertTrue(Arrays.equals(ArrayUtils.EMPTY_CHAR_ARRAY, array));
131         assertEquals(Character.TYPE, array.getClass().getComponentType());
132         array = ArrayUtils.remove(new char[] {'a', 'b'}, 0);
133         assertTrue(Arrays.equals(new char[] {'b'}, array));
134         assertEquals(Character.TYPE, array.getClass().getComponentType());
135         array = ArrayUtils.remove(new char[] {'a', 'b'}, 1);
136         assertTrue(Arrays.equals(new char[] {'a'}, array));
137         assertEquals(Character.TYPE, array.getClass().getComponentType());
138         array = ArrayUtils.remove(new char[] {'a', 'b', 'c'}, 1);
139         assertTrue(Arrays.equals(new char[] {'a', 'c'}, array));
140         assertEquals(Character.TYPE, array.getClass().getComponentType());
141         try {
142             ArrayUtils.remove(new char[] {'a', 'b'}, -1);
143             fail("IndexOutOfBoundsException expected");
144         } catch (IndexOutOfBoundsException JavaDoc e) {}
145         try {
146             ArrayUtils.remove(new char[] {'a', 'b'}, 2);
147             fail("IndexOutOfBoundsException expected");
148         } catch (IndexOutOfBoundsException JavaDoc e) {}
149         try {
150             ArrayUtils.remove((char[]) null, 0);
151             fail("IndexOutOfBoundsException expected");
152         } catch (IndexOutOfBoundsException JavaDoc e) {}
153     }
154     
155     public void testRemoveDoubleArray() {
156         double[] array;
157         array = ArrayUtils.remove(new double[] {1}, 0);
158         assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array));
159         assertEquals(Double.TYPE, array.getClass().getComponentType());
160         array = ArrayUtils.remove(new double[] {1, 2}, 0);
161         assertTrue(Arrays.equals(new double[] {2}, array));
162         assertEquals(Double.TYPE, array.getClass().getComponentType());
163         array = ArrayUtils.remove(new double[] {1, 2}, 1);
164         assertTrue(Arrays.equals(new double[] {1}, array));
165         assertEquals(Double.TYPE, array.getClass().getComponentType());
166         array = ArrayUtils.remove(new double[] {1, 2, 1}, 1);
167         assertTrue(Arrays.equals(new double[] {1, 1}, array));
168         assertEquals(Double.TYPE, array.getClass().getComponentType());
169         try {
170             ArrayUtils.remove(new double[] {1, 2}, -1);
171             fail("IndexOutOfBoundsException expected");
172         } catch (IndexOutOfBoundsException JavaDoc e) {}
173         try {
174             ArrayUtils.remove(new double[] {1, 2}, 2);
175             fail("IndexOutOfBoundsException expected");
176         } catch (IndexOutOfBoundsException JavaDoc e) {}
177         try {
178             ArrayUtils.remove((double[]) null, 0);
179             fail("IndexOutOfBoundsException expected");
180         } catch (IndexOutOfBoundsException JavaDoc e) {}
181     }
182     
183     public void testRemoveFloatArray() {
184         float[] array;
185         array = ArrayUtils.remove(new float[] {1}, 0);
186         assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, array));
187         assertEquals(Float.TYPE, array.getClass().getComponentType());
188         array = ArrayUtils.remove(new float[] {1, 2}, 0);
189         assertTrue(Arrays.equals(new float[] {2}, array));
190         assertEquals(Float.TYPE, array.getClass().getComponentType());
191         array = ArrayUtils.remove(new float[] {1, 2}, 1);
192         assertTrue(Arrays.equals(new float[] {1}, array));
193         assertEquals(Float.TYPE, array.getClass().getComponentType());
194         array = ArrayUtils.remove(new float[] {1, 2, 1}, 1);
195         assertTrue(Arrays.equals(new float[] {1, 1}, array));
196         assertEquals(Float.TYPE, array.getClass().getComponentType());
197         try {
198             ArrayUtils.remove(new float[] {1, 2}, -1);
199             fail("IndexOutOfBoundsException expected");
200         } catch (IndexOutOfBoundsException JavaDoc e) {}
201         try {
202             ArrayUtils.remove(new float[] {1, 2}, 2);
203             fail("IndexOutOfBoundsException expected");
204         } catch (IndexOutOfBoundsException JavaDoc e) {}
205         try {
206             ArrayUtils.remove((float[]) null, 0);
207             fail("IndexOutOfBoundsException expected");
208         } catch (IndexOutOfBoundsException JavaDoc e) {}
209     }
210     
211     public void testRemoveIntArray() {
212         int[] array;
213         array = ArrayUtils.remove(new int[] {1}, 0);
214         assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, array));
215         assertEquals(Integer.TYPE, array.getClass().getComponentType());
216         array = ArrayUtils.remove(new int[] {1, 2}, 0);
217         assertTrue(Arrays.equals(new int[] {2}, array));
218         assertEquals(Integer.TYPE, array.getClass().getComponentType());
219         array = ArrayUtils.remove(new int[] {1, 2}, 1);
220         assertTrue(Arrays.equals(new int[] {1}, array));
221         assertEquals(Integer.TYPE, array.getClass().getComponentType());
222         array = ArrayUtils.remove(new int[] {1, 2, 1}, 1);
223         assertTrue(Arrays.equals(new int[] {1, 1}, array));
224         assertEquals(Integer.TYPE, array.getClass().getComponentType());
225         try {
226             ArrayUtils.remove(new int[] {1, 2}, -1);
227             fail("IndexOutOfBoundsException expected");
228         } catch (IndexOutOfBoundsException JavaDoc e) {}
229         try {
230             ArrayUtils.remove(new int[] {1, 2}, 2);
231             fail("IndexOutOfBoundsException expected");
232         } catch (IndexOutOfBoundsException JavaDoc e) {}
233         try {
234             ArrayUtils.remove((int[]) null, 0);
235             fail("IndexOutOfBoundsException expected");
236         } catch (IndexOutOfBoundsException JavaDoc e) {}
237     }
238     
239     public void testRemoveLongArray() {
240         long[] array;
241         array = ArrayUtils.remove(new long[] {1}, 0);
242         assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
243         assertEquals(Long.TYPE, array.getClass().getComponentType());
244         array = ArrayUtils.remove(new long[] {1, 2}, 0);
245         assertTrue(Arrays.equals(new long[] {2}, array));
246         assertEquals(Long.TYPE, array.getClass().getComponentType());
247         array = ArrayUtils.remove(new long[] {1, 2}, 1);
248         assertTrue(Arrays.equals(new long[] {1}, array));
249         assertEquals(Long.TYPE, array.getClass().getComponentType());
250         array = ArrayUtils.remove(new long[] {1, 2, 1}, 1);
251         assertTrue(Arrays.equals(new long[] {1, 1}, array));
252         assertEquals(Long.TYPE, array.getClass().getComponentType());
253         try {
254             ArrayUtils.remove(new long[] {1, 2}, -1);
255             fail("IndexOutOfBoundsException expected");
256         } catch (IndexOutOfBoundsException JavaDoc e) {}
257         try {
258             ArrayUtils.remove(new long[] {1, 2}, 2);
259             fail("IndexOutOfBoundsException expected");
260         } catch (IndexOutOfBoundsException JavaDoc e) {}
261         try {
262             ArrayUtils.remove((long[]) null, 0);
263             fail("IndexOutOfBoundsException expected");
264         } catch (IndexOutOfBoundsException JavaDoc e) {}
265     }
266     
267     public void testRemoveShortArray() {
268         short[] array;
269         array = ArrayUtils.remove(new short[] {1}, 0);
270         assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, array));
271         assertEquals(Short.TYPE, array.getClass().getComponentType());
272         array = ArrayUtils.remove(new short[] {1, 2}, 0);
273         assertTrue(Arrays.equals(new short[] {2}, array));
274         assertEquals(Short.TYPE, array.getClass().getComponentType());
275         array = ArrayUtils.remove(new short[] {1, 2}, 1);
276         assertTrue(Arrays.equals(new short[] {1}, array));
277         assertEquals(Short.TYPE, array.getClass().getComponentType());
278         array = ArrayUtils.remove(new short[] {1, 2, 1}, 1);
279         assertTrue(Arrays.equals(new short[] {1, 1}, array));
280         assertEquals(Short.TYPE, array.getClass().getComponentType());
281         try {
282             ArrayUtils.remove(new short[] {1, 2}, -1);
283             fail("IndexOutOfBoundsException expected");
284         } catch (IndexOutOfBoundsException JavaDoc e) {}
285         try {
286             ArrayUtils.remove(new short[] {1, 2}, 2);
287             fail("IndexOutOfBoundsException expected");
288         } catch (IndexOutOfBoundsException JavaDoc e) {}
289         try {
290             ArrayUtils.remove((short[]) null, 0);
291             fail("IndexOutOfBoundsException expected");
292         } catch (IndexOutOfBoundsException JavaDoc e) {}
293     }
294     
295     public void testRemoveElementObjectArray() {
296         Object JavaDoc[] array;
297         array = ArrayUtils.removeElement((Object JavaDoc[]) null, "a");
298         assertNull(array);
299         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_OBJECT_ARRAY, "a");
300         assertTrue(Arrays.equals(ArrayUtils.EMPTY_OBJECT_ARRAY, array));
301         assertEquals(Object JavaDoc.class, array.getClass().getComponentType());
302         array = ArrayUtils.removeElement(new Object JavaDoc[] {"a"}, "a");
303         assertTrue(Arrays.equals(ArrayUtils.EMPTY_OBJECT_ARRAY, array));
304         assertEquals(Object JavaDoc.class, array.getClass().getComponentType());
305         array = ArrayUtils.removeElement(new Object JavaDoc[] {"a", "b"}, "a");
306         assertTrue(Arrays.equals(new Object JavaDoc[] {"b"}, array));
307         assertEquals(Object JavaDoc.class, array.getClass().getComponentType());
308         array = ArrayUtils.removeElement(new Object JavaDoc[] {"a", "b", "a"}, "a");
309         assertTrue(Arrays.equals(new Object JavaDoc[] {"b", "a"}, array));
310         assertEquals(Object JavaDoc.class, array.getClass().getComponentType());
311     }
312     
313     public void testRemoveElementBooleanArray() {
314         boolean[] array;
315         array = ArrayUtils.removeElement((boolean[]) null, true);
316         assertNull(array);
317         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_BOOLEAN_ARRAY, true);
318         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, array));
319         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
320         array = ArrayUtils.removeElement(new boolean[] {true}, true);
321         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, array));
322         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
323         array = ArrayUtils.removeElement(new boolean[] {true, false}, true);
324         assertTrue(Arrays.equals(new boolean[] {false}, array));
325         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
326         array = ArrayUtils.removeElement(new boolean[] {true, false, true}, true);
327         assertTrue(Arrays.equals(new boolean[] {false, true}, array));
328         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
329     }
330     
331     public void testRemoveElementByteArray() {
332         byte[] array;
333         array = ArrayUtils.removeElement((byte[]) null, (byte) 1);
334         assertNull(array);
335         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_BYTE_ARRAY, (byte) 1);
336         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BYTE_ARRAY, array));
337         assertEquals(Byte.TYPE, array.getClass().getComponentType());
338         array = ArrayUtils.removeElement(new byte[] {1}, (byte) 1);
339         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BYTE_ARRAY, array));
340         assertEquals(Byte.TYPE, array.getClass().getComponentType());
341         array = ArrayUtils.removeElement(new byte[] {1, 2}, (byte) 1);
342         assertTrue(Arrays.equals(new byte[] {2}, array));
343         assertEquals(Byte.TYPE, array.getClass().getComponentType());
344         array = ArrayUtils.removeElement(new byte[] {1, 2, 1}, (byte) 1);
345         assertTrue(Arrays.equals(new byte[] {2, 1}, array));
346         assertEquals(Byte.TYPE, array.getClass().getComponentType());
347     }
348     
349     public void testRemoveElementCharArray() {
350         char[] array;
351         array = ArrayUtils.removeElement((char[]) null, 'a');
352         assertNull(array);
353         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_CHAR_ARRAY, 'a');
354         assertTrue(Arrays.equals(ArrayUtils.EMPTY_CHAR_ARRAY, array));
355         assertEquals(Character.TYPE, array.getClass().getComponentType());
356         array = ArrayUtils.removeElement(new char[] {'a'}, 'a');
357         assertTrue(Arrays.equals(ArrayUtils.EMPTY_CHAR_ARRAY, array));
358         assertEquals(Character.TYPE, array.getClass().getComponentType());
359         array = ArrayUtils.removeElement(new char[] {'a', 'b'}, 'a');
360         assertTrue(Arrays.equals(new char[] {'b'}, array));
361         assertEquals(Character.TYPE, array.getClass().getComponentType());
362         array = ArrayUtils.removeElement(new char[] {'a', 'b', 'a'}, 'a');
363         assertTrue(Arrays.equals(new char[] {'b', 'a'}, array));
364         assertEquals(Character.TYPE, array.getClass().getComponentType());
365     }
366     
367     public void testRemoveElementDoubleArray() {
368         double[] array;
369         array = ArrayUtils.removeElement((double[]) null, (double) 1);
370         assertNull(array);
371         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_DOUBLE_ARRAY, (double) 1);
372         assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array));
373         assertEquals(Double.TYPE, array.getClass().getComponentType());
374         array = ArrayUtils.removeElement(new double[] {1}, (double) 1);
375         assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array));
376         assertEquals(Double.TYPE, array.getClass().getComponentType());
377         array = ArrayUtils.removeElement(new double[] {1, 2}, (double) 1);
378         assertTrue(Arrays.equals(new double[] {2}, array));
379         assertEquals(Double.TYPE, array.getClass().getComponentType());
380         array = ArrayUtils.removeElement(new double[] {1, 2, 1}, (double) 1);
381         assertTrue(Arrays.equals(new double[] {2, 1}, array));
382         assertEquals(Double.TYPE, array.getClass().getComponentType());
383     }
384     
385     public void testRemoveElementFloatArray() {
386         float[] array;
387         array = ArrayUtils.removeElement((float[]) null, (float) 1);
388         assertNull(array);
389         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_FLOAT_ARRAY, (float) 1);
390         assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, array));
391         assertEquals(Float.TYPE, array.getClass().getComponentType());
392         array = ArrayUtils.removeElement(new float[] {1}, (float) 1);
393         assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, array));
394         assertEquals(Float.TYPE, array.getClass().getComponentType());
395         array = ArrayUtils.removeElement(new float[] {1, 2}, (float) 1);
396         assertTrue(Arrays.equals(new float[] {2}, array));
397         assertEquals(Float.TYPE, array.getClass().getComponentType());
398         array = ArrayUtils.removeElement(new float[] {1, 2, 1}, (float) 1);
399         assertTrue(Arrays.equals(new float[] {2, 1}, array));
400         assertEquals(Float.TYPE, array.getClass().getComponentType());
401     }
402     
403     public void testRemoveElementIntArray() {
404         int[] array;
405         array = ArrayUtils.removeElement((int[]) null, 1);
406         assertNull(array);
407         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_INT_ARRAY, 1);
408         assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, array));
409         assertEquals(Integer.TYPE, array.getClass().getComponentType());
410         array = ArrayUtils.removeElement(new int[] {1}, 1);
411         assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, array));
412         assertEquals(Integer.TYPE, array.getClass().getComponentType());
413         array = ArrayUtils.removeElement(new int[] {1, 2}, 1);
414         assertTrue(Arrays.equals(new int[] {2}, array));
415         assertEquals(Integer.TYPE, array.getClass().getComponentType());
416         array = ArrayUtils.removeElement(new int[] {1, 2, 1}, 1);
417         assertTrue(Arrays.equals(new int[] {2, 1}, array));
418         assertEquals(Integer.TYPE, array.getClass().getComponentType());
419     }
420     
421     public void testRemoveElementLongArray() {
422         long[] array;
423         array = ArrayUtils.removeElement((long[]) null, (long) 1);
424         assertNull(array);
425         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_LONG_ARRAY, (long) 1);
426         assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
427         assertEquals(Long.TYPE, array.getClass().getComponentType());
428         array = ArrayUtils.removeElement(new long[] {1}, (long) 1);
429         assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
430         assertEquals(Long.TYPE, array.getClass().getComponentType());
431         array = ArrayUtils.removeElement(new long[] {1, 2}, (long) 1);
432         assertTrue(Arrays.equals(new long[] {2}, array));
433         assertEquals(Long.TYPE, array.getClass().getComponentType());
434         array = ArrayUtils.removeElement(new long[] {1, 2, 1}, (long) 1);
435         assertTrue(Arrays.equals(new long[] {2, 1}, array));
436         assertEquals(Long.TYPE, array.getClass().getComponentType());
437     }
438     
439     public void testRemoveElementShortArray() {
440         short[] array;
441         array = ArrayUtils.removeElement((short[]) null, (short) 1);
442         assertNull(array);
443         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_SHORT_ARRAY, (short) 1);
444         assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, array));
445         assertEquals(Short.TYPE, array.getClass().getComponentType());
446         array = ArrayUtils.removeElement(new short[] {1}, (short) 1);
447         assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, array));
448         assertEquals(Short.TYPE, array.getClass().getComponentType());
449         array = ArrayUtils.removeElement(new short[] {1, 2}, (short) 1);
450         assertTrue(Arrays.equals(new short[] {2}, array));
451         assertEquals(Short.TYPE, array.getClass().getComponentType());
452         array = ArrayUtils.removeElement(new short[] {1, 2, 1}, (short) 1);
453         assertTrue(Arrays.equals(new short[] {2, 1}, array));
454         assertEquals(Short.TYPE, array.getClass().getComponentType());
455     }
456     
457 }
458
Popular Tags