Package org.assertj.core.api
Class Boolean2DArrayAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.Abstract2DArrayAssert<Boolean2DArrayAssert,boolean[][],Boolean>
-
- org.assertj.core.api.Boolean2DArrayAssert
-
- All Implemented Interfaces:
Array2DAssert<Boolean2DArrayAssert,Boolean>
,Assert<Boolean2DArrayAssert,boolean[][]>
,Descriptable<Boolean2DArrayAssert>
,ExtensionPoints<Boolean2DArrayAssert,boolean[][]>
public class Boolean2DArrayAssert extends Abstract2DArrayAssert<Boolean2DArrayAssert,boolean[][],Boolean>
Assertion methods for two-dimensional arrays ofboolean
s.To create an instance of this class, invoke
.Assertions.assertThat(boolean[][])
- Since:
- 3.17.0
- Author:
- Maciej Wajcht
-
-
Field Summary
Fields Modifier and Type Field Description protected org.assertj.core.internal.Boolean2DArrays
boolean2dArrays
private org.assertj.core.internal.Failures
failures
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Constructor Description Boolean2DArrayAssert(boolean[][] actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Boolean2DArrayAssert
contains(boolean[] value, Index index)
Verifies that the actualboolean[][]
contains the given boolean[] at the given index.Boolean2DArrayAssert
doesNotContain(boolean[] value, Index index)
Verifies that the actualboolean[][]
does not contain the given boolean[] at the given index.Boolean2DArrayAssert
hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actual 2D array has the given dimensions.Boolean2DArrayAssert
hasSameDimensionsAs(Object array)
Verifies that the actualboolean[][]
has the same dimensions as the given array.Boolean2DArrayAssert
isDeepEqualTo(boolean[][] expected)
Verifies that the actualboolean[][]
is deeply equal to the given one.void
isEmpty()
Verifies that the actualboolean[][]
is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.Boolean2DArrayAssert
isEqualTo(Object expected)
Verifies that the actualboolean[][]
is equal to the given one.Boolean2DArrayAssert
isNotEmpty()
Verifies that the actualboolean[][]
is not empty, not empty means the array has at least one element.void
isNullOrEmpty()
Verifies that the actualboolean[][]
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, 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, 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 Boolean2DArrayAssert isDeepEqualTo(boolean[][] expected)
Verifies that the actualboolean[][]
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 boolean[][] {{true, false}, {false, true}}).isDeepEqualTo(new boolean[][] {{true, false}, {false, true}}); // assertions will fail assertThat(new boolean[][] {{true, false}, {false, true}}).isDeepEqualTo(new boolean[][] {{true, false}, {true, true}}); assertThat(new boolean[][] {{true, false}, {false, true}}).isDeepEqualTo(new boolean[][] {{true}, {false, false, true}});
- Specified by:
isDeepEqualTo
in classAbstract2DArrayAssert<Boolean2DArrayAssert,boolean[][],Boolean>
- 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 Boolean2DArrayAssert isEqualTo(Object expected)
Verifies that the actualboolean[][]
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(boolean[][])
instead.Example:
boolean[][] array = {{true, true}, {false, false}}; // assertion will pass assertThat(array).isEqualTo(array); // assertion will fail as isEqualTo calls equals which compares arrays references only. assertThat(array).isEqualTo(new boolean[][] {{true, true}, {false, false}});
- Specified by:
isEqualTo
in interfaceAssert<Boolean2DArrayAssert,boolean[][]>
- Overrides:
isEqualTo
in classAbstractAssert<Boolean2DArrayAssert,boolean[][]>
- Parameters:
expected
- the given value to compare the actualboolean[][]
to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualboolean[][]
is not equal to the given one.
-
isNullOrEmpty
public void isNullOrEmpty()
Verifies that the actualboolean[][]
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 boolean[][] array = null; assertThat(array).isNullOrEmpty(); assertThat(new boolean[][] { }).isNullOrEmpty(); assertThat(new boolean[][] {{ }}).isNullOrEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new boolean[][] {{ }, { }, { }}).isNullOrEmpty(); // assertion will fail assertThat(new String[][] {{"a"}, {"b"}}).isNullOrEmpty();
- Throws:
AssertionError
- if the actualboolean[][]
is notnull
or not empty.
-
isEmpty
public void isEmpty()
Verifies that the actualboolean[][]
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 boolean[][] {{ }}).isEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new boolean[][] {{ }, { }, { }}).isEmpty(); // assertions will fail assertThat(new boolean[][] {{ true }, { false }}).isEmpty(); boolean[][] array = null; assertThat(array).isEmpty();
- Throws:
AssertionError
- if the actualboolean[][]
is not empty.
-
isNotEmpty
public Boolean2DArrayAssert isNotEmpty()
Verifies that the actualboolean[][]
is not empty, not empty means the array has at least one element.Example:
// assertions will pass assertThat(new boolean[][] {{ true }, { false }}).isNotEmpty(); assertThat(new boolean[][] {{ }, { false }}).isNotEmpty(); // assertions will fail assertThat(new boolean[][] { }).isNotEmpty(); assertThat(new boolean[][] {{ }}).isNotEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new boolean[][] {{ }, { }, { }}).isNotEmpty(); boolean[][] array = null; assertThat(array).isNotEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualboolean[][]
is empty or null.
-
hasDimensions
public Boolean2DArrayAssert hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actual 2D array has the given dimensions.Example:
// assertion will pass assertThat(new boolean[][] {{true, true, true}, {false, false, false}}).hasDimensions(2, 3); // assertions will fail assertThat(new boolean[][] { }).hasSize(1, 1); assertThat(new boolean[][] {{true, true, true}, {false, false, false}}).hasDimensions(3, 2); assertThat(new boolean[][] {{true, true, true}, {false, false, false, false}}).hasDimensions(2, 3);
- Parameters:
expectedFirstDimension
- the expected number of values in first dimension of the actual array.expectedSecondDimension
- the expected number of values in second dimension of the actual array.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array's dimensions are not equal to the given ones.
-
hasSameDimensionsAs
public Boolean2DArrayAssert hasSameDimensionsAs(Object array)
Verifies that the actualboolean[][]
has the same dimensions as the given array.Parameter is declared as Object to accept both Object and primitive arrays.
Example:boolean[][] booleanArray = {{true, true, false}, {false, false, true}}; char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}}; // assertion will pass assertThat(booleanArray).hasSameDimensionsAs(charArray); // assertions will fail assertThat(booleanArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd'}, {'e', 'f'}}); assertThat(booleanArray).hasSameDimensionsAs(new char[][] {{'a', 'b'}, {'c', 'd', 'e'}}); assertThat(booleanArray).hasSameDimensionsAs(new char[][] {{'a', 'b', 'c'}, {'d', 'e'}});
- Parameters:
array
- the array to compare dimensions with actualboolean[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualboolean[][]
isnull
.AssertionError
- if the array parameter isnull
or is not a true array.AssertionError
- if actualboolean[][]
and given array don't have the same dimensions.
-
contains
public Boolean2DArrayAssert contains(boolean[] value, Index index)
Verifies that the actualboolean[][]
contains the given boolean[] at the given index.Example:
// assertion will pass assertThat(new boolean[][] {{true, false}, {false, true}}).contains(new boolean[] {true, false}, info); // assertion will fail assertThat(new boolean[][] {{true, false}, {false, true}}).contains(new boolean[] {true, false}, atIndex(1));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual array.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualboolean[][]
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 actualboolean[][]
does not contain the given value at the given index.
-
doesNotContain
public Boolean2DArrayAssert doesNotContain(boolean[] value, Index index)
Verifies that the actualboolean[][]
does not contain the given boolean[] at the given index.Example:
// assertion will pass assertThat(new boolean[][] {{true, false}, {false, true}}).doesNotContain(new boolean[] {true, false}, atIndex(1)); // assertion will fail assertThat(new boolean[][] {{true, false}, {false, true}}).doesNotContain(new boolean[] {true, false}, atIndex(0));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual array.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualboolean[][]
isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actualboolean[][]
contains the given value at the given index.
-
-