|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.fest.assertions.api.AbstractAssert<ByteArrayAssert,byte[]>
org.fest.assertions.api.ByteArrayAssert
public class ByteArrayAssert
Assertion methods for arrays of bytes.
To create an instance of this class, invoke .
Assertions.assertThat(byte[])
| Field Summary |
|---|
| Fields inherited from class org.fest.assertions.api.AbstractAssert |
|---|
actual, myself |
| Constructor Summary | |
|---|---|
protected |
ByteArrayAssert(byte[] actual)
|
| Method Summary | |
|---|---|
ByteArrayAssert |
contains(byte... values)
Verifies that the actual array contains the given values, in any order. |
ByteArrayAssert |
contains(byte value,
Index index)
Verifies that the actual array contains the given value at the given index. |
ByteArrayAssert |
containsOnly(byte... values)
Verifies that the actual array contains only the given values and nothing else, in any order. |
ByteArrayAssert |
containsSequence(byte... sequence)
Verifies that the actual array contains the given sequence, without any other values between them. |
ByteArrayAssert |
doesNotContain(byte... values)
Verifies that the actual array does not contain the given values. |
ByteArrayAssert |
doesNotContain(byte value,
Index index)
Verifies that the actual array does not contain the given value at the given index. |
ByteArrayAssert |
doesNotHaveDuplicates()
Verifies that the actual array does not contain duplicates. |
ByteArrayAssert |
endsWith(byte... sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them. |
ByteArrayAssert |
hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as given Iterable. |
ByteArrayAssert |
hasSameSizeAs(Object[] other)
Verifies that the actual group has the same size as given array. |
ByteArrayAssert |
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. |
ByteArrayAssert |
isNotEmpty()
Verifies that the actual group of values is not empty. |
void |
isNullOrEmpty()
Verifies that the actual group of values is null or empty. |
ByteArrayAssert |
isSorted()
Verifies that the actual array is sorted into ascending order according to the natural ordering of its elements. |
ByteArrayAssert |
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 element is compatible with comparator, otherwise an AssertionError is thrown. |
ByteArrayAssert |
startsWith(byte... sequence)
Verifies that the actual array starts with the given sequence of values, without any other values between them. |
ByteArrayAssert |
usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks. |
ByteArrayAssert |
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. |
| Methods inherited from class org.fest.assertions.api.AbstractAssert |
|---|
as, as, describedAs, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, equals, 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 |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected ByteArrayAssert(byte[] actual)
| Method Detail |
|---|
public void isNullOrEmpty()
null or empty.
isNullOrEmpty in interface EnumerableAssert<ByteArrayAssert,Byte>public void isEmpty()
isEmpty in interface EnumerableAssert<ByteArrayAssert,Byte>public ByteArrayAssert isNotEmpty()
isNotEmpty in interface EnumerableAssert<ByteArrayAssert,Byte>this assertion object.public ByteArrayAssert hasSize(int expected)
hasSize in interface EnumerableAssert<ByteArrayAssert,Byte>expected - the expected number of values in the actual group.
this assertion object.public ByteArrayAssert hasSameSizeAs(Object[] other)
hasSameSizeAs in interface EnumerableAssert<ByteArrayAssert,Byte>other - the array to compare size with actual group.
this assertion object.public ByteArrayAssert hasSameSizeAs(Iterable<?> other)
Iterable.
hasSameSizeAs in interface EnumerableAssert<ByteArrayAssert,Byte>other - the Iterable to compare size with actual group.
this assertion object.public ByteArrayAssert contains(byte... 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 ByteArrayAssert containsOnly(byte... 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 ByteArrayAssert containsSequence(byte... 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 ByteArrayAssert contains(byte 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 ByteArrayAssert doesNotContain(byte... 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 ByteArrayAssert doesNotContain(byte 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 ByteArrayAssert doesNotHaveDuplicates()
this assertion object.
AssertionError - if the actual array is null.
AssertionError - if the actual array contains duplicates.public ByteArrayAssert startsWith(byte... sequence)
containsSequence(byte...), 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 ByteArrayAssert endsWith(byte... sequence)
containsSequence(byte...), 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 ByteArrayAssert 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<ByteArrayAssert,Byte>this assertion object.public ByteArrayAssert isSortedAccordingTo(Comparator<? super Byte> comparator)
isSortedAccordingTo in interface ArraySortedAssert<ByteArrayAssert,Byte>comparator - the Comparator used to compare array elements
this assertion object.public ByteArrayAssert 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);
usingElementComparator in interface EnumerableAssert<ByteArrayAssert,Byte>customComparator - the comparator to use for incoming assertion checks.
this assertion object.public ByteArrayAssert usingDefaultElementComparator()
This method should be used to disable a custom comparison strategy set by calling EnumerableAssert.usingElementComparator(Comparator).
usingDefaultElementComparator in interface EnumerableAssert<ByteArrayAssert,Byte>this assertion object.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||