Top Description Fields Constructors Methods
org.assertj.core.api

public Class Short2DArrayAssert

extends Abstract2DArrayAssert<Short2DArrayAssert, short[][], Short>
Class Inheritance
Static Imports
org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs, .ShouldNotBeNull.shouldNotBeNull, .SubarraysShouldHaveSameSize.subarraysShouldHaveSameSize, org.assertj.core.error.array2d.Array2dElementShouldBeDeepEqual.elementShouldBeEqual

Assertion methods for arrays of shorts.

To create an instance of this class, invoke Assertions#assertThat(short[][]).

Author
Maciej Wajcht
Since
3.17.0

Field Summary

Modifier and TypeField and Description
private final Failures
protected Short2DArrays

Constructor Summary

AccessConstructor and Description
public
Short2DArrayAssert(short[][] actual)

Method Summary

Modifier and TypeMethod and Description
public Short2DArrayAssert

Returns:

myself assertion object.
contains
(short[]
the value to look for.
value
,
Index
the index where the value should be stored in the actual short[][].
index
)

Verifies that the actual short[][] contains the given short[] at the given index.

public Short2DArrayAssert

Returns:

myself assertion object.
contains
(int[]
the value to look for.
value
,
Index
the index where the value should be stored in the actual short[][].
index
)

Verifies that the actual short[][] contains the given short[] at the given index.

public Short2DArrayAssert

Returns:

myself assertion object.
doesNotContain
(short[]
the value to look for.
value
,
Index
the index where the value should be stored in the actual short[][].
index
)

Verifies that the actual short[][] does not contain the given short[] at the given index.

public Short2DArrayAssert

Returns:

myself assertion object.
doesNotContain
(int[]
the value to look for.
value
,
Index
the index where the value should be stored in the actual short[][].
index
)

Verifies that the actual short[][] does not contain the given short[] at the given index.

public Short2DArrayAssert

Returns:

this assertion object.
hasDimensions
(int
the expected number of values in first dimension of the actual short[][].
expectedFirstDimension
,
int
the expected number of values in second dimension of the actual short[][].
expectedSecondDimension
)

Implements org.assertj.core.api.Array2DAssert.hasDimensions.

Verifies that the actual 2D array has the given dimensions.
public Short2DArrayAssert

Returns:

this assertion object.
hasNumberOfRows
(int
the expected number of rows of the two-dimensional array.
expected
)

Implements org.assertj.core.api.Array2DAssert.hasNumberOfRows.

Verifies that the actual two-dimensional array has the given number of rows.
public Short2DArrayAssert

Returns:

this assertion object.
hasSameDimensionsAs
(Object
the array to compare dimensions with actual short[][].
array
)

Implements org.assertj.core.api.Array2DAssert.hasSameDimensionsAs.

Verifies that the actual short[][] has the same dimensions as the given array.
public Short2DArrayAssert

Returns:

this assertion object.
isDeepEqualTo
(short[][]
the given value to compare the actual short[][] to.
expected
)

Implements abstract org.assertj.core.api.Abstract2DArrayAssert.isDeepEqualTo.

Verifies that the actual short[][] is deeply equal to the given one.
public void
isEmpty()

Implements org.assertj.core.api.Array2DAssert.isEmpty.

Verifies that the actual short[][] is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.
public Short2DArrayAssert

Returns:

this assertion object.
isEqualTo
(Object
the given value to compare the actual short[][] to.
expected
)

Overrides org.assertj.core.api.AbstractAssert.isEqualTo.

Implements org.assertj.core.api.Assert.isEqualTo.

Verifies that the actual short[][] is equal to the given one.
public Short2DArrayAssert

Returns:

this assertion object.
isNotEmpty
()

Implements org.assertj.core.api.Array2DAssert.isNotEmpty.

Verifies that the actual short[][] is not empty, not empty means the array has at least one element.
public void
isNullOrEmpty()

Implements org.assertj.core.api.Array2DAssert.isNullOrEmpty.

Verifies that the actual short[][] 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.
private static short[]
toShort(int[] value)

Field Detail

failuresback to summary
private final Failures failures
short2dArraysback to summary
protected Short2DArrays short2dArrays
Annotations
@VisibleForTesting

Constructor Detail

Short2DArrayAssertback to summary
public Short2DArrayAssert(short[][] actual)

Method Detail

containsback to summary
public Short2DArrayAssert contains(short[] value, Index index)

Verifies that the actual short[][] 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:short[]

the value to look for.

index:Index

