|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fest.assertions.api.AbstractAssert<DoubleArrayAssert,double[]>
org.fest.assertions.api.DoubleArrayAssert
public class DoubleArrayAssert
Assertion methods for arrays of double
s.
To create an instance of this class, invoke
.
Assertions.assertThat(double[])
Field Summary |
---|
Fields inherited from class org.fest.assertions.api.AbstractAssert |
---|
actual, myself |
Constructor Summary | |
---|---|
protected |
DoubleArrayAssert(double[] actual)
|
Method Summary | |
---|---|
DoubleArrayAssert |
contains(double... values)
Verifies that the actual array contains the given values, in any order. |
DoubleArrayAssert |
contains(double value,
Index index)
Verifies that the actual array contains the given value at the given index. |
DoubleArrayAssert |
containsOnly(double... values)
Verifies that the actual array contains only the given values and nothing else, in any order. |
DoubleArrayAssert |
containsSequence(double... sequence)
Verifies that the actual array contains the given sequence, without any other values between them. |
DoubleArrayAssert |
doesNotContain(double... values)
Verifies that the actual array does not contain the given values. |
DoubleArrayAssert |
doesNotContain(double value,
Index index)
Verifies that the actual array does not contain the given value at the given index. |
DoubleArrayAssert |
doesNotHaveDuplicates()
Verifies that the actual array does not contain duplicates. |
DoubleArrayAssert |
endsWith(double... sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them. |
DoubleArrayAssert |
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. |
DoubleArrayAssert |
isNotEmpty()
Verifies that the actual group of values is not empty. |
void |
isNullOrEmpty()
Verifies that the actual group of values is null or empty. |
DoubleArrayAssert |
isSorted()
Verifies that the actual array is sorted into ascending order according to the natural ordering of its elements. |
DoubleArrayAssert |
isSortedAccordingTo(Comparator<? extends Double> comparator)
Verifies that the actual array is sorted according to the given comparator. |
DoubleArrayAssert |
startsWith(double... sequence)
Verifies that the actual array starts with the given sequence of values, without any other values between them. |
DoubleArrayAssert |
usingComparator(Comparator<?> customComparator)
Use given custom comparator instead of relying on actual type A equals method for incoming assertion checks. |
DoubleArrayAssert |
usingDefaultComparator()
Revert to standard comparison for incoming assertion checks. |
Methods inherited from class org.fest.assertions.api.AbstractAssert |
---|
as, as, describedAs, describedAs, descriptionText, doesNotHave, equals, has, hashCode, is, isEqualTo, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected DoubleArrayAssert(double[] actual)
Method Detail |
---|
public void isNullOrEmpty()
null
or empty.
isNullOrEmpty
in interface EnumerableAssert<DoubleArrayAssert>
public void isEmpty()
isEmpty
in interface EnumerableAssert<DoubleArrayAssert>
public DoubleArrayAssert isNotEmpty()
isNotEmpty
in interface EnumerableAssert<DoubleArrayAssert>
this
assertion object.public DoubleArrayAssert hasSize(int expected)
hasSize
in interface EnumerableAssert<DoubleArrayAssert>
expected
- the expected number of values in the actual group.
this
assertion object.public DoubleArrayAssert contains(double... 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 DoubleArrayAssert containsOnly(double... 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 DoubleArrayAssert containsSequence(double... 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 DoubleArrayAssert contains(double 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 DoubleArrayAssert doesNotContain(double... 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 DoubleArrayAssert doesNotContain(double 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 DoubleArrayAssert doesNotHaveDuplicates()
this
assertion object.
AssertionError
- if the actual array is null
.
AssertionError
- if the actual array contains duplicates.public DoubleArrayAssert startsWith(double... sequence)
containsSequence(double...)
, 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 DoubleArrayAssert endsWith(double... sequence)
containsSequence(double...)
, 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 DoubleArrayAssert 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<DoubleArrayAssert,Double>
this
assertion object.public DoubleArrayAssert isSortedAccordingTo(Comparator<? extends Double> comparator)
isSortedAccordingTo
in interface ArraySortedAssert<DoubleArrayAssert,Double>
comparator
- the Comparator
used to compare array elements
this
assertion object.public DoubleArrayAssert usingComparator(Comparator<?> customComparator)
AbstractAssert
// 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 uses standard comparison strategy (Invoice's equal method) to compare invoiceList elements to lowestInvoice. assertThat(invoiceList).contains(lowestInvoice).Custom comparator is not parameterized with actual type A (ie. Comparator<A>) because if it was, we could not write the following code :
// frodo and sam are instances of Character (a Character having a Race) // raceComparator implements Comparator<Character> // assertThat(frodo) returns an ObjectAssert and not a custom CharacterAssert implementing Assert<CharacterAssert, Character> assertThat(frodo).usingComparator(raceComparator).isEqualTo(sam); // won't compile ! The code does not compile because assertThat(frodo) returns an ObjectAssert, thus usingComparator expects a Comparator<Object> and Comparator<Character> is not a Comparator<Object> as generics are not reified. Note that, it would have worked if assertThat(frodo) returned a CharacterAssert implementing Assert<CharacterAssert, Character>.
usingComparator
in interface Assert<DoubleArrayAssert,double[]>
usingComparator
in class AbstractAssert<DoubleArrayAssert,double[]>
customComparator
- the comparator to use for incoming assertion checks.
this
assertion object.public DoubleArrayAssert usingDefaultComparator()
AbstractAssert
Assert.usingComparator(Comparator)
.
usingDefaultComparator
in interface Assert<DoubleArrayAssert,double[]>
usingDefaultComparator
in class AbstractAssert<DoubleArrayAssert,double[]>
this
assertion object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |