Interface Array2DAssert<SELF extends Array2DAssert<SELF,​ELEMENT>,​ELEMENT>

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      SELF hasDimensions​(int expectedFirstDimension, int expectedSecondDimension)
      Verifies that the actual 2D array has the given dimensions.
      SELF hasSameDimensionsAs​(Object array)
      Verifies that the actual array has the same dimensions as the given array.
      void isEmpty()
      Verifies that the actual array is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.
      SELF isNotEmpty()
      Verifies that the actual array is not empty, not empty means the array has at least one element.
      void isNullOrEmpty()
      Verifies that the actual array is null or empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.
    • Method Detail

      • isNullOrEmpty

        void isNullOrEmpty()
        Verifies that the actual array is null or empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.

        Example:

         // assertions will pass
         int[][] array = null;
         assertThat(array).isNullOrEmpty();
         assertThat(new int[][] { }).isNullOrEmpty();
         assertThat(new int[][] {{ }}).isNullOrEmpty();
         // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
         assertThat(new int[][] {{ }, { }, { }}).isNullOrEmpty();
        
         // assertion will fail
         assertThat(new int[][] {{ 1 }, { 2 }}).isNullOrEmpty();
        Throws:
        AssertionError - if the actual array is not null or not empty.
      • isEmpty

        void isEmpty()
        Verifies that the actual array is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.

        Example:

         // assertions will pass
         assertThat(new int[][] {{}}).isEmpty();
         // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
         assertThat(new int[][] {{ }, { }, { }}).isEmpty();
        
         // assertions will fail
         assertThat(new int[][] {{ 1 }, { 2 }}).isEmpty();
         int[][] array = null;
         assertThat(array).isEmpty();
        Throws:
        AssertionError - if the actual array is not empty.
      • isNotEmpty

        SELF isNotEmpty()
        Verifies that the actual array is not empty, not empty means the array has at least one element.

        Example:

         // assertions will pass
         assertThat(new int[][] {{ 1 }, { 2 }}).isNotEmpty();
         assertThat(new int[][] {{ }, { 2 }}).isNotEmpty();
        
         // assertions will fail
         assertThat(new int[][] { }).isNotEmpty();
         assertThat(new int[][] {{ }}).isNotEmpty();
         // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
         assertThat(new int[][] {{ }, { }, { }}).isNotEmpty();
         int[][] array = null;
         assertThat(array).isNotEmpty();
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is empty or null.
      • hasDimensions

        SELF hasDimensions​(int expectedFirstDimension,
                           int expectedSecondDimension)
        Verifies that the actual 2D array has the given dimensions.

        Example:

         // assertion will pass
         assertThat(new int[][] {{1, 2, 3}, {4, 5, 6}}).hasDimensions(2, 3);
        
         // assertions will fail
         assertThat(new int[][] { }).hasSize(1, 1);
         assertThat(new int[][] {{1, 2, 3}, {4, 5, 6}}).hasDimensions(3, 2);
         assertThat(new int[][] {{1, 2, 3}, {4, 5, 6, 7}}).hasDimensions(2, 3); 
        Parameters:
        expectedFirstDimension - the expected number of values in first dimension of the actual array.
        expectedSecondDimension - the expected number of values in second dimension of the actual array.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array's dimensions are not equal to the given ones.
      • hasSameDimensionsAs

        SELF hasSameDimensionsAs​(Object array)
        Verifies that the actual array has the same dimensions as the given array.

        Parameter is declared as Object to accept both Object[] and primitive arrays (e.g. int[]).

        Example:
         String[][] stringArray = {{"a", "b", "c"}, {"d", "e", "f"}};
         int[][] intArray = {{1, 2, 3}, {4, 5, 6}};
        
         // assertion will pass
         assertThat(stringArray).hasSameDimensionsAs(intArray);
        
         // assertions will fail
         assertThat(stringArray).hasSameDimensionsAs(new int[][] {{1, 2}, {3, 4}, {5, 6}});
         assertThat(stringArray).hasSameDimensionsAs(new int[][] {{1, 2}, {3, 4, 5}});
         assertThat(stringArray).hasSameDimensionsAs(new int[][] {{1, 2, 3}, {4, 5}});
        Parameters:
        array - the array to compare dimensions with actual array.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is null.
        AssertionError - if the array parameter is null or is not a true array.
        AssertionError - if actual array and given array don't have the same dimensions.