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 ofdoubles.To create an instance of this class, invoke
.Assertions.assertThat(double[][])- Since:
- 3.17.0
- Author:
- Maciej Wajcht
-
-
Field Summary
Fields Modifier and Type Field Description protected org.assertj.core.internal.Double2DArraysdouble2dArraysprivate org.assertj.core.internal.Failuresfailures-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description Double2DArrayAssert(double[][] actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Double2DArrayAssertcontains(double[] value, Index index)Verifies that the actualdouble[][]contains the given double[] at the given index.Double2DArrayAssertdoesNotContain(double[] value, Index index)Verifies that the actualdouble[][]does not contain the given double[] at the given index.Double2DArrayAsserthasDimensions(int expectedFirstDimension, int expectedSecondDimension)Verifies that the actualdouble[][]has the given dimensions.Double2DArrayAsserthasSameDimensionsAs(Object array)Verifies that the actualdouble[][]has the same dimensions as the given array.Double2DArrayAssertisDeepEqualTo(double[][] expected)Verifies that the actualdouble[][]is deeply equal to the given one.voidisEmpty()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.Double2DArrayAssertisEqualTo(Object expected)Verifies that the actualdouble[][]is equal to the given one.Double2DArrayAssertisNotEmpty()Verifies that the actualdouble[][]is not empty, not empty means the array has at least one element.voidisNullOrEmpty()Verifies that the actualdouble[][]isnullor 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, 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, 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, as, describedAs
-
-
-
-
Method Detail
-
isDeepEqualTo
public Double2DArrayAssert isDeepEqualTo(double[][] expected)
Verifies that the actualdouble[][]is deeply equal to the given one.Two arrays are considered deeply equal if both are
nullor 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:
isDeepEqualToin classAbstract2DArrayAssert<Double2DArrayAssert,double[][],Double>- Parameters:
expected- the given value to compare the actual value to.- Returns:
thisassertion object.- Throws:
AssertionError- if the actual value is not deeply equal to the given one.
-
isEqualTo
public Double2DArrayAssert isEqualTo(Object expected)
Verifies that the actualdouble[][]is equal to the given one.WARNING! This method will use
equalsto 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:
isEqualToin interfaceAssert<Double2DArrayAssert,double[][]>- Overrides:
isEqualToin classAbstractAssert<Double2DArrayAssert,double[][]>- Parameters:
expected- the given value to compare the actualdouble[][]to.- Returns:
thisassertion object.- Throws:
AssertionError- if the actualdouble[][]is not equal to the given one.
-
isNullOrEmpty
public void isNullOrEmpty()
Verifies that the actualdouble[][]isnullor 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 notnullor 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
public Double2DArrayAssert 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:
thisassertion object.- Throws:
AssertionError- if the actualdouble[][]is empty or null.
-
hasDimensions
public Double2DArrayAssert hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
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:
thisassertion object.- Throws:
AssertionError- if the actualdouble[][]'s dimensions are not equal to the given ones.
-
hasSameDimensionsAs
public Double2DArrayAssert hasSameDimensionsAs(Object array)
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:
thisassertion object.- Throws:
AssertionError- if the actualdouble[][]isnull.AssertionError- if the array parameter isnullor is not a true array.AssertionError- if actualdouble[][]and given array don't have the same dimensions.
-
contains
public Double2DArrayAssert contains(double[] value, Index index)
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:
thisassertion object.- Throws:
AssertionError- if the actualdouble[][]isnullor empty.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis 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
public Double2DArrayAssert doesNotContain(double[] value, Index index)
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:
thisassertion object.- Throws:
AssertionError- if the actualdouble[][]isnull.NullPointerException- if the givenIndexisnull.AssertionError- if the actualdouble[][]contains the given value at the given index.
-
-