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

public Class Float2DArrayAssert

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

Reusable assertions for two-dimensional arrays of floats.
Author
Maciej Wajcht
Since
3.17.0

Field Summary

Modifier and TypeField and Description
private final Failures
protected Float2DArrays

Constructor Summary

AccessConstructor and Description
public
Float2DArrayAssert(float[][] actual)

Method Summary

Modifier and TypeMethod and Description
public Float2DArrayAssert

Returns:

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

Verifies that the actual array contains the given float[] at the given index.

public Float2DArrayAssert

Returns:

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

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

public Float2DArrayAssert

Returns:

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

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

Verifies that the actual float[][] has the given dimensions.
public Float2DArrayAssert

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 Float2DArrayAssert

Returns:

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

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

Verifies that the actual float[][] has the same dimensions as the given array.
public Float2DArrayAssert

Returns:

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

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

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

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

Verifies that the actual float[][] 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 Float2DArrayAssert

Returns:

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

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

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

Verifies that the actual float[][] is equal to the given one.
public Float2DArrayAssert

Returns:

this assertion object.
isNotEmpty
()

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

Verifies that the actual float[][] 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 float[][] 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.

Field Detail

failuresback to summary
private final Failures failures
float2dArraysback to summary
protected Float2DArrays float2dArrays
Annotations
@VisibleForTesting

Constructor Detail

Float2DArrayAssertback to summary
public Float2DArrayAssert(float[][] actual)

Method Detail

containsback to summary
public Float2DArrayAssert contains(float[] value, Index index)

Verifies that the actual array contains the given float[] at the given index.

Example:

 float[][] values = new float[][] {{1.0f, 2.0f}, {3.0f, 4.0f}, {5.0f, 6.0f}};

// assertion will pass
assertThat(values).contains(new float[] {1.0f, 2.0f}, atIndex(O))
                  .contains(new float[] {5.0f, 6.0f}, atIndex(2));

// assertions will fail
assertThat(values).contains(new float[] {1.0f, 2.0f}, atIndex(1));
assertThat(values).contains(new float[] {7.0f, 8.0f}, atIndex(2));
Parameters
value:float[]

the value to look for.

index:Index

the index where the value should be stored in the actual array.

Returns:Float2DArrayAssert

this assertion object.

Exceptions
AssertionError:
  • if the actual array is null or empty.
  • if the actual array 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 array.
doesNotContainback to summary
public Float2DArrayAssert doesNotContain(float[] value, Index index)

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

Example:

 float[][] values = new float[][] {{1.0f, 2.0f}, {3.0f, 4.0f}, {5.0f, 6.0f}};

// assertion will pass
assertThat(values).doesNotContain(new float[] {1.0f, 2.0f}, atIndex(1))
                  .doesNotContain(new float[] {3.0f, 4.0f}, atIndex(0));

// assertion will fail
assertThat(values).doesNotContain(new float[] {1.0f, 2.0f}, atIndex(0));
Parameters
value:float[]

the value to look for.

index:Index

the index where the value should be stored in the actual array.

Returns:Float2DArrayAssert

this assertion object.

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

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

Verifies that the actual float[][] has the given dimensions.

Example:

 // assertion will pass
assertThat(new float[][] {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f}}).hasDimensions(2, 3);

// assertions will fail
assertThat(new float[][] { }).hasSize(1, 1);
assertThat(new float[][] {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f}}).hasDimensions(3, 2);
assertThat(new float[][] {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f, 7.0f}}).hasDimensions(2, 3); 
Parameters
expectedFirstDimension:int

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

expectedSecondDimension:int

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

Returns:Float2DArrayAssert

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the actual float[][]'s dimensions are not equal to the given ones.
hasNumberOfRowsback to summary
public Float2DArrayAssert 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 float[][] {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f}}).hasNumberOfRows(2);
assertThat(new float[][] {{1.0f}, {1.0f, 2.0f}, {1.0f, 2.0f, 3.0f}}).hasNumberOfRows(3);

