Package org.assertj.core.api
Class Double2DArrayAssert
java.lang.Object
org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
org.assertj.core.api.Abstract2DArrayAssert<Double2DArrayAssert,double[][],Double>
org.assertj.core.api.Double2DArrayAssert
- All Implemented Interfaces:
Array2DAssert<Double2DArrayAssert,
,Double> Assert<Double2DArrayAssert,
,double[][]> Descriptable<Double2DArrayAssert>
,ExtensionPoints<Double2DArrayAssert,
double[][]>
public class Double2DArrayAssert
extends Abstract2DArrayAssert<Double2DArrayAssert,double[][],Double>
Assertion methods for two-dimensional arrays of
double
s.
To create an instance of this class, invoke
.
Assertions.assertThat(double[][])
- Since:
- 3.17.0
- Author:
- Maciej Wajcht
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.assertj.core.internal.Double2DArrays
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, info, myself, objects, throwUnsupportedExceptionOnEquals
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionVerifies that the actualdouble[][]
contains the given double[] at the given index.doesNotContain
(double[] value, Index index) Verifies that the actualdouble[][]
does not contain the given double[] at the given index.hasDimensions
(int expectedFirstDimension, int expectedSecondDimension) Verifies that the actualdouble[][]
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 actualdouble[][]
has the same dimensions as the given array.isDeepEqualTo
(double[][] expected) Verifies that the actualdouble[][]
is deeply equal to the given one.void
isEmpty()
Verifies that the actualdouble[][]
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 actualdouble[][]
is equal to the given one.Verifies that the actualdouble[][]
is not empty, not empty means the array has at least one element.void
Verifies that the actualdouble[][]
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, 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, 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
-
Field Details
-
double2dArrays
protected org.assertj.core.internal.Double2DArrays double2dArrays
-
-
Constructor Details
-
Double2DArrayAssert
public Double2DArrayAssert(double[][] actual)
-
-
Method Details
-
isDeepEqualTo
Verifies that the actualdouble[][]
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 double[][] {{1.0, 2.0}, {3.0, 4.0}}).isDeepEqualTo(new double[][] {{1.0, 2.0}, {3.0, 4.0}}); // assertions will fail assertThat(new double[][] {{1.0, 2.0}, {3.0, 4.0}}).isDeepEqualTo(new double[][] {{1.0, 2.0}, {9.0, 10.0}}); assertThat(new double[][] {{1.0, 2.0}, {3.0, 4.0}}).isDeepEqualTo(new double[][] {{1.0, 2.0, 3.0}, {4.0}});
- Specified by:
isDeepEqualTo
in classAbstract2DArrayAssert<Double2DArrayAssert,
double[][], Double> - 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
Verifies that the actualdouble[][]
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(double[][])
instead.Example:
double[][] array = {{1.0, 2.0}, {3.0, 4.0}}; // assertion will pass assertThat(array).isEqualTo(array); // assertion will fail as isEqualTo calls equals which compares arrays references only. assertThat(array).isEqualTo(new double[][] {{1.0, 2.0}, {3.0, 4.0}});
- Specified by:
isEqualTo
in interfaceAssert<Double2DArrayAssert,
double[][]> - Overrides:
isEqualTo
in classAbstractAssert<Double2DArrayAssert,
double[][]> - Parameters:
expected
- the given value to compare the actualdouble[][]
to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualdouble[][]
is not equal to the given one.
-
isNullOrEmpty
public void isNullOrEmpty()Verifies that the actualdouble[][]
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 double[][] array = null; assertThat(array).isNullOrEmpty(); assertThat(new double[][] { }).isNullOrEmpty(); assertThat(new double[][] {{ }}).isNullOrEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new double[][] {{ }, { }, { }}).isNullOrEmpty(); // assertion will fail assertThat(new double[][] {{ 1.0 }, { 2.0 }}).isNullOrEmpty();
- Throws:
AssertionError
- if the actualdouble[][]
is notnull
or not empty.
-
isEmpty
public void isEmpty()Verifies that the actualdouble[][]
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 double[][] {{}}).isEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new double[][] {{ }, { }, { }}).isEmpty(); // assertions will fail assertThat(new double[][] {{ 1.0 }, { 2.0 }}).isEmpty(); double[][] array = null; assertThat(array).isEmpty();
- Throws:
AssertionError
- if the actualdouble[][]
is not empty.
-
isNotEmpty
Verifies that the actualdouble[][]
is not empty, not empty means the array has at least one element.Example:
// assertions will pass assertThat(new double[][] {{ 1.0 }, { 2.0 }}).isNotEmpty(); assertThat(new double[][] {{ }, { 2.0 }}).isNotEmpty(); // assertions will fail assertThat(new double[][] { }).isNotEmpty(); assertThat(new double[][] {{ }}).isNotEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new double[][] {{ }, { }, { }}).isNotEmpty(); double[][] array = null; assertThat(array).isNotEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualdouble[][]
is empty or null.
-
hasDimensions
Verifies that the actualdouble[][]
has the given dimensions.Example:
// assertion will pass assertThat(new double[][] {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}}).hasDimensions(2, 3); // assertions will fail assertThat(new double[][] { }).hasSize(1, 1); assertThat(new double[][] {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}}).hasDimensions(3, 2); assertThat(new double[][] {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0, 7.0}}).hasDimensions(2, 3);
- Parameters:
expectedFirstDimension
- the expected number of values in first dimension of the actualdouble[][]
.expectedSecondDimension
- the expected number of values in second dimension of the actualdouble[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualdouble[][]
'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 double[][] {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}}).hasNumberOfRows(2); assertThat(new double[][] {{1.0}, {1.0, 2.0}, {1.0, 2.0, 3.0}}).hasNumberOfRows(3); // assertions will fail assertThat(new double[][] { }).hasNumberOfRows(1); assertThat(new double[][] {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}}).hasNumberOfRows(3); assertThat(new double[][] {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0, 7.0}}).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 actualdouble[][]
has the same dimensions as the given array.Parameter is declared as Object to accept both Object and primitive arrays.
Example:double[][] doubleArray = {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}}; char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}}; // assertion will pass assertThat(doubleArray).hasSameDimensionsAs(charArray); // assertions will fail assertThat(doubleArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd'}, {'e', 'f'}}); assertThat(doubleArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd', 'e'}}); assertThat(doubleArray).hasSameDimensionsAs(new char[][] {{'a', 'b', 'c'}, {'d', 'e'}});
- Parameters:
array
- the array to compare dimensions with actualdouble[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualdouble[][]
isnull
.AssertionError
- if the array parameter isnull
or is not a true array.AssertionError
- if actualdouble[][]
and given array don't have the same dimensions.
-
contains
Verifies that the actualdouble[][]
contains the given double[] at the given index.Example:
double[][] values = new double[][] {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}}; // assertion will pass assertThat(values).contains(new double[] {1.0, 2.0}, atIndex(0)) .contains(new double[] {5.0, 6.0}, atIndex(2)); // assertions will fail assertThat(values).contains(new double[] {1.0, 2.0}, atIndex(1)); assertThat(values).contains(new double[] {6.0, 10.0}, atIndex(2));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualdouble[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualdouble[][]
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 actualdouble[][]
.AssertionError
- if the actualdouble[][]
does not contain the given value at the given index.
-
doesNotContain
Verifies that the actualdouble[][]
does not contain the given double[] at the given index.Example:
double[][] values = new double[][] {{1.0, 2.0}, {3.0, 4.0}, {5.0, 6.0}}; // assertion will pass assertThat(values).doesNotContain(new double[] {1.0, 2.0}, atIndex(1)) .doesNotContain(new double[] {3.0, 4.0}, atIndex(0)); // assertion will fail assertThat(values).doesNotContain(new double[] {1.0, 2.0}, atIndex(0));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualdouble[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualdouble[][]
isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actualdouble[][]
contains the given value at the given index.
-