Package org.assertj.core.api
Class Short2DArrayAssert
java.lang.Object
org.assertj.core.api.AbstractAssert<Short2DArrayAssert,short[][]>
org.assertj.core.api.Abstract2DArrayAssert<Short2DArrayAssert,short[][],Short>
org.assertj.core.api.Short2DArrayAssert
- All Implemented Interfaces:
Array2DAssert<Short2DArrayAssert,
,Short> Assert<Short2DArrayAssert,
,short[][]> Descriptable<Short2DArrayAssert>
,ExtensionPoints<Short2DArrayAssert,
short[][]>
Assertion methods for arrays of
short
s.
To create an instance of this class, invoke
.
Assertions.assertThat(short[][])
- Since:
- 3.17.0
- Author:
- Maciej Wajcht
-
Field Summary
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionVerifies that the actualshort[][]
contains the given short[] at the given index.Verifies that the actualshort[][]
contains the given short[] at the given index.doesNotContain
(int[] value, Index index) Verifies that the actualshort[][]
does not contain the given short[] at the given index.doesNotContain
(short[] value, Index index) Verifies that the actualshort[][]
does not contain the given short[] at the given index.hasDimensions
(int expectedFirstDimension, int expectedSecondDimension) Verifies that the actual 2D array has the given dimensions.hasNumberOfRows
(int expected) Verifies that the actual two-dimensional array has the given number of rows.hasSameDimensionsAs
(Object array) Verifies that the actualshort[][]
has the same dimensions as the given array.isDeepEqualTo
(short[][] expected) Verifies that the actualshort[][]
is deeply equal to the given one.void
isEmpty()
Verifies that the actualshort[][]
is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.Verifies that the actualshort[][]
is equal to the given one.Verifies that the actualshort[][]
is not empty, not empty means the array has at least one element.void
Verifies that the actualshort[][]
isnull
or empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.Methods inherited from class org.assertj.core.api.AbstractAssert
areEqual, asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, 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, usingRecursiveAssertion, usingRecursiveAssertion, usingRecursiveComparison, usingRecursiveComparison, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs, describedAs
-
Field Details
-
short2dArrays
protected org.assertj.core.internal.Short2DArrays short2dArrays
-
-
Constructor Details
-
Short2DArrayAssert
public Short2DArrayAssert(short[][] actual)
-
-
Method Details
-
isDeepEqualTo
Verifies that the actualshort[][]
is deeply equal to the given one.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 short[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new short[][] {{1, 2}, {3, 4}}); // assertions will fail assertThat(new short[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new short[][] {{1, 2}, {9, 10}}); assertThat(new short[][] {{1, 2}, {3, 4}}).isDeepEqualTo(new short[][] {{1, 2, 3}, {4}});
- Specified by:
isDeepEqualTo
in classAbstract2DArrayAssert<Short2DArrayAssert,
short[][], Short> - Parameters:
expected
- the given value to compare the actualshort[][]
to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualshort[][]
is not deeply equal to the given one.
-
isEqualTo
Verifies that the actualshort[][]
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 withAbstractAssert.usingComparator(Comparator)
, it is advised to useisDeepEqualTo(short[][])
instead.Example:
short[][] 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 short[][] {{1, 2}, {3, 4}});
- Specified by:
isEqualTo
in interfaceAssert<Short2DArrayAssert,
short[][]> - Overrides:
isEqualTo
in classAbstractAssert<Short2DArrayAssert,
short[][]> - Parameters:
expected
- the given value to compare the actualshort[][]
to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualshort[][]
is not equal to the given one.
-
isNullOrEmpty
public void isNullOrEmpty()Verifies that the actualshort[][]
isnull
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 short[][] array = null; assertThat(array).isNullOrEmpty(); assertThat(new short[][] { }).isNullOrEmpty(); assertThat(new short[][] {{ }}).isNullOrEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new short[][] {{ }, { }, { }}).isNullOrEmpty(); // assertion will fail assertThat(new short[][] {{ 1 }, { 2 }}).isNullOrEmpty();
- Throws:
AssertionError
- if the actualshort[][]
is notnull
or not empty.
-
isEmpty
public void isEmpty()Verifies that the actualshort[][]
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:
// assertion will pass assertThat(new short[][] {{}}).isEmpty(); assertThat(new short[][] {{ }}).isNullOrEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new short[][] {{ }, { }, { }}).isNullOrEmpty(); // assertions will fail assertThat(new short[][] {{ 1 }, { 2 }}).isEmpty(); short[][] array = null; assertThat(array).isEmpty();
- Throws:
AssertionError
- if the actualshort[][]
is not empty.
-
isNotEmpty
Verifies that the actualshort[][]
is not empty, not empty means the array has at least one element.Example:
// assertions will pass assertThat(new short[][] {{ 1 }, { 2 }}).isNotEmpty(); assertThat(new short[][] {{ }, { 2 }}).isNotEmpty(); // assertions will fail assertThat(new short[][] { }).isNotEmpty(); assertThat(new short[][] {{ }}).isNotEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new short[][] {{ }, { }, { }}).isNotEmpty(); short[][] array = null; assertThat(array).isNotEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualshort[][]
is empty or null.
-
hasDimensions
Verifies that the actual 2D array has the given dimensions.Example:
// assertion will pass assertThat(new short[][] {{1, 2, 3}, {4, 5, 6}}).hasDimensions(2, 3); // assertions will fail assertThat(new short[][] { }).hasSize(1, 1); assertThat(new short[][] {{1, 2, 3}, {4, 5, 6}}).hasDimensions(3, 2); assertThat(new short[][] {{1, 2, 3}, {4, 5, 6, 7}}).hasDimensions(2, 3);
- Parameters:
expectedFirstDimension
- the expected number of values in first dimension of the actualshort[][]
.expectedSecondDimension
- the expected number of values in second dimension of the actualshort[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualshort[][]
's dimensions are not equal to the given ones.
-
hasNumberOfRows
Verifies that the actual two-dimensional array has the given number of rows.Example:
// assertion will pass assertThat(new short[][] {{1, 2, 3}, {4, 5, 6}}).hasNumberOfRows(2); assertThat(new short[][] {{1}, {1, 2}, {1, 2, 3}}).hasNumberOfRows(3); // assertions will fail assertThat(new short[][] { }).hasNumberOfRows(1); assertThat(new short[][] {{1, 2, 3}, {4, 5, 6}}).hasNumberOfRows(3); assertThat(new short[][] {{1, 2, 3}, {4, 5, 6, 7}}).hasNumberOfRows(1);
- Parameters:
expected
- the expected number of rows of the two-dimensional array.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual number of rows are not equal to the given one.
-
hasSameDimensionsAs
Verifies that the actualshort[][]
has the same dimensions as the given array.Parameter is declared as Object to accept both Object and primitive arrays.
Example:short[][] shortArray = {{1, 2, 3}, {4, 5, 6}}; char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}}; // assertion will pass assertThat(shortArray).hasSameDimensionsAs(charArray); // assertions will fail assertThat(shortArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd'}, {'e', 'f'}}); assertThat(shortArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd', 'e'}}); assertThat(shortArray).hasSameDimensionsAs(new char[][] {{'a', 'b', 'c'}, {'d', 'e'}});
- Parameters:
array
- the array to compare dimensions with actualshort[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualshort[][]
isnull
.AssertionError
- if the array parameter isnull
or is not a true array.AssertionError
- if actualshort[][]
and given array don't have the same dimensions.
-
contains
Verifies that the actualshort[][]
contains the given short[] at the given index.Example:
// assertion will pass assertThat(new short[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new short[] {3, 4}, atIndex(1)); // assertions will fail assertThat(new short[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new short[] {3, 4}, atIndex(0)); assertThat(new short[][] {{1, 2}, {3, 4}, {5, 6}}).contains(new short[] {7, 8}, atIndex(2));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualshort[][]
.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualshort[][]
isnull
or empty.NullPointerException
- if the givenIndex
isnull
.IndexOutOfBoundsException
- if the value of the givenIndex
is equal to or greater than the size of the actualshort[][]
.AssertionError
- if the actualshort[][]
does not contain the given value at the given index.
-
contains
Verifies that the actualshort[][]
contains the given short[] at the given index.Example:
// assertions will pass assertThat(new short[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new short[] {3, 4}, atIndex(0)); assertThat(new short[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new short[] {7, 8}, atIndex(2)); // assertion will fail assertThat(new short[][] {{1, 2}, {3, 4}, {5, 6}}).doesNotContain(new short[] {3, 4}, atIndex(1));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualshort[][]
.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualshort[][]
isnull
or empty.NullPointerException
- if the givenIndex
isnull
.IndexOutOfBoundsException
- if the value of the givenIndex
is equal to or greater than the size of the actualshort[][]
.AssertionError
- if the actualshort[][]
does not contain the given value at the given index.
-
doesNotContain
Verifies that the actualshort[][]
does not contain the given short[] at the given index.Example:
// assertions will pass assertThat(new short[] { 1, 2, 3 }).doesNotContain((short) 1, atIndex(1)); assertThat(new short[] { 1, 2, 3 }).doesNotContain((short) 2, atIndex(0)); // assertions will fail assertThat(new short[] { 1, 2, 3 }).doesNotContain((short) 1, atIndex(0)); assertThat(new short[] { 1, 2, 3 }).doesNotContain((short) 2, atIndex(1));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualshort[][]
.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualshort[][]
isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actualshort[][]
contains the given value at the given index.
-
doesNotContain
Verifies that the actualshort[][]
does not contain the given short[] at the given index.Example:
// assertions will pass assertThat(new short[] { 1, 2, 3 }).doesNotContain(1, atIndex(1)); assertThat(new short[] { 1, 2, 3 }).doesNotContain(2, atIndex(0)); // assertions will fail assertThat(new short[] { 1, 2, 3 }).doesNotContain(1, atIndex(0)); assertThat(new short[] { 1, 2, 3 }).doesNotContain(2, atIndex(1));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualshort[][]
.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualshort[][]
isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actualshort[][]
contains the given value at the given index.
-