the index where the value should be stored in the actual short[][].

Returns:Short2DArrayAssert

myself assertion object.

Exceptions
AssertionError:
  • if the actual short[][] is null or empty.
  • if the actual short[][] does not contain the given value at the given index.
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 short[][].
containsback to summary
public Short2DArrayAssert contains(int[] value, Index index)

Verifies that the actual short[][] 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:int[]

the value to look for.

index:Index

the index where the value should be stored in the actual short[][].

Returns:Short2DArrayAssert

myself assertion object.

Exceptions
AssertionError:
  • if the actual short[][] is null or empty.
  • if the actual short[][] does not contain the given value at the given index.
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 short[][].
doesNotContainback to summary
public Short2DArrayAssert doesNotContain(short[] value, Index index)

Verifies that the actual short[][] 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:short[]

the value to look for.

index:Index

the index where the value should be stored in the actual short[][].

Returns:Short2DArrayAssert

myself assertion object.

Exceptions
AssertionError:
  • if the actual short[][] is null.
  • if the actual short[][] contains the given value at the given index.
NullPointerException:
if the given Index is null.
doesNotContainback to summary
public Short2DArrayAssert doesNotContain(int[] value, Index index)

Verifies that the actual short[][] 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:int[]

the value to look for.

index:Index

the index where the value should be stored in the actual short[][].

Returns:Short2DArrayAssert

myself assertion object.

Exceptions
AssertionError:
  • if the actual short[][] is null.
  • if the actual short[][] contains the given value at the given index.
NullPointerException:
if the given Index is null.
hasDimensionsback to summary
public Short2DArrayAssert hasDimensions(int expectedFirstDimension, int expectedSecondDimension)

Implements org.assertj.core.api.Array2DAssert.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:int

the expected number of values in first dimension of the actual short[][].

expectedSecondDimension:int

the expected number of values in second dimension of the actual short[][].

Returns:Short2DArrayAssert

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the actual short[][]'s dimensions are not equal to the given ones.
hasNumberOfRowsback to summary
public Short2DArrayAssert hasNumberOfRows(int expected)

Implements org.assertj.core.api.Array2DAssert.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:int

the expected number of rows of the two-dimensional array.

Returns:Short2DArrayAssert

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the actual number of rows are not equal to the given one.
hasSameDimensionsAsback to summary
public Short2DArrayAssert hasSameDimensionsAs(Object array)

Implements org.assertj.core.api.Array2DAssert.hasSameDimensionsAs.

Verifies that the actual short[][] 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:Object

the array to compare dimensions with actual short[][].

Returns:Short2DArrayAssert

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
  • if the actual short[][] is null.
  • if the array parameter is null or is not a true array.
  • if actual short[][] and given array don't have the same dimensions.
isDeepEqualToback to summary
public Short2DArrayAssert isDeepEqualTo(short[][] expected)

Implements abstract org.assertj.core.api.Abstract2DArrayAssert.isDeepEqualTo.

Verifies that the actual short[][] 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}});
Parameters
expected:short[][]

the given value to compare the actual short[][] to.

Returns:Short2DArrayAssert

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the actual short[][] is not deeply equal to the given one.
isEmptyback to summary
public void isEmpty()

Implements org.assertj.core.api.Array2DAssert.isEmpty.

Verifies that the actual short[][] 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();
Annotations
@Override
Exceptions
AssertionError:
if the actual short[][] is not empty.
isEqualToback to summary
public Short2DArrayAssert isEqualTo(Object expected)

Overrides org.assertj.core.api.AbstractAssert.isEqualTo.

Implements org.assertj.core.api.Assert.isEqualTo.

Verifies that the actual short[][] 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 usingComparator(Comparator), it is advised to use isDeepEqualTo(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}});
Parameters
expected:Object

the given value to compare the actual short[][] to.

Returns:Short2DArrayAssert

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the actual short[][] is not equal to the given one.
isNotEmptyback to summary
public Short2DArrayAssert isNotEmpty()

Implements org.assertj.core.api.Array2DAssert.isNotEmpty.

Verifies that the actual short[][] 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:Short2DArrayAssert

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the actual short[][] is empty or null.
isNullOrEmptyback to summary
public void isNullOrEmpty()

Implements org.assertj.core.api.Array2DAssert.isNullOrEmpty.

Verifies that the actual short[][] 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
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();
Annotations
@Override
Exceptions
AssertionError:
if the actual short[][] is not null or not empty.
toShortback to summary
private static short[] toShort(int[] value)