private void expectArrayContentsInOrder(List<E> expected, Object[] actual) { assertEquals("toArray() ordered contents: ", expected, Arrays.asList(actual)); }
/** * {@link Collection#toArray(Object[])} says: "Note that <tt>toArray(new Object[0])</tt> is * identical in function to <tt>toArray()</tt>." * * <p>For maximum effect, the collection under test should be created from an element array of a * type other than {@code Object[]}. */ public void testToArray_isPlainObjectArray() { Object[] array = collection.toArray(); assertEquals(Object[].class, array.getClass()); }
public void testToArray_emptyArrayOfObject() { Object[] in = new Object[0]; Object[] array = collection.toArray(in); assertEquals( "toArray(emptyObject[]) should return an array of type Object", Object[].class, array.getClass()); assertEquals("toArray(emptyObject[]).length", getNumElements(), array.length); expectArrayContentsAnyOrder(createSamplesArray(), array); }
public void testToArray_emptyArray() { E[] empty = getSubjectGenerator().createArray(0); E[] array = collection.toArray(empty); assertEquals( "toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass()); assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length); expectArrayContentsAnyOrder(createSamplesArray(), array); }
@CollectionFeature.Require(KNOWN_ORDER) public void testToArray_emptyArray_ordered() { E[] empty = getSubjectGenerator().createArray(0); E[] array = collection.toArray(empty); assertEquals( "toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass()); assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length); expectArrayContentsInOrder(getOrderedElements(), array); }
@CollectionFeature.Require(KNOWN_ORDER) public void testToArray_oversizedArray_ordered() { E[] array = getSubjectGenerator().createArray(getNumElements() + 2); array[getNumElements()] = e3(); array[getNumElements() + 1] = e3(); assertSame( "toArray(overSizedE[]) should return the given array", array, collection.toArray(array)); List<E> expected = getOrderedElements(); for (int i = 0; i < getNumElements(); i++) { assertEquals(expected.get(i), array[i]); } assertNull( "The array element immediately following the end of the collection should be nulled", array[getNumElements()]); // array[getNumElements() + 1] might or might not have been nulled }
private void expectArrayContentsInOrder(List<E> expected, Object[] actual) { assertEquals("toArray() ordered contents: ", expected, Arrays.asList(actual)); }
private void expectArrayContentsInOrder(List<E> expected, Object[] actual) { assertEquals("toArray() ordered contents: ", expected, Arrays.asList(actual)); }
/** * {@link Collection#toArray(Object[])} says: "Note that <tt>toArray(new Object[0])</tt> is * identical in function to <tt>toArray()</tt>." * * <p>For maximum effect, the collection under test should be created from an element array of a * type other than {@code Object[]}. */ public void testToArray_isPlainObjectArray() { Object[] array = collection.toArray(); assertEquals(Object[].class, array.getClass()); }
/** * {@link Collection#toArray(Object[])} says: "Note that * <tt>toArray(new Object[0])</tt> is identical in function to * <tt>toArray()</tt>." * * <p>For maximum effect, the collection under test should be created from an * element array of a type other than {@code Object[]}. */ public void testToArray_isPlainObjectArray() { Object[] array = collection.toArray(); assertEquals(Object[].class, array.getClass()); }
public void testToArray_emptyArrayOfObject() { Object[] in = new Object[0]; Object[] array = collection.toArray(in); assertEquals("toArray(emptyObject[]) should return an array of type Object", Object[].class, array.getClass()); assertEquals("toArray(emptyObject[]).length", getNumElements(), array.length); expectArrayContentsAnyOrder(createSamplesArray(), array); }
public void testToArray_emptyArrayOfObject() { Object[] in = new Object[0]; Object[] array = collection.toArray(in); assertEquals( "toArray(emptyObject[]) should return an array of type Object", Object[].class, array.getClass()); assertEquals("toArray(emptyObject[]).length", getNumElements(), array.length); expectArrayContentsAnyOrder(createSamplesArray(), array); }
public void testToArray_emptyArray() { E[] empty = getSubjectGenerator().createArray(0); E[] array = collection.toArray(empty); assertEquals("toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass()); assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length); expectArrayContentsAnyOrder(createSamplesArray(), array); }
public void testToArray_emptyArray() { E[] empty = getSubjectGenerator().createArray(0); E[] array = collection.toArray(empty); assertEquals( "toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass()); assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length); expectArrayContentsAnyOrder(createSamplesArray(), array); }
@CollectionFeature.Require(KNOWN_ORDER) public void testToArray_emptyArray_ordered() { E[] empty = getSubjectGenerator().createArray(0); E[] array = collection.toArray(empty); assertEquals("toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass()); assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length); expectArrayContentsInOrder(getOrderedElements(), array); }
@CollectionFeature.Require(KNOWN_ORDER) public void testToArray_emptyArray_ordered() { E[] empty = getSubjectGenerator().createArray(0); E[] array = collection.toArray(empty); assertEquals( "toArray(emptyT[]) should return an array of type T", empty.getClass(), array.getClass()); assertEquals("toArray(emptyT[]).length:", getNumElements(), array.length); expectArrayContentsInOrder(getOrderedElements(), array); }
@CollectionFeature.Require(KNOWN_ORDER) public void testToArray_oversizedArray_ordered() { E[] array = getSubjectGenerator().createArray(getNumElements() + 2); array[getNumElements()] = samples.e3; array[getNumElements() + 1] = samples.e3; assertSame("toArray(overSizedE[]) should return the given array", array, collection.toArray(array)); List<E> expected = getOrderedElements(); for (int i = 0; i < getNumElements(); i++) { assertEquals(expected.get(i), array[i]); } assertNull("The array element " + "immediately following the end of the collection should be nulled", array[getNumElements()]); // array[getNumElements() + 1] might or might not have been nulled }
@CollectionFeature.Require(KNOWN_ORDER) public void testToArray_oversizedArray_ordered() { E[] array = getSubjectGenerator().createArray(getNumElements() + 2); array[getNumElements()] = e3(); array[getNumElements() + 1] = e3(); assertSame( "toArray(overSizedE[]) should return the given array", array, collection.toArray(array)); List<E> expected = getOrderedElements(); for (int i = 0; i < getNumElements(); i++) { assertEquals(expected.get(i), array[i]); } assertNull( "The array element immediately following the end of the collection should be nulled", array[getNumElements()]); // array[getNumElements() + 1] might or might not have been nulled }