Exemplo n.º 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);
  }
Exemplo n.º 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);
  }
Exemplo n.º 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);
  }
Exemplo n.º 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);
  }
Exemplo n.º 5
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testMergeArraysObjectNegativeSecondLength() {
   CollectionUtil.mergeArrays(stringObjects, 1, 2, integerObjects, 2, -1);
 }
Exemplo n.º 6
0
 @Test(expected = IndexOutOfBoundsException.class)
 public void testMergeArraysObjectBadSecondOffset() {
   CollectionUtil.mergeArrays(stringObjects, 1, 2, integerObjects, 4, 1);
 }
Exemplo n.º 7
0
 @Test
 public void testMergeArraysObjectOffset() {
   Object[] merged =
       (Object[]) CollectionUtil.mergeArrays(stringObjects, 1, 2, integerObjects, 2, 1);
   assertArrayEquals(new Object[] {"bar", "baz", 3}, merged);
 }