Package org.assertj.core.api
Class Char2DArrayAssert
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.Abstract2DArrayAssert<Char2DArrayAssert,char[][],Character>
-
- org.assertj.core.api.Char2DArrayAssert
-
- All Implemented Interfaces:
Array2DAssert<Char2DArrayAssert,Character>
,Assert<Char2DArrayAssert,char[][]>
,Descriptable<Char2DArrayAssert>
,ExtensionPoints<Char2DArrayAssert,char[][]>
public class Char2DArrayAssert extends Abstract2DArrayAssert<Char2DArrayAssert,char[][],Character>
Assertion methods for two-dimensional arrays ofchar
s.To create an instance of this class, invoke
.Assertions.assertThat(char[][])
- Since:
- 3.17.0
- Author:
- Maciej Wajcht
-
-
Field Summary
Fields Modifier and Type Field Description protected org.assertj.core.internal.Char2DArrays
char2dArrays
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 Char2DArrayAssert(char[][] actual)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Char2DArrayAssert
contains(char[] value, Index index)
Verifies that the actualchar[][]
contains the given char[] at the given index.Char2DArrayAssert
doesNotContain(char[] value, Index index)
Verifies that the actualchar[][]
does not contain the given char[] at the given index.Char2DArrayAssert
hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actualchar[][]
has the the given dimensions.Char2DArrayAssert
hasSameDimensionsAs(Object array)
Verifies that the actualchar[][]
has the same dimensions as the given array.Char2DArrayAssert
inUnicode()
Use unicode character representation instead of standard representation in error messages.Char2DArrayAssert
isDeepEqualTo(char[][] expected)
Verifies that the actualchar[][]
is deeply equal to the given one.void
isEmpty()
Verifies that the actualchar[][]
is empty, empty means the array has no elements, said otherwise it can have any number of rows but all rows must be empty.Char2DArrayAssert
isEqualTo(Object expected)
Verifies that the actualchar[][]
is equal to the given one.Char2DArrayAssert
isNotEmpty()
Verifies that the actualchar[][]
is not empty, not empty means the array has at least one char element.void
isNullOrEmpty()
Verifies that the actualchar[][]
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 Char2DArrayAssert isDeepEqualTo(char[][] expected)
Verifies that the actualchar[][]
is deeply equal to the given one.Two array references 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 char[][] {{'1', '2'}, {'3', '4'}}).isDeepEqualTo(new char[][] {{'1', '2'}, {'3', '4'}}); // assertions will fail assertThat(new char[][] {{'1', '2'}, {'3', '4'}}).isDeepEqualTo(new char[][] {{'1', '2'}, {'9', '0'}}); assertThat(new char[][] {{'1', '2'}, {'3', '4'}}).isDeepEqualTo(new char[][] {{'1', '2', '3'}, {'4'}});
- Specified by:
isDeepEqualTo
in classAbstract2DArrayAssert<Char2DArrayAssert,char[][],Character>
- 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 Char2DArrayAssert isEqualTo(Object expected)
Verifies that the actualchar[][]
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(char[][])
instead.Example:
char[][] array = {{'1', '2'}, {'3', '4'}} // assertion will pass assertThat(array).isEqualTo(array); // assertion will fail as isEqualTo calls equals which compares arrays references only. assertThat(array).isEqualTo(new char[][] {{'1', '2'}, {'3', '4'}});
- Specified by:
isEqualTo
in interfaceAssert<Char2DArrayAssert,char[][]>
- Overrides:
isEqualTo
in classAbstractAssert<Char2DArrayAssert,char[][]>
- Parameters:
expected
- the given value to compare the actualchar[][]
to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualchar[][]
is not equal to the given one.
-
isNullOrEmpty
public void isNullOrEmpty()
Verifies that the actualchar[][]
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 char[][] array = null; assertThat(array).isNullOrEmpty(); assertThat(new char[][] { }).isNullOrEmpty(); assertThat(new char[][] { { } }).isNullOrEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new char[][] { { }, { }, { } }).isNullOrEmpty(); // assertion will fail assertThat(new char[][] { {'a'}, {'b'} }).isNullOrEmpty();
- Throws:
AssertionError
- if the actualchar[][]
is notnull
or not empty.
-
isEmpty
public void isEmpty()
Verifies that the actualchar[][]
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 char[][] { {} }).isEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new char[][] { { }, { }, { } }).isEmpty(); // assertions will fail assertThat(new char[][] { {'a'}, {'b'} }).isEmpty(); char[][] array = null; assertThat(array).isEmpty();
- Throws:
AssertionError
- if the actualchar[][]
is not empty.
-
isNotEmpty
public Char2DArrayAssert isNotEmpty()
Verifies that the actualchar[][]
is not empty, not empty means the array has at least one char element.Example:
// assertion will pass assertThat(new char[][] { {'a'}, {'b'} }).isNotEmpty(); assertThat(new char[][] { { }, {'b'} }).isNotEmpty(); // assertions will fail assertThat(new char[][] { }).isNotEmpty(); assertThat(new char[][] { { } }).isNotEmpty(); // this is considered empty as there are no elements in the 2d array which is comprised of 3 empty rows. assertThat(new char[][] { { }, { }, { } }).isNotEmpty(); char[][] array = null; assertThat(array).isNotEmpty();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualchar[][]
is empty or null.
-
hasDimensions
public Char2DArrayAssert hasDimensions(int expectedFirstDimension, int expectedSecondDimension)
Verifies that the actualchar[][]
has the the given dimensions.Example:
// assertion will pass assertThat(new char[][] { {'1', '2', '3'}, {'4', '5', '6'} }).hasDimensions(2, 3); // assertions will fail assertThat(new char[][] { }).hasDimensions(1, 1); assertThat(new char[][] { {'1', '2', '3'}, {'4', '5', '6'} }).hasDimensions(3, 2); assertThat(new char[][] { {'1', '2', '3'}, {'4', '5', '6', '7'} }).hasDimensions(2, 3);
- Parameters:
expectedFirstDimension
- the expected number of values in first dimension of the actualchar[][]
.expectedSecondDimension
- the expected number of values in second dimension of the actualchar[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actualchar[][]
is not equal to the given one.
-
hasSameDimensionsAs
public Char2DArrayAssert hasSameDimensionsAs(Object array)
Verifies that the actualchar[][]
has the same dimensions as the given array.Parameter is declared as Object to accept both Object[] and primitive arrays (e.g. int[]).
Example:char[][] charArray = {{'a', 'b', 'c'}, {'d', 'e', 'f'}}; int[][] intArray = {{1, 2, 3}, {4, 5, 6}}; // assertion will pass assertThat(charArray).hasSameDimensionsAs(intArray); // assertions will fail assertThat(charArray).hasSameDimensionsAs(new int[][] {{1, 2}, {3, 4}, {5, 6}}); assertThat(charArray).hasSameDimensionsAs(new int[][] {{1, 2}, {3, 4, 5}}); assertThat(charArray).hasSameDimensionsAs(new int[][] {{1, 2, 3}, {4, 5}});
- Parameters:
array
- the array to compare dimensions with actualchar[][]
.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actualchar[][]
isnull
.AssertionError
- if the array parameter isnull
or is not a true array.AssertionError
- if actualchar[][]
and given array don't have the same dimensions.
-
contains
public Char2DArrayAssert contains(char[] value, Index index)
Verifies that the actualchar[][]
contains the given char[] at the given index.Example:
// assertion will pass assertThat(new char[][] {{'a', 'b'}, {'c', 'd'} }).contains(new char[] {'a', 'b'}, atIndex(0)); // assertion will fail assertThat(new char[][] {{'a', 'b'}, {'c', 'd'} }).contains(new char[] {'a', 'b'}, atIndex(1));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualchar[][]
.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualchar[][]
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 actualchar[][]
.AssertionError
- if the actualchar[][]
does not contain the given value at the given index.
-
doesNotContain
public Char2DArrayAssert doesNotContain(char[] value, Index index)
Verifies that the actualchar[][]
does not contain the given char[] at the given index.Example:
// assertion will pass assertThat(new char[][] {{'a', 'b'}, {'c', 'd'} }).doesNotContain(new char[] {'a', 'b'}, atIndex(1)); // assertion will fail assertThat(new char[][] {{'a', 'b'}, {'c', 'd'} }).doesNotContain(new char[] {'a', 'b'}, atIndex(0));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actualchar[][]
.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actualchar[][]
isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actualchar[][]
contains the given value at the given index.
-
inUnicode
public Char2DArrayAssert inUnicode()
Use unicode character representation instead of standard representation in error messages.With standard error message:
With unicode based error message:assertThat(new char[][] {{'a', 'b'}, {'ć', 'd'}}).isDeepEqualTo(new char[][] {{'a', 'b'}, {'c', 'd'}}); org.opentest4j.AssertionFailedError: Expecting "actual[1][0]" value to be equal to: <'c'> but was <'ć'>
assertThat(new char[][] {{'a', 'b'}, {'ć', 'd'}}).inUnicode().isDeepEqualTo(new char[][] {{'a', 'b'}, {'c', 'd'}}); org.opentest4j.AssertionFailedError: Expecting actual[1][0] value to be equal to: <c> but was <ć>
- Returns:
this
assertion object.
-
-