예제 #1
0
  @Test(expected = ArrayStoreException.class)
  public void testMergeArraysNativeIllegalType() {
    char[] chars = {'a', 'b', 'c'};
    int[] integers = {1, 2, 3}; // Integer not assignable to String

    CollectionUtil.mergeArrays(chars, integers);
  }
예제 #2
0
  @Test(expected = ArrayStoreException.class)
  public void testMergeArraysObjectIllegalType() {
    String[] strings = {"foo", "bar", "baz"};
    Integer[] integers = {1, 2, 3}; // Integer not assignable to String

    CollectionUtil.mergeArrays(strings, integers);
  }
예제 #3
0
  @Test
  public void testMergeArraysObjectAssignable() {
    Integer[] integers = {1, 2, 3}; // Integer assignable to Object

    Object[] merged = (Object[]) CollectionUtil.mergeArrays(stringObjects, integers);
    assertArrayEquals(new Object[] {"foo", "bar", "baz", 1, 2, 3}, merged);
  }
예제 #4
0
  @Test
  public void testMergeArraysNative() {
    char[] chars = {'a', 'b', 'c'};
    char[] more = {'x', 'y', 'z'};

    char[] merged = (char[]) CollectionUtil.mergeArrays(chars, more);
    assertArrayEquals(new char[] {'a', 'b', 'c', 'x', 'y', 'z'}, merged);
  }
예제 #5
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testMergeArraysObjectNegativeSecondLength() {
   CollectionUtil.mergeArrays(stringObjects, 1, 2, integerObjects, 2, -1);
 }
예제 #6
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testMergeArraysObjectBadSecondOffset() {
   CollectionUtil.mergeArrays(stringObjects, 1, 2, integerObjects, 4, 1);
 }
예제 #7
0
 @Test
 public void testMergeArraysObjectOffset() {
   Object[] merged =
       (Object[]) CollectionUtil.mergeArrays(stringObjects, 1, 2, integerObjects, 2, 1);
   assertArrayEquals(new Object[] {"bar", "baz", 3}, merged);
 }