// assertions will fail
assertThat(new float[][] { }).hasNumberOfRows(1);
assertThat(new float[][] {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f}}).hasNumberOfRows(3);
assertThat(new float[][] {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f, 7.0f}}).hasNumberOfRows(1); 
Parameters
expected:int

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

Returns:Float2DArrayAssert

this assertion object.

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

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

Verifies that the actual float[][] has the same dimensions as the given array.

Parameter is declared as Object to accept both Object and primitive arrays.

Example:
 float[][] floatArray = {{1.0f, 2.0f, 3.0f}, {4.0f, 5.0f, 6.0f}};
char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};

// assertion will pass
assertThat(floatArray).hasSameDimensionsAs(charArray);

// assertions will fail
assertThat(floatArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd'}, {'e', 'f'}});
assertThat(floatArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd', 'e'}});
assertThat(floatArray).hasSameDimensionsAs(new char[][] {{'a', 'b', 'c'}, {'d', 'e'}});
Parameters
array:Object

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

Returns:Float2DArrayAssert

this assertion object.

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

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

Verifies that the actual float[][] 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 float[][] {{1.0f, 2.0f}, {3.0f, 4.0f}}).isDeepEqualTo(new float[][] {{1.0f, 2.0f}, {3.0f, 4.0f}});

// assertions will fail
assertThat(new float[][] {{1.0f, 2.0f}, {3.0f, 4.0f}}).isDeepEqualTo(new float[][] {{1.0f, 2.0f}, {9.0f, 10.0f}});
assertThat(new float[][] {{1.0f, 2.0f}, {3.0f, 4.0f}}).isDeepEqualTo(new float[][] {{1.0f, 2.0f, 3.0f}, {4.0f}});
Parameters
expected:float[][]

the given value to compare the actual value to.

Returns:Float2DArrayAssert

this assertion object.

Annotations
@Override
Exceptions
AssertionError:
if the actual value 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 float[][] 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 float[][] {{}}).isEmpty();
// this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
assertThat(new float[][] {{ }, { }, { }}).isEmpty();

// assertions will fail
assertThat(new float[][] {{ 1.0 }, { 2.0 }}).isEmpty();
float[][] array = null;
assertThat(array).isEmpty();
Annotations
@Override
Exceptions
AssertionError:
if the actual float[][] is not empty.
isEqualToback to summary
public Float2DArrayAssert isEqualTo(Object expected)

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

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

Verifies that the actual float[][] 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(float[][]) instead.

Example:

 float[][] array = {{1.0f, 2.0f}, {3.0f, 4.0f}};

// assertion will pass
assertThat(array).isEqualTo(array);

// assertion will fail as isEqualTo calls equals which compares arrays references only.
assertThat(array).isEqualTo(new float[][] {{1.0f, 2.0f}, {3.0f, 4.0f}});
Parameters
expected:Object

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

Returns:Float2DArrayAssert

this assertion object.

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

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

Verifies that the actual float[][] is not empty, not empty means the array has at least one element.

Example:

 // assertions will pass
assertThat(new float[][] {{ 1.0 }, { 2.0 }}).isNotEmpty();
assertThat(new float[][] {{ }, { 2.0 }}).isNotEmpty();

// assertions will fail
assertThat(new float[][] { }).isNotEmpty();
assertThat(new float[][] {{ }}).isNotEmpty();
// this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
assertThat(new float[][] {{ }, { }, { }}).isNotEmpty();
float[][] array = null;
assertThat(array).isNotEmpty();
Returns:Float2DArrayAssert

this assertion object.

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

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

Verifies that the actual float[][] 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
float[][] array = null;
assertThat(array).isNullOrEmpty();
assertThat(new float[][] { }).isNullOrEmpty();
assertThat(new float[][] {{ }}).isNullOrEmpty();
// this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows.
assertThat(new float[][] {{ }, { }, { }}).isNullOrEmpty();

// assertion will fail
assertThat(new float[][] {{ 1.0 }, { 2.0 }}).isNullOrEmpty();
Annotations
@Override
Exceptions
AssertionError:
if the actual float[][] is not null or not empty.