1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package org.apache.commons.lang;
19 
20 import java.util.Arrays;
21 
22 import junit.framework.TestCase;
23 
24 /**
25  * Tests ArrayUtils remove and removeElement methods.
26  *
27  * @author Maarten Coene
28  * @version $Id: ArrayUtilsRemoveTest.java 905628 2010-02-02 13:29:55Z niallp $
29  */
30 public class ArrayUtilsRemoveTest extends TestCase {
31 
testRemoveObjectArray()32     public void testRemoveObjectArray() {
33         Object[] array;
34         array = ArrayUtils.remove(new Object[] {"a"}, 0);
35         assertTrue(Arrays.equals(ArrayUtils.EMPTY_OBJECT_ARRAY, array));
36         assertEquals(Object.class, array.getClass().getComponentType());
37         array = ArrayUtils.remove(new Object[] {"a", "b"}, 0);
38         assertTrue(Arrays.equals(new Object[] {"b"}, array));
39         assertEquals(Object.class, array.getClass().getComponentType());
40         array = ArrayUtils.remove(new Object[] {"a", "b"}, 1);
41         assertTrue(Arrays.equals(new Object[] {"a"}, array));
42         assertEquals(Object.class, array.getClass().getComponentType());
43         array = ArrayUtils.remove(new Object[] {"a", "b", "c"}, 1);
44         assertTrue(Arrays.equals(new Object[] {"a", "c"}, array));
45         assertEquals(Object.class, array.getClass().getComponentType());
46         try {
47             ArrayUtils.remove(new Object[] {"a", "b"}, -1);
48             fail("IndexOutOfBoundsException expected");
49         } catch (IndexOutOfBoundsException e) {}
50         try {
51             ArrayUtils.remove(new Object[] {"a", "b"}, 2);
52             fail("IndexOutOfBoundsException expected");
53         } catch (IndexOutOfBoundsException e) {}
54         try {
55             ArrayUtils.remove((Object[]) null, 0);
56             fail("IndexOutOfBoundsException expected");
57         } catch (IndexOutOfBoundsException e) {}
58     }
59 
testRemoveNumberArray()60     public void testRemoveNumberArray(){
61         Number[] inarray = {new Integer(1), new Long(2), new Byte((byte) 3)};
62         assertEquals(3, inarray.length);
63         Number[] outarray;
64         outarray = (Number[])ArrayUtils.remove(inarray, 1);
65         assertEquals(2, outarray.length);
66         assertEquals(Number.class, outarray.getClass().getComponentType());
67         outarray = (Number[])ArrayUtils.remove(outarray, 1);
68         assertEquals(1, outarray.length);
69         assertEquals(Number.class, outarray.getClass().getComponentType());
70         outarray = (Number[])ArrayUtils.remove(outarray, 0);
71         assertEquals(0, outarray.length);
72         assertEquals(Number.class, outarray.getClass().getComponentType());
73     }
74 
testRemoveBooleanArray()75     public void testRemoveBooleanArray() {
76         boolean[] array;
77         array = ArrayUtils.remove(new boolean[] {true}, 0);
78         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, array));
79         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
80         array = ArrayUtils.remove(new boolean[] {true, false}, 0);
81         assertTrue(Arrays.equals(new boolean[] {false}, array));
82         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
83         array = ArrayUtils.remove(new boolean[] {true, false}, 1);
84         assertTrue(Arrays.equals(new boolean[] {true}, array));
85         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
86         array = ArrayUtils.remove(new boolean[] {true, false, true}, 1);
87         assertTrue(Arrays.equals(new boolean[] {true, true}, array));
88         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
89         try {
90             ArrayUtils.remove(new boolean[] {true, false}, -1);
91             fail("IndexOutOfBoundsException expected");
92         } catch (IndexOutOfBoundsException e) {}
93         try {
94             ArrayUtils.remove(new boolean[] {true, false}, 2);
95             fail("IndexOutOfBoundsException expected");
96         } catch (IndexOutOfBoundsException e) {}
97         try {
98             ArrayUtils.remove((boolean[]) null, 0);
99             fail("IndexOutOfBoundsException expected");
100         } catch (IndexOutOfBoundsException e) {}
101     }
102 
testRemoveByteArray()103     public void testRemoveByteArray() {
104         byte[] array;
105         array = ArrayUtils.remove(new byte[] {1}, 0);
106         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BYTE_ARRAY, array));
107         assertEquals(Byte.TYPE, array.getClass().getComponentType());
108         array = ArrayUtils.remove(new byte[] {1, 2}, 0);
109         assertTrue(Arrays.equals(new byte[] {2}, array));
110         assertEquals(Byte.TYPE, array.getClass().getComponentType());
111         array = ArrayUtils.remove(new byte[] {1, 2}, 1);
112         assertTrue(Arrays.equals(new byte[] {1}, array));
113         assertEquals(Byte.TYPE, array.getClass().getComponentType());
114         array = ArrayUtils.remove(new byte[] {1, 2, 1}, 1);
115         assertTrue(Arrays.equals(new byte[] {1, 1}, array));
116         assertEquals(Byte.TYPE, array.getClass().getComponentType());
117         try {
118             ArrayUtils.remove(new byte[] {1, 2}, -1);
119             fail("IndexOutOfBoundsException expected");
120         } catch (IndexOutOfBoundsException e) {}
121         try {
122             ArrayUtils.remove(new byte[] {1, 2}, 2);
123             fail("IndexOutOfBoundsException expected");
124         } catch (IndexOutOfBoundsException e) {}
125         try {
126             ArrayUtils.remove((byte[]) null, 0);
127             fail("IndexOutOfBoundsException expected");
128         } catch (IndexOutOfBoundsException e) {}
129     }
130 
testRemoveCharArray()131     public void testRemoveCharArray() {
132         char[] array;
133         array = ArrayUtils.remove(new char[] {'a'}, 0);
134         assertTrue(Arrays.equals(ArrayUtils.EMPTY_CHAR_ARRAY, array));
135         assertEquals(Character.TYPE, array.getClass().getComponentType());
136         array = ArrayUtils.remove(new char[] {'a', 'b'}, 0);
137         assertTrue(Arrays.equals(new char[] {'b'}, array));
138         assertEquals(Character.TYPE, array.getClass().getComponentType());
139         array = ArrayUtils.remove(new char[] {'a', 'b'}, 1);
140         assertTrue(Arrays.equals(new char[] {'a'}, array));
141         assertEquals(Character.TYPE, array.getClass().getComponentType());
142         array = ArrayUtils.remove(new char[] {'a', 'b', 'c'}, 1);
143         assertTrue(Arrays.equals(new char[] {'a', 'c'}, array));
144         assertEquals(Character.TYPE, array.getClass().getComponentType());
145         try {
146             ArrayUtils.remove(new char[] {'a', 'b'}, -1);
147             fail("IndexOutOfBoundsException expected");
148         } catch (IndexOutOfBoundsException e) {}
149         try {
150             ArrayUtils.remove(new char[] {'a', 'b'}, 2);
151             fail("IndexOutOfBoundsException expected");
152         } catch (IndexOutOfBoundsException e) {}
153         try {
154             ArrayUtils.remove((char[]) null, 0);
155             fail("IndexOutOfBoundsException expected");
156         } catch (IndexOutOfBoundsException e) {}
157     }
158 
testRemoveDoubleArray()159     public void testRemoveDoubleArray() {
160         double[] array;
161         array = ArrayUtils.remove(new double[] {1}, 0);
162         assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array));
163         assertEquals(Double.TYPE, array.getClass().getComponentType());
164         array = ArrayUtils.remove(new double[] {1, 2}, 0);
165         assertTrue(Arrays.equals(new double[] {2}, array));
166         assertEquals(Double.TYPE, array.getClass().getComponentType());
167         array = ArrayUtils.remove(new double[] {1, 2}, 1);
168         assertTrue(Arrays.equals(new double[] {1}, array));
169         assertEquals(Double.TYPE, array.getClass().getComponentType());
170         array = ArrayUtils.remove(new double[] {1, 2, 1}, 1);
171         assertTrue(Arrays.equals(new double[] {1, 1}, array));
172         assertEquals(Double.TYPE, array.getClass().getComponentType());
173         try {
174             ArrayUtils.remove(new double[] {1, 2}, -1);
175             fail("IndexOutOfBoundsException expected");
176         } catch (IndexOutOfBoundsException e) {}
177         try {
178             ArrayUtils.remove(new double[] {1, 2}, 2);
179             fail("IndexOutOfBoundsException expected");
180         } catch (IndexOutOfBoundsException e) {}
181         try {
182             ArrayUtils.remove((double[]) null, 0);
183             fail("IndexOutOfBoundsException expected");
184         } catch (IndexOutOfBoundsException e) {}
185     }
186 
testRemoveFloatArray()187     public void testRemoveFloatArray() {
188         float[] array;
189         array = ArrayUtils.remove(new float[] {1}, 0);
190         assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, array));
191         assertEquals(Float.TYPE, array.getClass().getComponentType());
192         array = ArrayUtils.remove(new float[] {1, 2}, 0);
193         assertTrue(Arrays.equals(new float[] {2}, array));
194         assertEquals(Float.TYPE, array.getClass().getComponentType());
195         array = ArrayUtils.remove(new float[] {1, 2}, 1);
196         assertTrue(Arrays.equals(new float[] {1}, array));
197         assertEquals(Float.TYPE, array.getClass().getComponentType());
198         array = ArrayUtils.remove(new float[] {1, 2, 1}, 1);
199         assertTrue(Arrays.equals(new float[] {1, 1}, array));
200         assertEquals(Float.TYPE, array.getClass().getComponentType());
201         try {
202             ArrayUtils.remove(new float[] {1, 2}, -1);
203             fail("IndexOutOfBoundsException expected");
204         } catch (IndexOutOfBoundsException e) {}
205         try {
206             ArrayUtils.remove(new float[] {1, 2}, 2);
207             fail("IndexOutOfBoundsException expected");
208         } catch (IndexOutOfBoundsException e) {}
209         try {
210             ArrayUtils.remove((float[]) null, 0);
211             fail("IndexOutOfBoundsException expected");
212         } catch (IndexOutOfBoundsException e) {}
213     }
214 
testRemoveIntArray()215     public void testRemoveIntArray() {
216         int[] array;
217         array = ArrayUtils.remove(new int[] {1}, 0);
218         assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, array));
219         assertEquals(Integer.TYPE, array.getClass().getComponentType());
220         array = ArrayUtils.remove(new int[] {1, 2}, 0);
221         assertTrue(Arrays.equals(new int[] {2}, array));
222         assertEquals(Integer.TYPE, array.getClass().getComponentType());
223         array = ArrayUtils.remove(new int[] {1, 2}, 1);
224         assertTrue(Arrays.equals(new int[] {1}, array));
225         assertEquals(Integer.TYPE, array.getClass().getComponentType());
226         array = ArrayUtils.remove(new int[] {1, 2, 1}, 1);
227         assertTrue(Arrays.equals(new int[] {1, 1}, array));
228         assertEquals(Integer.TYPE, array.getClass().getComponentType());
229         try {
230             ArrayUtils.remove(new int[] {1, 2}, -1);
231             fail("IndexOutOfBoundsException expected");
232         } catch (IndexOutOfBoundsException e) {}
233         try {
234             ArrayUtils.remove(new int[] {1, 2}, 2);
235             fail("IndexOutOfBoundsException expected");
236         } catch (IndexOutOfBoundsException e) {}
237         try {
238             ArrayUtils.remove((int[]) null, 0);
239             fail("IndexOutOfBoundsException expected");
240         } catch (IndexOutOfBoundsException e) {}
241     }
242 
testRemoveLongArray()243     public void testRemoveLongArray() {
244         long[] array;
245         array = ArrayUtils.remove(new long[] {1}, 0);
246         assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
247         assertEquals(Long.TYPE, array.getClass().getComponentType());
248         array = ArrayUtils.remove(new long[] {1, 2}, 0);
249         assertTrue(Arrays.equals(new long[] {2}, array));
250         assertEquals(Long.TYPE, array.getClass().getComponentType());
251         array = ArrayUtils.remove(new long[] {1, 2}, 1);
252         assertTrue(Arrays.equals(new long[] {1}, array));
253         assertEquals(Long.TYPE, array.getClass().getComponentType());
254         array = ArrayUtils.remove(new long[] {1, 2, 1}, 1);
255         assertTrue(Arrays.equals(new long[] {1, 1}, array));
256         assertEquals(Long.TYPE, array.getClass().getComponentType());
257         try {
258             ArrayUtils.remove(new long[] {1, 2}, -1);
259             fail("IndexOutOfBoundsException expected");
260         } catch (IndexOutOfBoundsException e) {}
261         try {
262             ArrayUtils.remove(new long[] {1, 2}, 2);
263             fail("IndexOutOfBoundsException expected");
264         } catch (IndexOutOfBoundsException e) {}
265         try {
266             ArrayUtils.remove((long[]) null, 0);
267             fail("IndexOutOfBoundsException expected");
268         } catch (IndexOutOfBoundsException e) {}
269     }
270 
testRemoveShortArray()271     public void testRemoveShortArray() {
272         short[] array;
273         array = ArrayUtils.remove(new short[] {1}, 0);
274         assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, array));
275         assertEquals(Short.TYPE, array.getClass().getComponentType());
276         array = ArrayUtils.remove(new short[] {1, 2}, 0);
277         assertTrue(Arrays.equals(new short[] {2}, array));
278         assertEquals(Short.TYPE, array.getClass().getComponentType());
279         array = ArrayUtils.remove(new short[] {1, 2}, 1);
280         assertTrue(Arrays.equals(new short[] {1}, array));
281         assertEquals(Short.TYPE, array.getClass().getComponentType());
282         array = ArrayUtils.remove(new short[] {1, 2, 1}, 1);
283         assertTrue(Arrays.equals(new short[] {1, 1}, array));
284         assertEquals(Short.TYPE, array.getClass().getComponentType());
285         try {
286             ArrayUtils.remove(new short[] {1, 2}, -1);
287             fail("IndexOutOfBoundsException expected");
288         } catch (IndexOutOfBoundsException e) {}
289         try {
290             ArrayUtils.remove(new short[] {1, 2}, 2);
291             fail("IndexOutOfBoundsException expected");
292         } catch (IndexOutOfBoundsException e) {}
293         try {
294             ArrayUtils.remove((short[]) null, 0);
295             fail("IndexOutOfBoundsException expected");
296         } catch (IndexOutOfBoundsException e) {}
297     }
298 
testRemoveElementObjectArray()299     public void testRemoveElementObjectArray() {
300         Object[] array;
301         array = ArrayUtils.removeElement((Object[]) null, "a");
302         assertNull(array);
303         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_OBJECT_ARRAY, "a");
304         assertTrue(Arrays.equals(ArrayUtils.EMPTY_OBJECT_ARRAY, array));
305         assertEquals(Object.class, array.getClass().getComponentType());
306         array = ArrayUtils.removeElement(new Object[] {"a"}, "a");
307         assertTrue(Arrays.equals(ArrayUtils.EMPTY_OBJECT_ARRAY, array));
308         assertEquals(Object.class, array.getClass().getComponentType());
309         array = ArrayUtils.removeElement(new Object[] {"a", "b"}, "a");
310         assertTrue(Arrays.equals(new Object[] {"b"}, array));
311         assertEquals(Object.class, array.getClass().getComponentType());
312         array = ArrayUtils.removeElement(new Object[] {"a", "b", "a"}, "a");
313         assertTrue(Arrays.equals(new Object[] {"b", "a"}, array));
314         assertEquals(Object.class, array.getClass().getComponentType());
315     }
316 
testRemoveElementBooleanArray()317     public void testRemoveElementBooleanArray() {
318         boolean[] array;
319         array = ArrayUtils.removeElement((boolean[]) null, true);
320         assertNull(array);
321         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_BOOLEAN_ARRAY, true);
322         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, array));
323         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
324         array = ArrayUtils.removeElement(new boolean[] {true}, true);
325         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BOOLEAN_ARRAY, array));
326         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
327         array = ArrayUtils.removeElement(new boolean[] {true, false}, true);
328         assertTrue(Arrays.equals(new boolean[] {false}, array));
329         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
330         array = ArrayUtils.removeElement(new boolean[] {true, false, true}, true);
331         assertTrue(Arrays.equals(new boolean[] {false, true}, array));
332         assertEquals(Boolean.TYPE, array.getClass().getComponentType());
333     }
334 
testRemoveElementByteArray()335     public void testRemoveElementByteArray() {
336         byte[] array;
337         array = ArrayUtils.removeElement((byte[]) null, (byte) 1);
338         assertNull(array);
339         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_BYTE_ARRAY, (byte) 1);
340         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BYTE_ARRAY, array));
341         assertEquals(Byte.TYPE, array.getClass().getComponentType());
342         array = ArrayUtils.removeElement(new byte[] {1}, (byte) 1);
343         assertTrue(Arrays.equals(ArrayUtils.EMPTY_BYTE_ARRAY, array));
344         assertEquals(Byte.TYPE, array.getClass().getComponentType());
345         array = ArrayUtils.removeElement(new byte[] {1, 2}, (byte) 1);
346         assertTrue(Arrays.equals(new byte[] {2}, array));
347         assertEquals(Byte.TYPE, array.getClass().getComponentType());
348         array = ArrayUtils.removeElement(new byte[] {1, 2, 1}, (byte) 1);
349         assertTrue(Arrays.equals(new byte[] {2, 1}, array));
350         assertEquals(Byte.TYPE, array.getClass().getComponentType());
351     }
352 
testRemoveElementCharArray()353     public void testRemoveElementCharArray() {
354         char[] array;
355         array = ArrayUtils.removeElement((char[]) null, 'a');
356         assertNull(array);
357         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_CHAR_ARRAY, 'a');
358         assertTrue(Arrays.equals(ArrayUtils.EMPTY_CHAR_ARRAY, array));
359         assertEquals(Character.TYPE, array.getClass().getComponentType());
360         array = ArrayUtils.removeElement(new char[] {'a'}, 'a');
361         assertTrue(Arrays.equals(ArrayUtils.EMPTY_CHAR_ARRAY, array));
362         assertEquals(Character.TYPE, array.getClass().getComponentType());
363         array = ArrayUtils.removeElement(new char[] {'a', 'b'}, 'a');
364         assertTrue(Arrays.equals(new char[] {'b'}, array));
365         assertEquals(Character.TYPE, array.getClass().getComponentType());
366         array = ArrayUtils.removeElement(new char[] {'a', 'b', 'a'}, 'a');
367         assertTrue(Arrays.equals(new char[] {'b', 'a'}, array));
368         assertEquals(Character.TYPE, array.getClass().getComponentType());
369     }
370 
testRemoveElementDoubleArray()371     public void testRemoveElementDoubleArray() {
372         double[] array;
373         array = ArrayUtils.removeElement((double[]) null, (double) 1);
374         assertNull(array);
375         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_DOUBLE_ARRAY, (double) 1);
376         assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array));
377         assertEquals(Double.TYPE, array.getClass().getComponentType());
378         array = ArrayUtils.removeElement(new double[] {1}, (double) 1);
379         assertTrue(Arrays.equals(ArrayUtils.EMPTY_DOUBLE_ARRAY, array));
380         assertEquals(Double.TYPE, array.getClass().getComponentType());
381         array = ArrayUtils.removeElement(new double[] {1, 2}, (double) 1);
382         assertTrue(Arrays.equals(new double[] {2}, array));
383         assertEquals(Double.TYPE, array.getClass().getComponentType());
384         array = ArrayUtils.removeElement(new double[] {1, 2, 1}, (double) 1);
385         assertTrue(Arrays.equals(new double[] {2, 1}, array));
386         assertEquals(Double.TYPE, array.getClass().getComponentType());
387     }
388 
testRemoveElementFloatArray()389     public void testRemoveElementFloatArray() {
390         float[] array;
391         array = ArrayUtils.removeElement((float[]) null, (float) 1);
392         assertNull(array);
393         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_FLOAT_ARRAY, (float) 1);
394         assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, array));
395         assertEquals(Float.TYPE, array.getClass().getComponentType());
396         array = ArrayUtils.removeElement(new float[] {1}, (float) 1);
397         assertTrue(Arrays.equals(ArrayUtils.EMPTY_FLOAT_ARRAY, array));
398         assertEquals(Float.TYPE, array.getClass().getComponentType());
399         array = ArrayUtils.removeElement(new float[] {1, 2}, (float) 1);
400         assertTrue(Arrays.equals(new float[] {2}, array));
401         assertEquals(Float.TYPE, array.getClass().getComponentType());
402         array = ArrayUtils.removeElement(new float[] {1, 2, 1}, (float) 1);
403         assertTrue(Arrays.equals(new float[] {2, 1}, array));
404         assertEquals(Float.TYPE, array.getClass().getComponentType());
405     }
406 
testRemoveElementIntArray()407     public void testRemoveElementIntArray() {
408         int[] array;
409         array = ArrayUtils.removeElement((int[]) null, 1);
410         assertNull(array);
411         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_INT_ARRAY, 1);
412         assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, array));
413         assertEquals(Integer.TYPE, array.getClass().getComponentType());
414         array = ArrayUtils.removeElement(new int[] {1}, 1);
415         assertTrue(Arrays.equals(ArrayUtils.EMPTY_INT_ARRAY, array));
416         assertEquals(Integer.TYPE, array.getClass().getComponentType());
417         array = ArrayUtils.removeElement(new int[] {1, 2}, 1);
418         assertTrue(Arrays.equals(new int[] {2}, array));
419         assertEquals(Integer.TYPE, array.getClass().getComponentType());
420         array = ArrayUtils.removeElement(new int[] {1, 2, 1}, 1);
421         assertTrue(Arrays.equals(new int[] {2, 1}, array));
422         assertEquals(Integer.TYPE, array.getClass().getComponentType());
423     }
424 
testRemoveElementLongArray()425     public void testRemoveElementLongArray() {
426         long[] array;
427         array = ArrayUtils.removeElement((long[]) null, (long) 1);
428         assertNull(array);
429         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_LONG_ARRAY, (long) 1);
430         assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
431         assertEquals(Long.TYPE, array.getClass().getComponentType());
432         array = ArrayUtils.removeElement(new long[] {1}, (long) 1);
433         assertTrue(Arrays.equals(ArrayUtils.EMPTY_LONG_ARRAY, array));
434         assertEquals(Long.TYPE, array.getClass().getComponentType());
435         array = ArrayUtils.removeElement(new long[] {1, 2}, (long) 1);
436         assertTrue(Arrays.equals(new long[] {2}, array));
437         assertEquals(Long.TYPE, array.getClass().getComponentType());
438         array = ArrayUtils.removeElement(new long[] {1, 2, 1}, (long) 1);
439         assertTrue(Arrays.equals(new long[] {2, 1}, array));
440         assertEquals(Long.TYPE, array.getClass().getComponentType());
441     }
442 
testRemoveElementShortArray()443     public void testRemoveElementShortArray() {
444         short[] array;
445         array = ArrayUtils.removeElement((short[]) null, (short) 1);
446         assertNull(array);
447         array = ArrayUtils.removeElement(ArrayUtils.EMPTY_SHORT_ARRAY, (short) 1);
448         assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, array));
449         assertEquals(Short.TYPE, array.getClass().getComponentType());
450         array = ArrayUtils.removeElement(new short[] {1}, (short) 1);
451         assertTrue(Arrays.equals(ArrayUtils.EMPTY_SHORT_ARRAY, array));
452         assertEquals(Short.TYPE, array.getClass().getComponentType());
453         array = ArrayUtils.removeElement(new short[] {1, 2}, (short) 1);
454         assertTrue(Arrays.equals(new short[] {2}, array));
455         assertEquals(Short.TYPE, array.getClass().getComponentType());
456         array = ArrayUtils.removeElement(new short[] {1, 2, 1}, (short) 1);
457         assertTrue(Arrays.equals(new short[] {2, 1}, array));
458         assertEquals(Short.TYPE, array.getClass().getComponentType());
459     }
460 
461 }
462