public class Int2DArrayAssert extends Abstract2DArrayAssert<Int2DArrayAssert,int[][],Integer>
ints.
To create an instance of this class, invoke .
Assertions.assertThat(int[][])
| Modifier and Type | Field and Description |
|---|---|
protected Int2DArrays |
int2dArrays |
actual, info, myself, objects, throwUnsupportedExceptionOnEquals| Constructor and Description |
|---|
Int2DArrayAssert(int[][] actual) |
| Modifier and Type | Method and Description |
|---|---|
Int2DArrayAssert |
contains(int[] value,
Index index)
Verifies that the actual array contains the given int[] at the given index.
|
Int2DArrayAssert |
doesNotContain(int[] value,
Index index)
Verifies that the actual array does not contain the given value at the given index.
|
Int2DArrayAssert |
hasDimensions(int expectedFirstDimension,
int expectedSecondDimension)
Verifies that the actual 2D array has the given dimensions.
|
Int2DArrayAssert |
hasNumberOfRows(int expected)
Verifies that the actual two-dimensional array has the given number of rows.
|
Int2DArrayAssert |
hasSameDimensionsAs(Object array)
Verifies that the actual
int[][] has the same dimensions as the given array. |
Int2DArrayAssert |
isDeepEqualTo(int[][] expected)
Verifies that the actual 2D array is deeply equal to the given one.
|
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.
|
Int2DArrayAssert |
isEqualTo(Object expected)
Verifies that the actual
int[][] is equal to the given one. |
Int2DArrayAssert |
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. |
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, isElementOfCustomAssert, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOfForProxy, satisfiesForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnErrorclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitas, as, as, describedAsprotected Int2DArrays int2dArrays
public Int2DArrayAssert isDeepEqualTo(int[][] expected)
Two arrays are considered deeply equal if both are null
or if they refer to arrays that contain the same number of elements and
all corresponding pairs of elements in the two arrays are deeply equal.
Example:
// assertion will pass
assertThat(new int[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new int[][] {{1, 2}, {3, 4}});
// assertions will fail
assertThat(new int[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new int[][] {{1, 2}, {9, 10}});
assertThat(new int[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new int[][] {{1, 2, 3}, {4}});isDeepEqualTo in class Abstract2DArrayAssert<Int2DArrayAssert,int[][],Integer>expected - the given value to compare the actual value to.this assertion object.public Int2DArrayAssert isEqualTo(Object expected)
int[][] is equal to the given one.
WARNING! This method will use equals to compare (it will compare arrays references only).
Unless you specify a comparator with AbstractAssert.usingComparator(Comparator), it is advised to use
isDeepEqualTo(int[][]) instead.
Example:
int[][] array = {{1, 2}, {3, 4}};
// assertion will pass
assertThat(array).isEqualTo(array);
// assertion will fail as isEqualTo calls equals which compares arrays references only.
assertThat(array).isEqualTo(new int[][] {{1, 2}, {3, 4}});isEqualTo in interface Assert<Int2DArrayAssert,int[][]>isEqualTo in class AbstractAssert<Int2DArrayAssert,int[][]>expected - the given value to compare the actual int[][] to.this assertion object.AssertionError - if the actual int[][] is not equal to the given one.public void isNullOrEmpty()
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();public void isEmpty()
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();public Int2DArrayAssert isNotEmpty()
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();this assertion object.public Int2DArrayAssert hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
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); 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.this assertion object.public Int2DArrayAssert hasNumberOfRows(int expected)
Example:
// assertion will pass
assertThat(new int[][] {{1, 2, 3}, {4, 5, 6}}).hasNumberOfRows(2);
assertThat(new int[][] {{1}, {1, 2}, {1, 2, 3}}).hasNumberOfRows(3);
// assertions will fail
assertThat(new int[][] { }).hasNumberOfRows(1);
assertThat(new int[][] {{1, 2, 3}, {4, 5, 6}}).hasNumberOfRows(3);
assertThat(new int[][] {{1, 2, 3}, {4, 5, 6, 7}}).hasNumberOfRows(1); expected - the expected number of rows of the two-dimensional array.this assertion object.AssertionError - if the actual number of rows are not equal to the given one.public Int2DArrayAssert hasSameDimensionsAs(Object array)
int[][] has the same dimensions as the given array.
Parameter is declared as Object to accept both Object and primitive arrays.
Example: int[][] intArray = {{1, 2, 3}, {4, 5, 6}};
char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};
// assertion will pass
assertThat(intArray).hasSameDimensionsAs(charArray);
// assertions will fail
assertThat(intArray).hasSameDimensionsAs(new int[][] {{'a', 'b'}, {'c', 'd'}, {'e', 'f'}});
assertThat(intArray).hasSameDimensionsAs(new int[][] {{'a', 'b'}, {'c', 'd', 'e'}});
assertThat(intArray).hasSameDimensionsAs(new int[][] {{'a', 'b', 'c'}, {'d', 'e'}});array - the array to compare dimensions with actual int[][].this assertion object.AssertionError - if the actual int[][] is null.AssertionError - if the array parameter is null or is not a true array.AssertionError - if actual int[][] and given array don't have the same dimensions.public Int2DArrayAssert contains(int[] value, Index index)
Example:
// assertion will pass
assertThat(new int[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new int[] {3, 4}, atIndex(1));
// assertions will fail
assertThat(new int[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new int[] {3, 4}, atIndex(0));
assertThat(new int[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new int[] {7, 8}, atIndex(2));value - the value to look for.index - the index where the value should be stored in the actual array.AssertionError - if the actual array is null or empty.NullPointerException - if the given Index is null.IndexOutOfBoundsException - if the value of the given Index is equal to or greater than the size of
the actual array.AssertionError - if the actual array does not contain the given value at the given index.public Int2DArrayAssert doesNotContain(int[] value, Index index)
Example:
// assertions will pass
assertThat(new int[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new int[] {3, 4}, atIndex(0));
assertThat(new int[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new int[] {7, 8}, atIndex(2));
// assertion will fail
assertThat(new int[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new int[] {3, 4}, atIndex(1));value - the value to look for.index - the index where the value should be stored in the actual array.AssertionError - if the actual array is null.NullPointerException - if the given Index is null.AssertionError - if the actual array contains the given value at the given index.Copyright © 2025. All rights reserved.