private static void appendRecursiveTypes(final StringBuilder buf, final int[] recursiveTypeIndexes, final Type[] argumentTypes) { for (int i = 0; i < recursiveTypeIndexes.length; i++) { appendAllTo(buf.append('<'), ", ", argumentTypes[i].toString()).append('>'); } final Type[] argumentsFiltered = ArrayUtils.removeAll(argumentTypes, recursiveTypeIndexes); if (argumentsFiltered.length > 0) { appendAllTo(buf.append('<'), ", ", argumentsFiltered).append('>'); } }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllObjectArrayNegativeIndex() { ArrayUtils.removeAll(new Object[] { "a", "b" }, -1); }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllObjectArrayOutOfBoundsIndex() { ArrayUtils.removeAll(new Object[] { "a", "b" }, 2); }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllCharArrayOutOfBoundsIndex() { ArrayUtils.removeAll(new char[] { 'a', 'b' }, 2); }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllDoubleArrayNegativeIndex() { ArrayUtils.removeAll(new double[] { 1, 2 }, -1); }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllCharArrayNegativeIndex() { ArrayUtils.removeAll(new char[] { 'a', 'b' }, -1); }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllFloatArrayNegativeIndex() { ArrayUtils.removeAll(new float[] { 1, 2 }, -1); }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllLongArrayNegativeIndex() { ArrayUtils.removeAll(new long[] { 1, 2 }, -1); }
@Test(expected = IndexOutOfBoundsException.class) public void testRemoveAllNullShortArray() { ArrayUtils.removeAll((short[]) null, 0); }
@Benchmark public int[] timeBitSetRemoveAll() { final BitSet toRemove = new BitSet(); final int[] array = new int[100]; toRemove.set(10, 20); return (int[]) ArrayUtils.removeAll(array, toRemove); }
@Benchmark public int[] timeExtractRemoveAll() { final BitSet toRemove = new BitSet(); final int[] array = new int[100]; toRemove.set(10, 20); final int[] extractIndices = extractIndices(toRemove); return (int[]) ArrayUtils.removeAll((Object)array, extractIndices); }
@Test public void testRemoveAllBooleanArrayRemoveNone() { final boolean[] array1 = new boolean[] { true, false }; final boolean[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertTrue(Arrays.equals(array1, array2)); assertEquals(boolean.class, array2.getClass().getComponentType()); }
@Test public void testRemoveAllDoubleArrayRemoveNone() { final double[] array1 = new double[] { 1, 2 }; final double[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertTrue(Arrays.equals(array1, array2)); assertEquals(double.class, array2.getClass().getComponentType()); }
@Test public void testRemoveAllFloatArrayRemoveNone() { final float[] array1 = new float[] { 1, 2 }; final float[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertTrue(Arrays.equals(array1, array2)); assertEquals(float.class, array2.getClass().getComponentType()); }
@Test public void testRemoveAllCharArrayRemoveNone() { final char[] array1 = new char[] { 'a', 'b' }; final char[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertArrayEquals(array1, array2); assertEquals(char.class, array2.getClass().getComponentType()); }
@Test public void testRemoveAllShortArrayRemoveNone() { final short[] array1 = new short[] { 1, 2 }; final short[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertArrayEquals(array1, array2); assertEquals(short.class, array2.getClass().getComponentType()); }
@Test public void testRemoveAllLongArrayRemoveNone() { final long[] array1 = new long[] { 1, 2 }; final long[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertArrayEquals(array1, array2); assertEquals(long.class, array2.getClass().getComponentType()); }
@Test public void testRemoveAllObjectArrayRemoveNone() { final Object[] array1 = new Object[] { "foo", "bar", "baz" }; final Object[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertArrayEquals(array1, array2); assertEquals(Object.class, array2.getClass().getComponentType()); }
@Test public void testRemoveAllIntArrayRemoveNone() { final int[] array1 = new int[] { 1, 2 }; final int[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertArrayEquals(array1, array2); assertEquals(int.class, array2.getClass().getComponentType()); }
@Test public void testRemoveAllByteArrayRemoveNone() { final byte[] array1 = new byte[] { 1, 2 }; final byte[] array2 = ArrayUtils.removeAll(array1); assertNotSame(array1, array2); assertArrayEquals(array1, array2); assertEquals(byte.class, array2.getClass().getComponentType()); }