Interface ToArrayContract<E,C extends Collection<E>>

Type Parameters:
E - The element type being tested.
C - The collection type being tested.
All Superinterfaces:
CollectionContractConfig, CollectionContractSupport<E,C>, CollectionProviderSupport<E,C>, ContractSupport<C>, ElementProviderSupport<E>, ProviderSupport<C>, SupportedMethods
All Known Subinterfaces:
CollectionContract<E,C>, ListContract<E,L>, ListToArrayContract<E,L>, SequencedCollectionContract<E,C>

public interface ToArrayContract<E,C extends Collection<E>> extends CollectionContractSupport<E,C>
This interface tests if a collection class has implemented the toArray method correctly.
Since:
1.0.0
Author:
evanbergstrom
See Also:
  • Method Details

    • testToArrayOnEmptyCollection

      @Test @DisplayName("The toArray method works on an empty container.") default void testToArrayOnEmptyCollection()
      Tests that the toArray() method works for an empty collection.
    • testToArray

      @Test @DisplayName("The toArray method works on a container with elements") default void testToArray()
      Tests that the toArray() method works for a collection with elements.
    • testToArrayIsSafe

      @Test @DisplayName("The toArray method returns a safe array") default void testToArrayIsSafe()
      Tests that the toArray() method returns a safe array that can be modified without changing the elements of the container.
    • testToArrayStoreOnEmptyCollection

      @Test @DisplayName("The toArray method works on an empty container.") default void testToArrayStoreOnEmptyCollection()
      Tests that the toArray(T[]) method works for an empty collection.
    • testToArrayStore

      @Test @DisplayName("The toArray method works on a container with elements") default void testToArrayStore()
      Tests that the toArray(T[]) method works for a collection with elements.
    • testToArrayStoreThrowsOnNullArray

      @Test @DisplayName("The toArray(T[]) method throws on a null array.") default void testToArrayStoreThrowsOnNullArray()

      Tests that the toArray(T[]) method throws on a null array.

      Implementation Notes

      This test checks that the toArray(T[]) function throws the correct exception if it is called on a null value. IntelliJ will detect a problem when it is called with a null argument since the method declaration has a NotNull annotation. Since this is what we are trying to test, the inspection is suppressed here.

      Any implementations that use the NotNull annotation for the collection parameter may throw an IllegalArgumentException here, so either exception type is accepted.