Package org.assertj.core.internal
Class DoubleArrays
- java.lang.Object
-
- org.assertj.core.internal.DoubleArrays
-
public class DoubleArrays extends Object
Reusable assertions for arrays ofdoubles.- Author:
- Alex Ruiz, Mikhail Mazursky, Nicolas François
-
-
Constructor Summary
Constructors Constructor Description DoubleArrays()DoubleArrays(ComparisonStrategy comparisonStrategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassertContains(AssertionInfo info, double[] actual, double[] values)Asserts that the given array contains the given values, in any order.voidassertContains(AssertionInfo info, double[] actual, double value, Index index)Verifies that the given array contains the given value at the given index.voidassertContainsAnyOf(AssertionInfo info, double[] actual, double[] values)voidassertContainsExactly(AssertionInfo info, double[] actual, double[] values)voidassertContainsExactlyInAnyOrder(AssertionInfo info, double[] actual, double[] values)voidassertContainsOnly(AssertionInfo info, double[] actual, double[] values)Asserts that the given array contains only the given values and nothing else, in any order.voidassertContainsOnlyOnce(AssertionInfo info, double[] actual, double[] values)Asserts that the given array contains only once the given values.voidassertContainsSequence(AssertionInfo info, double[] actual, double[] sequence)Verifies that the given array contains the given sequence of values, without any other values between them.voidassertContainsSubsequence(AssertionInfo info, double[] actual, double[] subsequence)Verifies that the given array contains the given subsequence of values (possibly with other values between them).voidassertDoesNotContain(AssertionInfo info, double[] actual, double[] values)Asserts that the given array does not contain the given values.voidassertDoesNotContain(AssertionInfo info, double[] actual, double value, Index index)Verifies that the given array does not contain the given value at the given index.voidassertDoesNotHaveDuplicates(AssertionInfo info, double[] actual)Asserts that the given array does not have duplicate values.voidassertEmpty(AssertionInfo info, double[] actual)Asserts that the given array is empty.voidassertEndsWith(AssertionInfo info, double[] actual, double[] sequence)Verifies that the given array ends with the given sequence of values, without any other values between them.voidassertHasSameSizeAs(AssertionInfo info, double[] actual, Iterable<?> other)Assert that the actual array has the same size as the otherIterable.voidassertHasSameSizeAs(AssertionInfo info, double[] actual, Object[] other)Assert that the actual array has the same size as the other array.voidassertHasSize(AssertionInfo info, double[] actual, int expectedSize)Asserts that the number of elements in the given array is equal to the expected one.voidassertHasSizeBetween(AssertionInfo info, double[] actual, int lowerBoundary, int higherBoundary)Asserts that the number of elements in the given array is between the given lower and higher boundary (inclusive).voidassertHasSizeGreaterThan(AssertionInfo info, double[] actual, int boundary)Asserts that the number of elements in the given array is greater than the given boundary.voidassertHasSizeGreaterThanOrEqualTo(AssertionInfo info, double[] actual, int boundary)Asserts that the number of elements in the given array is greater than or equal to the given boundary.voidassertHasSizeLessThan(AssertionInfo info, double[] actual, int boundary)Asserts that the number of elements in the given array is less than the given boundary.voidassertHasSizeLessThanOrEqualTo(AssertionInfo info, double[] actual, int boundary)Asserts that the number of elements in the given array is less than or equal to the given boundary.voidassertIsSorted(AssertionInfo info, double[] actual)Concrete implementation ofArraySortedAssert.isSorted().voidassertIsSortedAccordingToComparator(AssertionInfo info, double[] actual, Comparator<? super Double> comparator)Concrete implementation ofArraySortedAssert.isSortedAccordingTo(Comparator).voidassertNotEmpty(AssertionInfo info, double[] actual)Asserts that the given array is not empty.voidassertNullOrEmpty(AssertionInfo info, double[] actual)Asserts that the given array isnullor empty.voidassertStartsWith(AssertionInfo info, double[] actual, double[] sequence)Verifies that the given array starts with the given sequence of values, without any other values between them.Comparator<?>getComparator()static DoubleArraysinstance()Returns the singleton instance of this class.voidsetArrays(Arrays arrays)
-
-
-
Field Detail
-
INSTANCE
private static final DoubleArrays INSTANCE
-
arrays
private Arrays arrays
-
failures
Failures failures
-
-
Constructor Detail
-
DoubleArrays
DoubleArrays()
-
DoubleArrays
public DoubleArrays(ComparisonStrategy comparisonStrategy)
-
-
Method Detail
-
instance
public static DoubleArrays instance()
Returns the singleton instance of this class.- Returns:
- the singleton instance of this class.
-
setArrays
public void setArrays(Arrays arrays)
-
getComparator
public Comparator<?> getComparator()
-
assertNullOrEmpty
public void assertNullOrEmpty(AssertionInfo info, double[] actual)
Asserts that the given array isnullor empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
AssertionError- if the given array is notnull*and* contains one or more elements.
-
assertEmpty
public void assertEmpty(AssertionInfo info, double[] actual)
Asserts that the given array is empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
AssertionError- if the given array isnull.AssertionError- if the given array is not empty.
-
assertNotEmpty
public void assertNotEmpty(AssertionInfo info, double[] actual)
Asserts that the given array is not empty.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
AssertionError- if the given array isnull.AssertionError- if the given array is empty.
-
assertHasSize
public void assertHasSize(AssertionInfo info, double[] actual, int expectedSize)
Asserts that the number of elements in the given array is equal to the expected one.- Parameters:
info- contains information about the assertion.actual- the given array.expectedSize- the expected size ofactual.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is different than the expected one.
-
assertHasSizeGreaterThan
public void assertHasSizeGreaterThan(AssertionInfo info, double[] actual, int boundary)
Asserts that the number of elements in the given array is greater than the given boundary.- Parameters:
info- contains information about the assertion.actual- the given array.boundary- the given value to compare the size ofactualto.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not greater than the boundary.
-
assertHasSizeGreaterThanOrEqualTo
public void assertHasSizeGreaterThanOrEqualTo(AssertionInfo info, double[] actual, int boundary)
Asserts that the number of elements in the given array is greater than or equal to the given boundary.- Parameters:
info- contains information about the assertion.actual- the given array.boundary- the given value to compare the size ofactualto.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not greater than or equal to the boundary.
-
assertHasSizeLessThan
public void assertHasSizeLessThan(AssertionInfo info, double[] actual, int boundary)
Asserts that the number of elements in the given array is less than the given boundary.- Parameters:
info- contains information about the assertion.actual- the given array.boundary- the given value to compare the size ofactualto.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not less than the boundary.
-
assertHasSizeLessThanOrEqualTo
public void assertHasSizeLessThanOrEqualTo(AssertionInfo info, double[] actual, int boundary)
Asserts that the number of elements in the given array is less than or equal to the given boundary.- Parameters:
info- contains information about the assertion.actual- the given array.boundary- the given value to compare the size ofactualto.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not less than or equal to the boundary.
-
assertHasSizeBetween
public void assertHasSizeBetween(AssertionInfo info, double[] actual, int lowerBoundary, int higherBoundary)
Asserts that the number of elements in the given array is between the given lower and higher boundary (inclusive).- Parameters:
info- contains information about the assertion.actual- the given array.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.- Throws:
AssertionError- if the given array isnull.AssertionError- if the number of elements in the given array is not between the boundaries.
-
assertHasSameSizeAs
public void assertHasSameSizeAs(AssertionInfo info, double[] actual, Iterable<?> other)
Assert that the actual array has the same size as the otherIterable.- Parameters:
info- contains information about the assertion.actual- the given array.other- the group to compare- Throws:
AssertionError- if the actual group isnull.AssertionError- if the other group isnull.AssertionError- if the actual group does not have the same size.
-
assertHasSameSizeAs
public void assertHasSameSizeAs(AssertionInfo info, double[] actual, Object[] other)
Assert that the actual array has the same size as the other array.- Parameters:
info- contains information about the assertion.actual- the given array.other- the group to compare- Throws:
AssertionError- if the actual group isnull.AssertionError- if the other group isnull.AssertionError- if the actual group does not have the same size.
-
assertContains
public void assertContains(AssertionInfo info, double[] actual, double[] values)
Asserts that the given array contains the given values, in any order.- Parameters:
info- contains information about the assertion.actual- the given array.values- the values that are expected to be in the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array does not contain the given values.
-
assertContains
public void assertContains(AssertionInfo info, double[] actual, double value, Index index)
Verifies that the given array contains the given value at the given index.- Parameters:
info- contains information about the assertion.actual- the given array.value- the value to look for.index- the index where the value should be stored in the given array.- Throws:
AssertionError- if the given array isnullor empty.NullPointerException- if the givenIndexisnull.IndexOutOfBoundsException- if the value of the givenIndexis equal to or greater than the size of the given array.AssertionError- if the given array does not contain the given value at the given index.
-
assertDoesNotContain
public void assertDoesNotContain(AssertionInfo info, double[] actual, double value, Index index)
Verifies that the given array does not contain the given value at the given index.- Parameters:
info- contains information about the assertion.actual- the given array.value- the value to look for.index- the index where the value should be stored in the given array.- Throws:
AssertionError- if the given array isnull.NullPointerException- if the givenIndexisnull.AssertionError- if the given array contains the given value at the given index.
-
assertContainsOnly
public void assertContainsOnly(AssertionInfo info, double[] actual, double[] values)
Asserts that the given array contains only the given values and nothing else, in any order.- Parameters:
info- contains information about the assertion.actual- the given array.values- the values that are expected to be in the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array does not contain the given values or if the given array contains values that are not in the given array.
-
assertContainsOnlyOnce
public void assertContainsOnlyOnce(AssertionInfo info, double[] actual, double[] values)
Asserts that the given array contains only once the given values.- Parameters:
info- contains information about the assertion.actual- the given array.values- the values that are expected to be in the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array does not contain the given values or if the given array contains more than once values.
-
assertContainsExactly
public void assertContainsExactly(AssertionInfo info, double[] actual, double[] values)
-
assertContainsExactlyInAnyOrder
public void assertContainsExactlyInAnyOrder(AssertionInfo info, double[] actual, double[] values)
-
assertContainsSequence
public void assertContainsSequence(AssertionInfo info, double[] actual, double[] sequence)
Verifies that the given array contains the given sequence of values, without any other values between them.- Parameters:
info- contains information about the assertion.actual- the given array.sequence- the sequence of values to look for.- Throws:
AssertionError- if the given array isnull.NullPointerException- if the given sequence isnull.IllegalArgumentException- if the given sequence is empty.AssertionError- if the given array does not contain the given sequence of values.
-
assertContainsSubsequence
public void assertContainsSubsequence(AssertionInfo info, double[] actual, double[] subsequence)
Verifies that the given array contains the given subsequence of values (possibly with other values between them).- Parameters:
info- contains information about the assertion.actual- the given array.subsequence- the subsequence of values to look for.- Throws:
AssertionError- if the given array isnull.NullPointerException- if the given subsequence isnull.IllegalArgumentException- if the given subsequence is empty.AssertionError- if the given array does not contain the given subsequence of values.
-
assertDoesNotContain
public void assertDoesNotContain(AssertionInfo info, double[] actual, double[] values)
Asserts that the given array does not contain the given values.- Parameters:
info- contains information about the assertion.actual- the given array.values- the values that are expected not to be in the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array contains any of given values.
-
assertDoesNotHaveDuplicates
public void assertDoesNotHaveDuplicates(AssertionInfo info, double[] actual)
Asserts that the given array does not have duplicate values.- Parameters:
info- contains information about the assertion.actual- the given array.- Throws:
NullPointerException- if the array of values isnull.IllegalArgumentException- if the array of values is empty.AssertionError- if the given array isnull.AssertionError- if the given array contains duplicate values.
-
assertStartsWith
public void assertStartsWith(AssertionInfo info, double[] actual, double[] sequence)
Verifies that the given array starts with the given sequence of values, without any other values between them. Similar to, but it also verifies that the first element in the sequence is also the first element of the given array.assertContainsSequence(AssertionInfo, double[], double[])- Parameters:
info- contains information about the assertion.actual- the given array.sequence- the sequence of values to look for.- Throws:
NullPointerException- if the given argument isnull.IllegalArgumentException- if the given argument is an empty array.AssertionError- if the given array isnull.AssertionError- if the given array does not start with the given sequence of values.
-
assertEndsWith
public void assertEndsWith(AssertionInfo info, double[] actual, double[] sequence)
Verifies that the given array ends with the given sequence of values, without any other values between them. Similar to, but it also verifies that the last element in the sequence is also the last element of the given array.assertContainsSequence(AssertionInfo, double[], double[])- Parameters:
info- contains information about the assertion.actual- the given array.sequence- the sequence of values to look for.- Throws:
NullPointerException- if the given argument isnull.IllegalArgumentException- if the given argument is an empty array.AssertionError- if the given array isnull.AssertionError- if the given array does not end with the given sequence of values.
-
assertIsSorted
public void assertIsSorted(AssertionInfo info, double[] actual)
Concrete implementation ofArraySortedAssert.isSorted().- Parameters:
info- contains information about the assertion.actual- the given array.
-
assertIsSortedAccordingToComparator
public void assertIsSortedAccordingToComparator(AssertionInfo info, double[] actual, Comparator<? super Double> comparator)
Concrete implementation ofArraySortedAssert.isSortedAccordingTo(Comparator).- Parameters:
info- contains information about the assertion.actual- the given array.comparator- theComparatorused to compare array elements
-
assertContainsAnyOf
public void assertContainsAnyOf(AssertionInfo info, double[] actual, double[] values)
-
-