Package org.assertj.core.api
Class Float2DArrayAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.Abstract2DArrayAssert<Float2DArrayAssert,float[][],Float>
-
- org.assertj.core.api.Float2DArrayAssert
-
- All Implemented Interfaces:
Array2DAssert<Float2DArrayAssert,Float>
,Assert<Float2DArrayAssert,float[][]>
,Descriptable<Float2DArrayAssert>
,ExtensionPoints<Float2DArrayAssert,float[][]>
public class Float2DArrayAssert extends Abstract2DArrayAssert<Float2DArrayAssert,float[][],Float>
Reusable assertions for two-dimensional arrays offloat
s.- Since:
- 3.17.0
- Author:
- Maciej Wajcht
-
-
Field Summary
Fields Modifier and Type Field Description private Failures
failures
protected Float2DArrays
float2dArrays
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, info, myself, objects, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description Float2DArrayAssert(float[][] actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Float2DArrayAssert
contains(float[] value, Index index)
Verifies that the actual array contains the given float[] at the given index.Float2DArrayAssert
doesNotContain(float[] value, Index index)
Verifies that the actual array does not contain the given float[] at the given index.Float2DArrayAssert
hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actualfloat[][]
has the given dimensions.Float2DArrayAssert
hasSameDimensionsAs(Object array)
Verifies that the actualfloat[][]
has the same dimensions as the given array.Float2DArrayAssert
isDeepEqualTo(float[][] expected)
Verifies that the actualfloat[][]
is deeply equal to the given one.void
isEmpty()
Verifies that the actualfloat[][]
is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.Float2DArrayAssert
isEqualTo(Object expected)
Verifies that the actualfloat[][]
is equal to the given one.Float2DArrayAssert
isNotEmpty()
Verifies that the actualfloat[][]
is not empty, not empty means the array has at least one element.void
isNullOrEmpty()
Verifies that the actualfloat[][]
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
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, extracting, extracting, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, inBinary, inHexadecimal, is, 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, satisfiesAnyOf, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, 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, describedAs
-
-
-
-
Field Detail
-
float2dArrays
protected Float2DArrays float2dArrays
-
failures
private final Failures failures
-
-
Method Detail
-
isDeepEqualTo
public Float2DArrayAssert isDeepEqualTo(float[][] expected)
Verifies that the actualfloat[][]
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}});
- Specified by:
isDeepEqualTo
in classAbstract2DArrayAssert<Float2DArrayAssert,float[][],Float>
- Parameters:
expected
- the given value to compare the actual value to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual value is not deeply equal to the given one.
-
isEqualTo
public Float2DArrayAssert isEqualTo(Object expected)
Verifies that the actualfloat[][]
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(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}});
- Specified by:
isEqualTo
in interfaceAssert<Float2DArrayAssert,float[][]>
- Overrides:
isEqualTo
in classAbstractAssert<Float2DArrayAssert,float[][]>
- Parameters:
expected
- the given value to compare the actualfloat[][]
to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualfloat[][]
is not equal to the given one.
-
isNullOrEmpty
public void isNullOrEmpty()
Verifies that the actualfloat[][]
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 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();
- Throws:
AssertionError
- if the actualfloat[][]
is notnull
or not empty.
-
isEmpty
public void isEmpty()
Verifies that the actualfloat[][]
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();
- Throws:
AssertionError
- if the actualfloat[][]
is not empty.
-
isNotEmpty
public Float2DArrayAssert isNotEmpty()
Verifies that the actualfloat[][]
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:
this
assertion object.- Throws:
AssertionError
- if the actualfloat[][]
is empty or null.
-
hasDimensions
public Float2DArrayAssert hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actualfloat[][]
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
- the expected number of values in first dimension of the actualfloat[][]
.expectedSecondDimension
- the expected number of values in second dimension of the actualfloat[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualfloat[][]
's dimensions are not equal to the given ones.
-
hasSameDimensionsAs
public Float2DArrayAssert hasSameDimensionsAs(Object array)
Verifies that the actualfloat[][]
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
- the array to compare dimensions with actualfloat[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualfloat[][]
isnull
.AssertionError
- if the array parameter isnull
or is not a true array.AssertionError
- if actualfloat[][]
and given array don't have the same dimensions.
-
contains
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
- the value to look for.index
- the index where the value should be stored in the actual array.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array 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 actual array.AssertionError
- if the actual array does not contain the given value at the given index.
-
doesNotContain
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
- the value to look for.index
- the index where the value should be stored in the actual array.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actual array contains the given value at the given index.
-
-