public class CharArrayAssert extends AbstractAssert<CharArrayAssert,char[]> implements EnumerableAssert<CharArrayAssert,Character>, ArraySortedAssert<CharArrayAssert,Character>
char
s.
To create an instance of this class, invoke
.
Assertions.assertThat(char[])
actual, info, myself
Modifier | Constructor and Description |
---|---|
protected |
CharArrayAssert(char[] actual) |
Modifier and Type | Method and Description |
---|---|
CharArrayAssert |
contains(char... values)
Verifies that the actual array contains the given values, in any order.
|
CharArrayAssert |
contains(char value,
Index index)
Verifies that the actual array contains the given value at the given index.
|
CharArrayAssert |
containsOnly(char... values)
Verifies that the actual array contains only the given values and nothing else, in any order.
|
CharArrayAssert |
containsSequence(char... sequence)
Verifies that the actual array contains the given sequence, without any other values between them.
|
CharArrayAssert |
doesNotContain(char... values)
Verifies that the actual array does not contain the given values.
|
CharArrayAssert |
doesNotContain(char value,
Index index)
Verifies that the actual array does not contain the given value at the given index.
|
CharArrayAssert |
doesNotHaveDuplicates()
Verifies that the actual array does not contain duplicates.
|
CharArrayAssert |
endsWith(char... sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them.
|
CharArrayAssert |
hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as given
Iterable . |
CharArrayAssert |
hasSameSizeAs(Object[] other)
Verifies that the actual group has the same size as given array.
|
CharArrayAssert |
hasSize(int expected)
Verifies that the number of values in the actual group is equal to the given one.
|
void |
isEmpty()
Verifies that the actual group of values is empty.
|
CharArrayAssert |
isNotEmpty()
Verifies that the actual group of values is not empty.
|
void |
isNullOrEmpty()
Verifies that the actual group of values is
null or empty. |
CharArrayAssert |
isSorted()
Verifies that the actual array is sorted into ascending order according to the natural ordering of its elements.
|
CharArrayAssert |
isSortedAccordingTo(Comparator<? super Character> comparator)
Verifies that the actual array is sorted according to the given comparator. Empty arrays are considered sorted whatever
the comparator is. One element arrays are considered sorted if element is compatible with comparator, otherwise an
AssertionError is thrown.
|
CharArrayAssert |
startsWith(char... sequence)
Verifies that the actual array starts with the given sequence of values, without any other values between them.
|
CharArrayAssert |
usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks.
|
CharArrayAssert |
usingElementComparator(Comparator<? super Character> customComparator)
Use given custom comparator instead of relying on actual type A
equals method to compare group elements for
incoming assertion checks. |
as, as, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, overridingErrorMessage, usingComparator, usingDefaultComparator
public void isNullOrEmpty()
null
or empty.isNullOrEmpty
in interface EnumerableAssert<CharArrayAssert,Character>
public void isEmpty()
isEmpty
in interface EnumerableAssert<CharArrayAssert,Character>
public CharArrayAssert isNotEmpty()
isNotEmpty
in interface EnumerableAssert<CharArrayAssert,Character>
this
assertion object.public CharArrayAssert hasSize(int expected)
hasSize
in interface EnumerableAssert<CharArrayAssert,Character>
expected
- the expected number of values in the actual group.this
assertion object.public CharArrayAssert hasSameSizeAs(Object[] other)
hasSameSizeAs
in interface EnumerableAssert<CharArrayAssert,Character>
other
- the array to compare size with actual group.this
assertion object.public CharArrayAssert hasSameSizeAs(Iterable<?> other)
Iterable
.hasSameSizeAs
in interface EnumerableAssert<CharArrayAssert,Character>
other
- the Iterable
to compare size with actual group.this
assertion object.public CharArrayAssert contains(char... values)
values
- the given values.this
assertion object.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array is null
.AssertionError
- if the actual array does not contain the given values.public CharArrayAssert containsOnly(char... values)
values
- the given values.this
assertion object.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array is null
.AssertionError
- if the actual array does not contain the given values, i.e. the actual array contains some or none of
the given values, or the actual array contains more values than the given ones.public CharArrayAssert containsSequence(char... sequence)
sequence
- the sequence of values to look for.AssertionError
- if the actual array is null
.AssertionError
- if the given array is null
.AssertionError
- if the actual array does not contain the given sequence.public CharArrayAssert contains(char value, Index index)
value
- the value to look for.index
- the index where the value should be stored in the actual array.AssertionError
- if the actual array is null
or empty.NullPointerException
- if the given Index
is null
.IndexOutOfBoundsException
- if the value of the given Index
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.public CharArrayAssert doesNotContain(char... values)
values
- the given values.this
assertion object.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array is null
.AssertionError
- if the actual array contains any of the given values.public CharArrayAssert doesNotContain(char value, Index index)
value
- the value to look for.index
- the index where the value should be stored in the actual array.AssertionError
- if the actual array is null
.NullPointerException
- if the given Index
is null
.AssertionError
- if the actual array contains the given value at the given index.public CharArrayAssert doesNotHaveDuplicates()
this
assertion object.AssertionError
- if the actual array is null
.AssertionError
- if the actual array contains duplicates.public CharArrayAssert startsWith(char... sequence)
containsSequence(char...)
, but it also verifies that the first element in the sequence is also first
element of the actual array.sequence
- the sequence of values to look for.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array is null
.AssertionError
- if the actual array does not start with the given sequence.public CharArrayAssert endsWith(char... sequence)
containsSequence(char...)
, but it also verifies that the last element in the sequence is also last
element of the actual array.sequence
- the sequence of values to look for.NullPointerException
- if the given argument is null
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array is null
.AssertionError
- if the actual array does not end with the given sequence.public CharArrayAssert isSorted()
All array elements must be primitive or implement the Comparable
interface and must be mutually comparable (that is,
e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the array), examples :
isSorted
in interface ArraySortedAssert<CharArrayAssert,Character>
this
assertion object.public CharArrayAssert isSortedAccordingTo(Comparator<? super Character> comparator)
isSortedAccordingTo
in interface ArraySortedAssert<CharArrayAssert,Character>
comparator
- the Comparator
used to compare array elementsthis
assertion object.public CharArrayAssert usingElementComparator(Comparator<? super Character> customComparator)
equals
method to compare group elements for
incoming assertion checks.
Custom comparator is bound to assertion instance, meaning that if a new assertion is created, it will use default comparison strategy.
Examples :
// compares invoices by payee assertThat(invoiceList).usingComparator(invoicePayeeComparator).isEqualTo(expectedInvoiceList). // compares invoices by date, doesNotHaveDuplicates and contains both use the given invoice date comparator assertThat(invoiceList).usingComparator(invoiceDateComparator).doesNotHaveDuplicates().contains(may2010Invoice) // as assertThat(invoiceList) creates a new assertion, it falls back to standard comparison strategy // based on Invoice's equal method to compare invoiceList elements to lowestInvoice. assertThat(invoiceList).contains(lowestInvoice). // standard comparison : the fellowshipOfTheRing includes Gandalf but not Sauron (believe me) ... assertThat(fellowshipOfTheRing).contains(gandalf) .doesNotContain(sauron); // ... but if we compare only races, Sauron is in fellowshipOfTheRing because he's a Maia like Gandalf. assertThat(fellowshipOfTheRing).usingElementComparator(raceComparator) .contains(sauron);
usingElementComparator
in interface EnumerableAssert<CharArrayAssert,Character>
customComparator
- the comparator to use for incoming assertion checks.this
assertion object.public CharArrayAssert usingDefaultElementComparator()
This method should be used to disable a custom comparison strategy set by calling EnumerableAssert.usingElementComparator(Comparator)
.
usingDefaultElementComparator
in interface EnumerableAssert<CharArrayAssert,Character>
this
assertion object.Copyright © 2013 AssertJ. All Rights Reserved.