public abstract class AbstractByteArrayAssert<SELF extends AbstractByteArrayAssert<SELF>> extends AbstractArrayAssert<SELF,byte[],Byte>
Modifier and Type | Field and Description |
---|---|
protected ByteArrays |
arrays |
actual, info, myself, throwUnsupportedExceptionOnEquals
Constructor and Description |
---|
AbstractByteArrayAssert(byte[] actual,
Class<?> selfType) |
Modifier and Type | Method and Description |
---|---|
SELF |
contains(byte... values)
Verifies that the actual array contains the given values, in any order.
|
SELF |
contains(byte value,
Index index)
Verifies that the actual array contains the given value at the given index.
|
SELF |
contains(int... values)
Verifies that the actual array contains the given values, in any order.
|
SELF |
contains(int value,
Index index)
Verifies that the actual array contains the given value at the given index.
|
SELF |
containsAnyOf(byte... values)
Verifies that the actual array contains at least one of the given values.
|
SELF |
containsAnyOf(int... values)
Verifies that the actual array contains at least one of the given values.
|
SELF |
containsExactly(byte... values)
Verifies that the actual group contains only the given values and nothing else, in order.
|
SELF |
containsExactly(int... values)
Verifies that the actual group contains only the given values and nothing else, in order.
|
SELF |
containsExactlyInAnyOrder(byte... values)
Verifies that the actual group contains exactly the given values and nothing else, in any order.
|
SELF |
containsExactlyInAnyOrder(int... values)
Verifies that the actual group contains exactly the given values and nothing else, in any order.
|
SELF |
containsOnly(byte... values)
Verifies that the actual array contains only the given values and nothing else, in any order.
|
SELF |
containsOnly(int... values)
Verifies that the actual array contains only the given values and nothing else, in any order.
|
SELF |
containsOnlyOnce(byte... values)
Verifies that the actual array contains the given values only once.
|
SELF |
containsOnlyOnce(int... values)
Verifies that the actual array contains the given values only once.
|
SELF |
containsSequence(byte... sequence)
Verifies that the actual array contains the given sequence, without any other values between them.
|
SELF |
containsSequence(int... sequence)
Verifies that the actual array contains the given sequence, without any other values between them.
|
SELF |
containsSubsequence(byte... subsequence)
Verifies that the actual array contains the given subsequence (possibly with other values between them).
|
SELF |
containsSubsequence(int... subsequence)
Verifies that the actual array contains the given subsequence (possibly with other values between them).
|
SELF |
doesNotContain(byte... values)
Verifies that the actual array does not contain the given values.
|
SELF |
doesNotContain(byte value,
Index index)
Verifies that the actual array does not contain the given value at the given index.
|
SELF |
doesNotContain(int... values)
Verifies that the actual array does not contain the given values.
|
SELF |
doesNotContain(int value,
Index index)
Verifies that the actual array does not contain the given value at the given index.
|
SELF |
doesNotHaveDuplicates()
Verifies that the actual array does not contain duplicates.
|
SELF |
endsWith(byte... sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them.
|
SELF |
endsWith(int... sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them.
|
SELF |
hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as given
Iterable . |
SELF |
hasSize(int expected)
Verifies that the number of values in the actual group is equal to the given one.
|
SELF |
hasSizeBetween(int lowerBoundary,
int higherBoundary)
Verifies that the number of values in the actual array is between the given boundaries (inclusive).
|
SELF |
hasSizeGreaterThan(int boundary)
Verifies that the number of values in the actual array is greater than the given boundary.
|
SELF |
hasSizeGreaterThanOrEqualTo(int boundary)
Verifies that the number of values in the actual group is greater than or equal to the given boundary.
|
SELF |
hasSizeLessThan(int boundary)
Verifies that the number of values in the actual array is less than the given boundary.
|
SELF |
hasSizeLessThanOrEqualTo(int boundary)
Verifies that the number of values in the actual array is less than or equal to the given boundary.
|
void |
isEmpty()
Verifies that the actual group of values is empty.
|
SELF |
isNotEmpty()
Verifies that the actual group of values is not empty.
|
void |
isNullOrEmpty()
Verifies that the actual group of values is
null or empty. |
SELF |
isSorted()
Verifies that the actual array is sorted in ascending order according to the natural ordering of its elements.
|
SELF |
isSortedAccordingTo(Comparator<? super Byte> 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 the element is compatible with comparator, otherwise an AssertionError is thrown. |
SELF |
startsWith(byte... sequence)
Verifies that the actual array starts with the given sequence of values, without any other values between them.
|
SELF |
startsWith(int... sequence)
Verifies that the actual array starts with the given sequence of values, without any other values between them.
|
SELF |
usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks.
|
SELF |
usingElementComparator(Comparator<? super Byte> customComparator)
Use given custom comparator instead of relying on actual type A
equals method to compare group
elements for incoming assertion checks. |
hasSameSizeAs, inBinary, inHexadecimal
as, as, asList, asString, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, is, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOf, setCustomRepresentation, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, withFailMessage, withRepresentation, withThreadDumpOnError
protected ByteArrays arrays
public AbstractByteArrayAssert(byte[] actual, Class<?> selfType)
public void isNullOrEmpty()
null
or empty.
Example:
// assertions will pass
List<String> strings = new ArrayList<>();
assertThat(strings).isNullOrEmpty();
assertThat(new int[] { }).isNullOrEmpty();
// assertions will fail
assertThat(new String[] { "a", "b"}).isNullOrEmpty();
assertThat(Arrays.asList(1, 2, 3)).isNullOrEmpty();
public void isEmpty()
Example:
// assertions will pass
assertThat(new ArrayList()).isEmpty();
assertThat(new int[] { }).isEmpty();
// assertions will fail
assertThat(new String[] { "a", "b" }).isEmpty();
assertThat(Arrays.asList(1, 2, 3)).isEmpty();
public SELF isNotEmpty()
Example:
// assertions will pass
assertThat(new String[] { "a", "b" }).isNotEmpty();
assertThat(Arrays.asList(1, 2, 3)).isNotEmpty();
// assertions will fail
assertThat(new ArrayList()).isNotEmpty();
assertThat(new int[] { }).isNotEmpty();
this
assertion object.public SELF hasSize(int expected)
Example:
// assertions will pass
assertThat(new String[] { "a", "b" }).hasSize(2);
assertThat(Arrays.asList(1, 2, 3)).hasSize(3);
// assertions will fail
assertThat(new ArrayList()).hasSize(1);
assertThat(new int[] { 1, 2, 3 }).hasSize(2);
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).hasSize(3);
// assertion will fail
assertThat(new byte[] { 1, 2, 3, 4 }).hasSize(3);
expected
- the expected number of values in the actual group.this
assertion object.public SELF hasSizeGreaterThan(int boundary)
Example:
// assertion will pass
assertThat(new byte[] { 2, 3 }).hasSizeGreaterThan(1);
// assertion will fail
assertThat(new byte[] { 8 }).hasSizeGreaterThan(1);
boundary
- the given value to compare the actual size to.this
assertion object.AssertionError
- if the number of values of the actual array is not greater than the boundary.public SELF hasSizeGreaterThanOrEqualTo(int boundary)
Example:
// assertion will pass
assertThat(new byte[] { 17, 1 }).hasSizeGreaterThanOrEqualTo(1)
.hasSizeGreaterThanOrEqualTo(2);
// assertion will fail
assertThat(new byte[] { 3 }).hasSizeGreaterThanOrEqualTo(2);
boundary
- the given value to compare the actual size to.this
assertion object.AssertionError
- if the number of values of the actual array is not greater than or equal to the boundary.public SELF hasSizeLessThan(int boundary)
Example:
// assertion will pass
assertThat(new byte[] { 2, 9 }).hasSizeLessThan(3);
// assertion will fail
assertThat(new byte[] { 100, 101 }).hasSizeLessThan(1);
boundary
- the given value to compare the actual size to.this
assertion object.AssertionError
- if the number of values of the actual array is not less than the boundary.public SELF hasSizeLessThanOrEqualTo(int boundary)
Example:
// assertion will pass
assertThat(new byte[] { 56, 57 }).hasSizeLessThanOrEqualTo(3)
.hasSizeLessThanOrEqualTo(2);
// assertion will fail
assertThat(new byte[] { 42, 43 }).hasSizeLessThanOrEqualTo(1);
boundary
- the given value to compare the actual size to.this
assertion object.AssertionError
- if the number of values of the actual array is not less than or equal to the boundary.public SELF hasSizeBetween(int lowerBoundary, int higherBoundary)
Example:
// assertion will pass
assertThat(new byte[] { 22, 23 }).hasSizeBetween(1, 3)
.hasSizeBetween(2, 2);
// assertion will fail
assertThat(new byte[] { 37, 38 }).hasSizeBetween(4, 5);
lowerBoundary
- the lower boundary compared to which actual size should be greater than or equal to.higherBoundary
- the higher boundary compared to which actual size should be less than or equal to.this
assertion object.AssertionError
- if the number of values of the actual array is not between the boundaries.public SELF hasSameSizeAs(Iterable<?> other)
Iterable
.
Examples:
// assertion will pass
assertThat(new byte[] { 95, 96 }).hasSameSizeAs(Arrays.asList(2, 3));
// assertion will fail
assertThat(new byte[] { 126, 127 }).hasSameSizeAs(Arrays.asList(1, 2, 3));
other
- the Iterable
to compare size with actual group.this
assertion object.public SELF contains(byte... values)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, (byte) 2);
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 3, (byte) 1);
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, (byte) 3, (byte) 2);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, (byte) 4);
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 4, (byte) 7);
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 SELF contains(int... values)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).contains(1, 2);
assertThat(new byte[] { 1, 2, 3 }).contains(3, 1);
assertThat(new byte[] { 1, 2, 3 }).contains(1, 3, 2);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).contains(1, 4);
assertThat(new byte[] { 1, 2, 3 }).contains(4, 7);
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 SELF containsOnly(byte... values)
Example:
// assertions will pass
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 1, (byte) 2, (byte) 3);
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 2, (byte) 3, (byte) 1);
assertThat(new byte[] { 1, 1, 2 }).containsOnly((byte) 1, (byte) 2);
// assertions will fail
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 1, (byte) 2, (byte) 3, (byte) 4);
assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 4, (byte) 7);
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 SELF containsOnly(int... values)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsOnly(1, 2, 3);
assertThat(new byte[] { 1, 2, 3 }).containsOnly(2, 3, 1);
assertThat(new byte[] { 1, 1, 2 }).containsOnly(1, 2);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).containsOnly(1, 2, 3, 4);
assertThat(new byte[] { 1, 2, 3 }).containsOnly(4, 7);
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 SELF containsOnlyOnce(byte... values)
Examples :
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsOnlyOnce((byte) 1, (byte) 2);
// assertions will fail
assertThat(new byte[] { 1, 2, 1 }).containsOnlyOnce((byte) 1);
assertThat(new byte[] { 1, 2, 3 }).containsOnlyOnce((byte) 4);
assertThat(new byte[] { 1, 2, 3, 3 }).containsOnlyOnce((byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5);
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 group does not contain the given values, i.e. the actual group
contains some
or none of the given values, or the actual group contains more than once these
values.public SELF containsOnlyOnce(int... values)
Examples :
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsOnlyOnce(1, 2);
// assertions will fail
assertThat(new byte[] { 1, 2, 1 }).containsOnlyOnce(1);
assertThat(new byte[] { 1, 2, 3 }).containsOnlyOnce(4);
assertThat(new byte[] { 1, 2, 3, 3 }).containsOnlyOnce(0, 1, 2, 3, 4, 5);
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 group does not contain the given values, i.e. the actual group
contains some
or none of the given values, or the actual group contains more than once these
values.public SELF containsSequence(byte... sequence)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 1, (byte) 2);
assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 1, (byte) 2, (byte) 3);
assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 2, (byte) 3);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 1, (byte) 3);
assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 4, (byte) 7);
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 SELF containsSequence(int... sequence)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsSequence(1, 2);
assertThat(new byte[] { 1, 2, 3 }).containsSequence(1, 2, 3);
assertThat(new byte[] { 1, 2, 3 }).containsSequence(2, 3);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).containsSequence(1, 3);
assertThat(new byte[] { 1, 2, 3 }).containsSequence(4, 7);
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 SELF containsSubsequence(byte... subsequence)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 1, (byte) 2, (byte) 3);
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 1, (byte) 2);
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 1, (byte) 3);
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 2, (byte) 3);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 2, (byte) 1);
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 4, (byte) 7);
subsequence
- the subsequence 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 subsequence.public SELF containsSubsequence(int... subsequence)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(1, 2, 3);
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(1, 2);
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(1, 3);
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(2, 3);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(2, 1);
assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(4, 7);
subsequence
- the subsequence 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 subsequence.public SELF contains(byte value, Index index)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, atIndex(O));
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 3, atIndex(2));
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, atIndex(1));
assertThat(new byte[] { 1, 2, 3 }).contains((byte) 4, atIndex(2));
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 SELF contains(int value, Index index)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).contains(1, atIndex(O));
assertThat(new byte[] { 1, 2, 3 }).contains(3, atIndex(2));
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).contains(1, atIndex(1));
assertThat(new byte[] { 1, 2, 3 }).contains(4, atIndex(2));
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 SELF doesNotContain(byte... values)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 4);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 2);
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 SELF doesNotContain(int... values)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).doesNotContain(4);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).doesNotContain(2);
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 SELF doesNotContain(byte value, Index index)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 1, atIndex(1));
assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 2, atIndex(0));
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 1, atIndex(0));
assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 2, atIndex(1));
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 SELF doesNotContain(int value, Index index)
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).doesNotContain(1, atIndex(1));
assertThat(new byte[] { 1, 2, 3 }).doesNotContain(2, atIndex(0));
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).doesNotContain(1, atIndex(0));
assertThat(new byte[] { 1, 2, 3 }).doesNotContain(2, atIndex(1));
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 SELF doesNotHaveDuplicates()
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).doesNotHaveDuplicates();
// assertion will fail
assertThat(new byte[] { 1, 1, 2, 3 }).doesNotHaveDuplicates();
this
assertion object.AssertionError
- if the actual array is null
.AssertionError
- if the actual array contains duplicates.public SELF startsWith(byte... sequence)
containsSequence(byte...)
, but it also verifies that the first element in the
sequence is also first element of the actual array.
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).startsWith((byte) 1, (byte) 2);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).startsWith((byte) 2, (byte) 3);
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 SELF startsWith(int... sequence)
containsSequence(byte...)
, but it also verifies that the first element in the
sequence is also first element of the actual array.
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).startsWith(1, 2);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).startsWith(2, 3);
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 SELF endsWith(byte... sequence)
containsSequence(byte...)
, but it also verifies that the last element in the
sequence is also last element of the actual array.
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).endsWith((byte) 2, (byte) 3);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).endsWith((byte) 3, (byte) 4);
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 SELF endsWith(int... sequence)
containsSequence(byte...)
, but it also verifies that the last element in the
sequence is also last element of the actual array.
Example:
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).endsWith(2, 3);
// assertion will fail
assertThat(new byte[] { 1, 2, 3 }).endsWith(3, 4);
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 SELF 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 :
this
assertion object.public SELF isSortedAccordingTo(Comparator<? super Byte> comparator)
comparator
- the Comparator
used to compare array elementsthis
assertion object.public SELF usingElementComparator(Comparator<? super Byte> 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);
customComparator
- the comparator to use for incoming assertion checks.this
assertion object.public SELF usingDefaultElementComparator()
This method should be used to disable a custom comparison strategy set by calling
EnumerableAssert.usingElementComparator(Comparator)
.
this
assertion object.public SELF containsExactly(byte... values)
Example :
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsExactly((byte) 1, (byte) 2, (byte) 3);
// assertion will fail as actual and expected order differ
assertThat(new byte[] { 1, 2, 3 }).containsExactly((byte) 2, (byte) 1, (byte) 3);
values
- the given values.this
assertion object.NullPointerException
- if the given argument is null
.AssertionError
- if the actual group is null
.AssertionError
- if the actual group does not contain the given values with same order, i.e. the actual
group
contains some or none of the given values, or the actual group contains more values
than the given ones
or values are the same but the order is not.public SELF containsExactly(int... values)
Example :
// assertion will pass
assertThat(new byte[] { 1, 2, 3 }).containsExactly(1, 2, 3);
// assertion will fail as actual and expected order differ
assertThat(new byte[] { 1, 2, 3 }).containsExactly(2, 1, 3);
values
- the given values.this
assertion object.NullPointerException
- if the given argument is null
.AssertionError
- if the actual group is null
.AssertionError
- if the actual group does not contain the given values with same order, i.e. the actual
group
contains some or none of the given values, or the actual group contains more values
than the given ones
or values are the same but the order is not.public SELF containsExactlyInAnyOrder(byte... values)
Example :
// assertions will pass
assertThat(new byte[] { 1, 2 }).containsExactlyInAnyOrder((byte) 1, (byte) 2);
assertThat(new byte[] { 1, 2, 1 }).containsExactlyInAnyOrder((byte) 1, (byte) 1, (byte) 2);
// assertions will fail
assertThat(new byte[] { 1, 2 }).containsExactlyInAnyOrder((byte) 1);
assertThat(new byte[] { 1 }).containsExactlyInAnyOrder((byte) 1, (byte) 2);
assertThat(new byte[] { 1, 2, 1 }).containsExactlyInAnyOrder((byte) 1, (byte) 2);
values
- the given values.this
assertion object.NullPointerException
- if the given argument is null
.AssertionError
- if the actual group is null
.AssertionError
- if the actual group does not contain the given values, i.e. the actual group
contains some or none of the given values, or the actual group contains more values than the given ones.public SELF containsExactlyInAnyOrder(int... values)
Example :
// assertions will pass
assertThat(new byte[] { 1, 2 }).containsExactlyInAnyOrder(1, 2);
assertThat(new byte[] { 1, 2, 1 }).containsExactlyInAnyOrder(1, 1, 2);
// assertions will fail
assertThat(new byte[] { 1, 2 }).containsExactlyInAnyOrder(1);
assertThat(new byte[] { 1 }).containsExactlyInAnyOrder(1, 2);
assertThat(new byte[] { 1, 2, 1 }).containsExactlyInAnyOrder(1, 2);
values
- the given values.this
assertion object.NullPointerException
- if the given argument is null
.AssertionError
- if the actual group is null
.AssertionError
- if the actual group does not contain the given values, i.e. the actual group
contains some or none of the given values, or the actual group contains more values than the given ones.public SELF containsAnyOf(byte... values)
Example :
byte[] oneTwoThree = { 1, 2, 3 };
// assertions will pass
assertThat(oneTwoThree).containsAnyOf((byte)2)
.containsAnyOf((byte)2, (byte)3)
.containsAnyOf((byte)1, (byte)2, (byte)3)
.containsAnyOf((byte)1, (byte)2, (byte)3, (byte)4)
.containsAnyOf((byte)5, (byte)6, (byte)7, (byte)2);
// assertions will fail
assertThat(oneTwoThree).containsAnyOf((byte)4);
assertThat(oneTwoThree).containsAnyOf((byte)4, (byte)5, (byte)6, (byte)7);
values
- the values whose at least one which is expected to be in the array under test.this
assertion object.NullPointerException
- if the array of values is null
.IllegalArgumentException
- if the array of values is empty and the array under test is not empty.AssertionError
- if the array under test is null
.AssertionError
- if the array under test does not contain any of the given values
.public SELF containsAnyOf(int... values)
Example :
byte[] oneTwoThree = { 1, 2, 3 };
// assertions will pass
assertThat(oneTwoThree).containsAnyOf(2)
.containsAnyOf(2, 3)
.containsAnyOf(1, 2, 3)
.containsAnyOf(1, 2, 3, 4)
.containsAnyOf(5, 6, 7, 2);
// assertions will fail
assertThat(oneTwoThree).containsAnyOf(4);
assertThat(oneTwoThree).containsAnyOf(4, 5, 6, 7);
values
- the values whose at least one which is expected to be in the array under test.this
assertion object.NullPointerException
- if the array of values is null
.IllegalArgumentException
- if the array of values is empty and the array under test is not empty.AssertionError
- if the array under test is null
.AssertionError
- if the array under test does not contain any of the given values
.Copyright © 2014–2019 AssertJ. All rights reserved.