Class AbstractFloatArrayAssert<SELF extends AbstractFloatArrayAssert<SELF>>
- java.lang.Object
-
- org.assertj.core.api.AbstractAssert<SELF,ACTUAL>
-
- org.assertj.core.api.AbstractEnumerableAssert<SELF,ACTUAL,ELEMENT>
-
- org.assertj.core.api.AbstractArrayAssert<SELF,float[],Float>
-
- org.assertj.core.api.AbstractFloatArrayAssert<SELF>
-
- All Implemented Interfaces:
ArraySortedAssert<AbstractArrayAssert<SELF,float[],Float>,Float>
,Assert<SELF,float[]>
,Descriptable<SELF>
,EnumerableAssert<AbstractEnumerableAssert<SELF,float[],Float>,Float>
,ExtensionPoints<SELF,float[]>
- Direct Known Subclasses:
FloatArrayAssert
public abstract class AbstractFloatArrayAssert<SELF extends AbstractFloatArrayAssert<SELF>> extends AbstractArrayAssert<SELF,float[],Float>
-
-
Field Summary
Fields Modifier and Type Field Description protected org.assertj.core.internal.FloatArrays
arrays
-
Fields inherited from class org.assertj.core.api.AbstractAssert
actual, assertionErrorCreator, conditions, customRepresentation, info, myself, objects, printAssertionsDescription, throwUnsupportedExceptionOnEquals
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFloatArrayAssert(float[] actual, Class<?> selfType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SELF
contains(float... values)
Verifies that the actual array contains the given values, in any order.SELF
contains(float[] values, Offset<Float> precision)
Verifies that the actual array contains the given values, in any order, the comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.SELF
contains(float value, Index index)
Verifies that the actual array contains the given value at the given index.SELF
contains(float value, Index index, Offset<Float> precision)
Verifies that the actual array contains the given value at the given index.SELF
contains(Float[] values)
Verifies that the actual array contains the values of the given array, in any order.SELF
contains(Float[] values, Offset<Float> precision)
Verifies that the actual array contains the values of the given array, in any order, the comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.SELF
containsAnyOf(float... values)
Verifies that the actual array contains at least one of the given values.SELF
containsAnyOf(Float[] values)
Verifies that the actual array contains at least one of the values of the given array.SELF
containsExactly(float... values)
Verifies that the actual group contains only the given values and nothing else, in order.SELF
containsExactly(float[] values, Offset<Float> precision)
Verifies that the actual group contains only the given values and nothing else, in order.SELF
containsExactly(Float[] values)
Verifies that the actual group contains only the values of the given array and nothing else, in order.SELF
containsExactly(Float[] values, Offset<Float> precision)
Verifies that the actual group contains only the values of the given array and nothing else, in order.SELF
containsExactlyInAnyOrder(float... values)
Verifies that the actual group contains exactly the given values and nothing else, in any order.SELF
containsExactlyInAnyOrder(Float[] values)
Verifies that the actual group contains exactly the values of the given array and nothing else, in any order.SELF
containsOnly(float... values)
Verifies that the actual array contains only the given values and nothing else, in any order.SELF
containsOnly(float[] values, Offset<Float> precision)
Verifies that the actual array contains only the given values and nothing else, in any order.SELF
containsOnly(Float[] values)
Verifies that the actual array contains only the values of the given array and nothing else, in any order.SELF
containsOnly(Float[] values, Offset<Float> precision)
Verifies that the actual array contains only the values of the given array and nothing else, in any order.SELF
containsOnlyOnce(float... values)
Verifies that the actual array contains the given values only once.SELF
containsOnlyOnce(float[] values, Offset<Float> precision)
Verifies that the actual array contains the given values only once.SELF
containsOnlyOnce(Float[] values)
Verifies that the actual array contains the values of the given array only once.SELF
containsOnlyOnce(Float[] values, Offset<Float> precision)
Verifies that the actual array contains the values of the given array only once.SELF
containsSequence(float... sequence)
Verifies that the actual array contains the given sequence, without any other values between them.SELF
containsSequence(float[] sequence, Offset<Float> precision)
Verifies that the actual array contains the given sequence, without any other values between them.SELF
containsSequence(Float[] sequence)
Verifies that the actual array contains the given sequence, without any other values between them.SELF
containsSequence(Float[] sequence, Offset<Float> precision)
Verifies that the actual array contains the given sequence, without any other values between them.SELF
containsSubsequence(float... subsequence)
Verifies that the actual array contains the given subsequence (possibly with other values between them).SELF
containsSubsequence(float[] subsequence, Offset<Float> precision)
Verifies that the actual array contains the given subsequence (possibly with other values between them).SELF
containsSubsequence(Float[] subsequence)
Verifies that the actual array contains the given subsequence (possibly with other values between them).SELF
containsSubsequence(Float[] subsequence, Offset<Float> precision)
Verifies that the actual array contains the given subsequence (possibly with other values between them).SELF
doesNotContain(float... values)
Verifies that the actual array does not contain the given values.SELF
doesNotContain(float[] values, Offset<Float> precision)
Verifies that the actual array does not contain the given values.SELF
doesNotContain(float value, Index index)
Verifies that the actual array does not contain the given value at the given index.SELF
doesNotContain(float value, Index index, Offset<Float> precision)
Verifies that the actual array does not contain the given value at the given index.SELF
doesNotContain(Float[] values)
Verifies that the actual array does not contain the values of the given array.SELF
doesNotContain(Float[] values, Offset<Float> precision)
Verifies that the actual array does not contain the values of the given array.SELF
doesNotHaveDuplicates()
Verifies that the actual array does not contain duplicates.SELF
doesNotHaveDuplicates(Offset<Float> precision)
Verifies that the actual array does not contain duplicates.SELF
endsWith(float... sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them.SELF
endsWith(float[] values, Offset<Float> precision)
Verifies that the actual array ends with the given sequence of values, without any other values between them.SELF
endsWith(Float[] sequence)
Verifies that the actual array ends with the given sequence of values, without any other values between them.SELF
endsWith(Float[] values, Offset<Float> precision)
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 givenIterable
.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 group 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 array 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 isnull
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 Float> 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(float... sequence)
Verifies that the actual array starts with the given sequence of values, without any other values between them.SELF
startsWith(float[] values, Offset<Float> precision)
Verifies that the actual array starts with the given sequence of values, without any other values between them.SELF
startsWith(Float[] sequence)
Verifies that the actual array starts with the given sequence of values, without any other values between them.SELF
startsWith(Float[] values, Offset<Float> precision)
Verifies that the actual array starts with the given sequence of values, without any other values between them.private static float[]
toPrimitiveFloatArray(Float[] values)
SELF
usingComparatorWithPrecision(Float precision)
Create aFloat
comparator which compares floats at the given precision and pass it tousingElementComparator(Comparator)
.SELF
usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks.SELF
usingElementComparator(Comparator<? super Float> customComparator)
Use given custom comparator instead of relying on actual type Aequals
method to compare group elements for incoming assertion checks.-
Methods inherited from class org.assertj.core.api.AbstractArrayAssert
requireNonNullParameter
-
Methods inherited from class org.assertj.core.api.AbstractEnumerableAssert
hasSameSizeAs, inBinary, inHexadecimal
-
Methods inherited from class org.assertj.core.api.AbstractAssert
asInstanceOf, asList, assertionError, asString, describedAs, descriptionText, doesNotHave, doesNotHaveSameClassAs, doesNotHaveSameHashCodeAs, doesNotHaveToString, equals, extracting, extracting, failure, failureWithActualExpected, failWithActualExpectedAndMessage, failWithMessage, getWritableAssertionInfo, has, hashCode, hasSameClassAs, hasSameHashCodeAs, hasToString, is, isElementOfCustomAssert, isEqualTo, isExactlyInstanceOf, isIn, isIn, isInstanceOf, isInstanceOfAny, isInstanceOfSatisfying, isNot, isNotEqualTo, isNotExactlyInstanceOf, isNotIn, isNotIn, isNotInstanceOf, isNotInstanceOfAny, isNotNull, isNotOfAnyClassIn, isNotSameAs, isNull, isOfAnyClassIn, isSameAs, matches, matches, newListAssertInstance, overridingErrorMessage, overridingErrorMessage, satisfies, satisfies, satisfiesAnyOf, satisfiesAnyOfForProxy, setCustomRepresentation, setDescriptionConsumer, setPrintAssertionsDescription, throwAssertionError, usingComparator, usingComparator, usingDefaultComparator, usingRecursiveComparison, usingRecursiveComparison, withAssertionState, withFailMessage, withFailMessage, withRepresentation, withThreadDumpOnError
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.assertj.core.api.Descriptable
as, as, as, describedAs
-
-
-
-
Constructor Detail
-
AbstractFloatArrayAssert
protected AbstractFloatArrayAssert(float[] actual, Class<?> selfType)
-
-
Method Detail
-
isNullOrEmpty
public void isNullOrEmpty()
Verifies that the actual group of values isnull
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();
-
isEmpty
public void isEmpty()
Verifies that the actual group of values is empty.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();
-
isNotEmpty
public SELF isNotEmpty()
Verifies that the actual group of values is not empty.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();
- Returns:
this
assertion object.
-
hasSize
public SELF hasSize(int expected)
Verifies that the number of values in the actual group is equal to the given one.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);
Examples:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f, 3.0f }).hasSize(3); // assertions will fail assertThat(new float[] { 1.0f, 2.0f, 1.0f }).hasSize(2);
- Parameters:
expected
- the expected number of values in the actual group.- Returns:
this
assertion object.
-
hasSizeGreaterThan
public SELF hasSizeGreaterThan(int boundary)
Verifies that the number of values in the actual array is greater than the given boundary.Example:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f }).hasSizeGreaterThan(1); // assertion will fail assertThat(new float[] { 1.0f }).hasSizeGreaterThan(1);
- Parameters:
boundary
- the given value to compare the actual size to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not greater than the boundary.- Since:
- 3.12.0
-
hasSizeGreaterThanOrEqualTo
public SELF hasSizeGreaterThanOrEqualTo(int boundary)
Verifies that the number of values in the actual array is greater than or equal to the given boundary.Example:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f }).hasSizeGreaterThanOrEqualTo(1) .hasSizeGreaterThanOrEqualTo(2); // assertion will fail assertThat(new float[] { 1.0f }).hasSizeGreaterThanOrEqualTo(2);
- Parameters:
boundary
- the given value to compare the actual size to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not greater than or equal to the boundary.- Since:
- 3.12.0
-
hasSizeLessThan
public SELF hasSizeLessThan(int boundary)
Verifies that the number of values in the actual array is less than the given boundary.Example:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f }).hasSizeLessThan(3); // assertion will fail assertThat(new float[] { 1.0f, 2.0f }).hasSizeLessThan(1);
- Parameters:
boundary
- the given value to compare the actual size to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not less than the boundary.- Since:
- 3.12.0
-
hasSizeLessThanOrEqualTo
public SELF hasSizeLessThanOrEqualTo(int boundary)
Verifies that the number of values in the actual array is less than or equal to the given boundary.Example:
// assertion will pass assertThat(new byte[] { 1.0f, 2.0f }).hasSizeLessThanOrEqualTo(3) .hasSizeLessThanOrEqualTo(2); // assertion will fail assertThat(new byte[] { 1.0f, 2.0f }).hasSizeLessThanOrEqualTo(1);
- Parameters:
boundary
- the given value to compare the actual size to.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not less than or equal to the boundary.- Since:
- 3.12.0
-
hasSizeBetween
public SELF hasSizeBetween(int lowerBoundary, int higherBoundary)
Verifies that the number of values in the actual group is between the given boundaries (inclusive).Example:
// assertion will pass assertThat(new byte[] { 1.0f, 2.0f }).hasSizeBetween(1, 3) .hasSizeBetween(2, 2); // assertion will fail assertThat(new byte[] { 1.0f, 2.0f }).hasSizeBetween(4, 5);
- Parameters:
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.- Returns:
this
assertion object.- Throws:
AssertionError
- if the number of values of the actual array is not between the boundaries.- Since:
- 3.12.0
-
hasSameSizeAs
public SELF hasSameSizeAs(Iterable<?> other)
Verifies that the actual group has the same size as givenIterable
.Examples:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f, 3.0f }).hasSameSizeAs(Arrays.asList(1, 2, 3)); // assertion will fail assertThat(new float[] { 1.0f, 2.0f, 1.0f }).hasSameSizeAs(Arrays.asList(1, 2));
- Parameters:
other
- theIterable
to compare size with actual group.- Returns:
this
assertion object.
-
contains
public SELF contains(float... values)
Verifies that the actual array contains the given values, in any order.If you want to set a precision for the comparison either use
contains(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Examples :
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertions will pass assertThat(values).contains(1.0f, 3.0f, 2.0f) .contains(3.0f, 1.0f) .usingComparatorWithPrecision(0.5f) .contains(1.1f, 2.1f); // assertions will fail assertThat(values).contains(1.0f, 4.0f); assertThat(values).usingComparatorWithPrecision(0.01f) .contains(1.1f, 2.1f);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not contain the given values.
-
contains
public SELF contains(Float[] values)
Verifies that the actual array contains the values of the given array, in any order.Example:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f }).contains(new Float[] { 1.0f, 2.0f }); assertThat(new float[] { 1.0f, 2.0f }).contains(new Float[] { 1.0f, 2.0f }); assertThat(new float[] { 1.0f, 2.0f }).contains(new Float[] { 1.0f }); // assertion will fail assertThat(new float[] { 1.0f, 2.0f }).contains(new Float[] { 3.0f });
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not contain the given values.- Since:
- 3.19.0
-
contains
public SELF contains(float[] values, Offset<Float> precision)
Verifies that the actual array contains the given values, in any order, the comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertion will pass assertThat(values).contains(new float[] { 1.01f, 3.01f, 2.0f }, withPrecision(0.02f)); // assertions will fail assertThat(values).contains(new float[] { 1.0f, 4.0f }, withPrecision(0.5f)); assertThat(values).contains(new float[] { 4.0f, 7.0f }, withPrecision(2f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not contain the given values.
-
contains
public SELF contains(Float[] values, Offset<Float> precision)
Verifies that the actual array contains the values of the given array, in any order, the comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).contains(new Float[] { 1.01f, 3.01f, 2.0f }, withPrecision(0.02f)); // assertions will fail assertThat(values).contains(new Float[] { 1.0f, 4.0f }, withPrecision(0.5f)); assertThat(values).contains(new Float[] { 4.0f, 7.0f }, withPrecision(2f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not contain the given values.- Since:
- 3.19.0
-
containsOnly
public SELF containsOnly(float... values)
Verifies that the actual array contains only the given values and nothing else, in any order.If you want to set a precision for the comparison either use
containsOnly(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Examples :
float[] values = new double[] {1.0f, 2.0f, 3.0f}; // assertions will pass assertThat(values).containsOnly(1.0f, 2.0f, 3.0f) .containsOnly(2.0f, 3.0f, 1.0f) .usingComparatorWithPrecision(0.5f) .containsOnly(1.1f, 3.1f, 2.1f); // assertions will fail assertThat(values).containsOnly(1.0f, 4.0f, 2.0f, 3.0f); assertThat(values).containsOnly(4.0f, 7.0f); assertThat(values).containsOnly(1.1f, 2.1f, 3.1f); assertThat(values).usingComparatorWithPrecision(0.01f) .containsOnly(1.1f, 2.1f, 3.1f);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.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.
-
containsOnly
public SELF containsOnly(Float[] values)
Verifies that the actual array contains only the values of the given array and nothing else, in any order.Example:
// assertions will pass assertThat(new float[] { 1.0f, 2.0f }).containsOnly(new Float[] { 1.0f, 2.0f }); assertThat(new float[] { 2.0f, 1.0f }).containsOnly(new Float[] { 1.0f, 2.0f }); assertThat(new float[] { 1.0f, 1.0f, 2.0f }).containsOnly(new Float[] { 1.0f, 2.0f }); // assertions will fail assertThat(new float[] { 1.0f, 2.0f }).containsOnly(new Float[] { 2.0f }); assertThat(new float[] { 1.0f }).containsOnly(new Float[] { 1.0f, 2.0f });
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.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.- Since:
- 3.19.0
-
containsOnly
public SELF containsOnly(float[] values, Offset<Float> precision)
Verifies that the actual array contains only the given values and nothing else, in any order. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertion will pass assertThat(values).containsOnly(new float[] {1.0f, 2.0f, 3.0f }, withPrecision(0.00001f)) .containsOnly(new float[] {2.0,f 3.0f, 0.7f}, withPrecision(0.5f)); // assertions will fail assertThat(values).containsOnly(new float[] {1.0f, 4.0f, 2.0f, 3.0f}, withPrecision(0.5f)); assertThat(values).containsOnly(new float[] {4.0f, 7.0f}, withPrecision(0.2f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.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.
-
containsOnly
public SELF containsOnly(Float[] values, Offset<Float> precision)
Verifies that the actual array contains only the values of the given array and nothing else, in any order. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).containsOnly(new Float[] { 1.0f, 2.0f, 3.0f }, withPrecision(0.00001f)) .containsOnly(new Float[] { 2.0,f 3.0f, 0.7f }, withPrecision(0.5f)); // assertions will fail assertThat(values).containsOnly(new Float[] { 1.0f, 4.0f, 2.0f, 3.0f }, withPrecision(0.5f)); assertThat(values).containsOnly(new Float[] { 4.0f, 7.0f }, withPrecision(0.2f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.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.- Since:
- 3.19.0
-
containsOnlyOnce
public SELF containsOnlyOnce(float... values)
Verifies that the actual array contains the given values only once.If you want to set a precision for the comparison either use
containsOnlyOnce(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Examples :
// assertions will pass assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(1.0f, 2.0f) .usingComparatorWithPrecision(0.5f) .containsOnlyOnce(1.1f, 3.1f, 2.1f); // assertions will fail assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(1.0f); assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(1.0f, 2.0f); assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(4.0f); assertThat(new float[] { 1.0f, 2.0f, 3.0f }).usingComparatorWithPrecision(0.05f) .containsOnlyOnce(1.1f, 2.1f);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.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.
-
containsOnlyOnce
public SELF containsOnlyOnce(Float[] values)
Verifies that the actual array contains the values of the given array only once.Examples :
// assertion will pass assertThat(new float[] { 1.0f, 2.0f }).containsOnlyOnce(new Float[] { 1.0f, 2.0f }); // assertions will fail assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(new Float[] { 1.0f }); assertThat(new float[] { 1.0f }).containsOnlyOnce(new Float[] { 2.0f }); assertThat(new float[] { 1.0f }).containsOnlyOnce(new Float[] { 1.0f, 2.0f });
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.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.- Since:
- 3.19.0
-
containsOnlyOnce
public SELF containsOnlyOnce(float[] values, Offset<Float> precision)
Verifies that the actual array contains the given values only once. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
// assertion will pass assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(new float[] {1.1f, 2.0f}, withPrecision(0.2f)); // assertions will fail assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(new float[] {1.05f}, withPrecision(0.1f)); assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(new float[] {4.0f}, withPrecision(0.1f)); assertThat(new float[] { 1.0f, 2.0f, 3.0f, 3.0f }).containsOnlyOnce(new float[] {0.1f, 0.9f, 2.0f, 3.11f, 4.0f, 5.0f}, withPrecision(0.2f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.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.
-
containsOnlyOnce
public SELF containsOnlyOnce(Float[] values, Offset<Float> precision)
Verifies that the actual array contains the values of the given array only once. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
// assertion will pass assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(new Float[] { 1.1f, 2.0f }, withPrecision(0.2f)); // assertions will fail assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(new Float[] { 1.05f }, withPrecision(0.1f)); assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(new Float[] { 4.0f }, withPrecision(0.1f)); assertThat(new float[] { 1.0f, 2.0f, 3.0f, 3.0f }).containsOnlyOnce(new Float[] { 0.1f, 0.9f, 2.0f, 3.11f, 4.0f, 5.0f }, withPrecision(0.2f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.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.- Since:
- 3.19.0
-
containsSequence
public SELF containsSequence(float... sequence)
Verifies that the actual array contains the given sequence, without any other values between them.If you want to set a precision for the comparison either use
containsSequence(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Examples :
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).containsSequence(1.0f, 2.0f) .containsSequence(1.0f, 2.0f, 3.0f) .containsSequence(2.0f, 3.0f) .usingComparatorWithPrecision(0.5f) .containsSequence(1.1f, 2.1f); // assertions will fail assertThat(values).containsSequence(1.0f, 3.0f); assertThat(values).containsSequence(4.0f, 7.0f); assertThat(values).usingComparatorWithPrecision(0.01f) .containsSequence(1.1f, 2.0f, 3.0f);
- Parameters:
sequence
- the sequence of values to look for.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual array does not contain the given sequence.
-
containsSequence
public SELF containsSequence(Float[] sequence)
Verifies that the actual array contains the given sequence, without any other values between them.Example:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f }).containsSequence(new Float[] { 1.0f, 2.0f }); assertThat(new float[] { 1.0f, 2.0f, 2.0f, 1.0f }).containsSequence(new Float[] { 2.0f, 1.0f }); // assertion will fail assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsSequence(new Float[] { 3.0f, 1.0f });
- Parameters:
sequence
- the sequence of values to look for.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual array does not contain the given sequence.- Since:
- 3.19.0
-
containsSequence
public SELF containsSequence(float[] sequence, Offset<Float> precision)
Verifies that the actual array contains the given sequence, without any other values between them. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertions will pass assertThat(values).containsSequence(new float[] {1.07f, 2.0f}, withPrecision(0.1f)) .containsSequence(new float[] {1.1f, 2.1f, 3.0f}, withPrecision(0.2f)) .containsSequence(new float[] {2.2f, 3.0f}, withPrecision(0.3f)); // assertions will fail assertThat(values).containsSequence(new float[] {1.0f, 3.0f}, withPrecision(0.2f)); assertThat(values).containsSequence(new float[] {4.0f, 7.0f}, withPrecision(0.1f));
- Parameters:
sequence
- the sequence of values to look for.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual array does not contain the given sequence.
-
containsSequence
public SELF containsSequence(Float[] sequence, Offset<Float> precision)
Verifies that the actual array contains the given sequence, without any other values between them. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertions will pass assertThat(values).containsSequence(new Float[] { 1.07f, 2.0f }, withPrecision(0.1f)) .containsSequence(new Float[] { 1.1f, 2.1f, 3.0f }, withPrecision(0.2f)) .containsSequence(new Float[] { 2.2f, 3.0f }, withPrecision(0.3f)); // assertions will fail assertThat(values).containsSequence(new Float[] { 1.0f, 3.0f }, withPrecision(0.2f)); assertThat(values).containsSequence(new Float[] { 4.0f, 7.0f }, withPrecision(0.1f));
- Parameters:
sequence
- the sequence of values to look for.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual array does not contain the given sequence.- Since:
- 3.19.0
-
containsSubsequence
public SELF containsSubsequence(float... subsequence)
Verifies that the actual array contains the given subsequence (possibly with other values between them).If you want to set a precision for the comparison either use
containsSubsequence(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Examples :
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).containsSubsequence(1.0f, 2.0f); .containsSubsequence(1.0f, 2.0f, 3.0f) .containsSubsequence(1.0f, 3.0f) .usingComparatorWithPrecision(0.5f) .containsSubsequence(1.1f, 2.1f); // assertions will fail assertThat(values).containsSubsequence(3.0f, 1.0f); assertThat(values).containsSubsequence(4.0f, 7.0f); assertThat(values).usingComparatorWithPrecision(0.01f) .containsSubsequence(1.1f, 2.0f);
- Parameters:
subsequence
- the subsequence of values to look for.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual array does not contain the given subsequence.
-
containsSubsequence
public SELF containsSubsequence(Float[] subsequence)
Verifies that the actual array contains the given subsequence (possibly with other values between them).Example:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f }).containsSubsequence(new Float[] { 1.0f, 2.0f }); assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).containsSubsequence(new Float[] { 1.0f, 4.0f }); // assertion will fail assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsSubsequence(new Float[] { 3.0f, 1.0f });
- Parameters:
subsequence
- the subsequence of values to look for.- Returns:
- myself assertion object.
- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual array does not contain the given subsequence.- Since:
- 3.19.0
-
containsSubsequence
public SELF containsSubsequence(float[] subsequence, Offset<Float> precision)
Verifies that the actual array contains the given subsequence (possibly with other values between them). The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertions will pass assertThat(values).containsSubsequence(new float[] {1.0f, 2.0f}, withPrecision(0.1f)) .containsSubsequence(new float[] {1.0f, 2.07f, 3.0f}, withPrecision(0.1f)) .containsSubsequence(new float[] {2.1f, 2.9f}, withPrecision(0.2f)); // assertions will fail assertThat(values).containsSubsequence(new float[] {1.0f, 3.0f}, withPrecision(0.1f)); assertThat(values).containsSubsequence(new float[] {4.0f, 7.0f}, withPrecision(0.1f));
- Parameters:
subsequence
- the subsequence of values to look for.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual array does not contain the given subsequence.
-
containsSubsequence
public SELF containsSubsequence(Float[] subsequence, Offset<Float> precision)
Verifies that the actual array contains the given subsequence (possibly with other values between them). The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Examples :
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertions will pass assertThat(values).containsSubsequence(new Float[] { 1.0f, 2.0f }, withPrecision(0.1f)) .containsSubsequence(new Float[] { 1.0f, 2.07f, 3.0f }, withPrecision(0.1f)) .containsSubsequence(new Float[] { 2.1f, 2.9f }, withPrecision(0.2f)); // assertions will fail assertThat(values).containsSubsequence(new Float[] { 1.0f, 3.0f }, withPrecision(0.1f)); assertThat(values).containsSubsequence(new Float[] { 4.0f, 7.0f }, withPrecision(0.1f));
- Parameters:
subsequence
- the subsequence of values to look for.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the given array isnull
.AssertionError
- if the actual array does not contain the given subsequence.- Since:
- 3.19.0
-
contains
public SELF contains(float value, Index index)
Verifies that the actual array contains the given value at the given index.If you want to set a precision for the comparison either use
contains(float, Index, Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Example:
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).contains(1.0f, atIndex(O)) .contains(3.0f, atIndex(2)) .usingComparatorWithPrecision(0.5f) .contains(3.1f, atIndex(2)); // assertions will fail assertThat(values).contains(1.0f, atIndex(1)); assertThat(values).contains(4.0f, atIndex(2)); assertThat(values).usingComparatorWithPrecision(0.01f) .contains(3.1f, atIndex(2));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual array.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
or empty.NullPointerException
- if the givenIndex
isnull
.IndexOutOfBoundsException
- if the value of the givenIndex
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.
-
contains
public SELF contains(float value, Index index, Offset<Float> precision)
Verifies that the actual array contains the given value at the given index. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Example:
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertions will pass assertThat(values).contains(1.0f, atIndex(O), withPrecision(0.01f)) .contains(3.3f, atIndex(2), withPrecision(0.5f)); // assertions will fail assertThat(values).contains(1.0f, atIndex(1), withPrecision(0.2f)); assertThat(values).contains(4.5f, atIndex(2), withPrecision(0.1f));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual array.precision
- the precision which the value may vary.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
or empty.NullPointerException
- if the givenIndex
isnull
.IndexOutOfBoundsException
- if the value of the givenIndex
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.
-
doesNotContain
public SELF doesNotContain(float... values)
Verifies that the actual array does not contain the given values.If you want to set a precision for the comparison either use
doesNotContain(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Example:
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).doesNotContain(4.0f, 8.0f) .usingComparatorWithPrecision(0.0001f) .doesNotContain(1.01f, 2.01f); // assertions will fail assertThat(values).doesNotContain(1.0f, 4.0f, 8.0f); assertThat(values).usingComparatorWithPrecision(0.1f) .doesNotContain(1.001f, 2.001f);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array contains any of the given values.
-
doesNotContain
public SELF doesNotContain(Float[] values)
Verifies that the actual array does not contain the values of the given array.Example:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f }).doesNotContain(new Float[] { 3.0f }); // assertion will fail assertThat(new float[] { 1.0f, 2.0f, 3.0f }).doesNotContain(new Float[] { 1.0f });
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array contains any of the given values.- Since:
- 3.19.0
-
doesNotContain
public SELF doesNotContain(float[] values, Offset<Float> precision)
Verifies that the actual array does not contain the given values. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Example:
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertion will pass assertThat(values).doesNotContain(new float[] {4.0f, 8.0f}, withPrecision(0.5f)); // assertion will fail assertThat(values).doesNotContain(new float[] {1.05f, 4.0f, 8.0f}, withPrecision(0.1f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array contains any of the given values.
-
doesNotContain
public SELF doesNotContain(Float[] values, Offset<Float> precision)
Verifies that the actual array does not contain the values of the given array. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Example:
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).doesNotContain(new Float[] { 4.0f, 8.0f }, withPrecision(0.5f)); // assertion will fail assertThat(values).doesNotContain(new Float[] { 1.05f, 4.0f, 8.0f }, withPrecision(0.1f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array contains any of the given values.- Since:
- 3.19.0
-
doesNotContain
public SELF doesNotContain(float value, Index index)
Verifies that the actual array does not contain the given value at the given index.If you want to set a precision for the comparison either use
doesNotContain(float, Index, Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Example:
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).doesNotContain(1.0f, atIndex(1)) .doesNotContain(2.0f, atIndex(0)) .usingComparatorWithPrecision(0.001) .doesNotContain(1.1f, atIndex(0)); // assertions will fail assertThat(values).doesNotContain(1.0f, atIndex(0)); assertThat(values).usingComparatorWithPrecision(0.1) .doesNotContain(1.001f, atIndex(0));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual array.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actual array contains the given value at the given index.
-
doesNotContain
public SELF doesNotContain(float value, Index index, Offset<Float> precision)
Verifies that the actual array does not contain the given value at the given index. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Example:
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertions will pass assertThat(values).doesNotContain(1.01f, atIndex(1), withPrecision(0.0001f)) .doesNotContain(2.05f, atIndex(0), withPrecision(0.1f)); // assertion will fail assertThat(values).doesNotContain(1.01f, atIndex(0), withPrecision(0.1f));
- Parameters:
value
- the value to look for.index
- the index where the value should be stored in the actual array.precision
- the precision under which the value may vary.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.NullPointerException
- if the givenIndex
isnull
.AssertionError
- if the actual array contains the given value at the given index.
-
doesNotHaveDuplicates
public SELF doesNotHaveDuplicates()
Verifies that the actual array does not contain duplicates.If you want to set a precision for the comparison either use
doesNotHaveDuplicates(Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Example:
// assertions will pass assertThat(new float[] { 1.0f, 2.0f, 3.0f }).doesNotHaveDuplicates(); assertThat(new float[] { 1.0f, 1.1f }).usingComparatorWithPrecision(0.01f) .doesNotHaveDuplicates(); // assertions will fail assertThat(new float[] { 1.0f, 1.0f, 2.0f, 3.0f }).doesNotHaveDuplicates(); assertThat(new float[] { 1.0f, 1.1f }).usingComparatorWithPrecision(0.5f) .doesNotHaveDuplicates();
- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the actual array contains duplicates.
-
doesNotHaveDuplicates
public SELF doesNotHaveDuplicates(Offset<Float> precision)
Verifies that the actual array does not contain duplicates. The comparison is done at the given precision/offset set withAssertions.withPrecision(Float)
.Example:
// assertions will pass assertThat(new float[] {1.0f, 2.0f, 3.0f}).doesNotHaveDuplicates(withPrecision(0.1f)); assertThat(new float[] {1.1f, 1.2f, 1.3f}).doesNotHaveDuplicates(withPrecision(0.05f)); // assertion will fail assertThat(new float[] {1.0f, 1.01f, 2.0f}).doesNotHaveDuplicates(withPrecision(0.1f));
- Parameters:
precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
AssertionError
- if the actual array isnull
.AssertionError
- if the actual array contains duplicates.
-
startsWith
public SELF startsWith(float... sequence)
Verifies that the actual 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 first element of the actual array.containsSequence(float...)
If you want to set a precision for the comparison either use
startsWith(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Example:
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).startsWith(1.0f, 2.0f) .usingComparatorWithPrecision(0.5f) .startsWith(1.1f, 2.1f); // assertion will fail assertThat(values).startsWith(2.0f, 3.0f);
- Parameters:
sequence
- the sequence of values to look for.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not start with the given sequence.
-
startsWith
public SELF startsWith(Float[] sequence)
Verifies that the actual 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 first element of the actual array.containsSequence(Float[])
Example:
// assertion will pass assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).startsWith(new Float[] { 1.0f, 2.0f }); // assertion will fail assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).startsWith(new Float[] { 2.0f, 3.0f, 4.0f });
- Parameters:
sequence
- the sequence of values to look for.- Returns:
- myself assertion object.
- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not start with the given sequence.- Since:
- 3.19.0
-
startsWith
public SELF startsWith(float[] values, Offset<Float> precision)
Verifies that the actual 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 first element of the actual array.containsSequence(float...)
The comparison is done at the given precision/offset set with
Assertions.withPrecision(Float)
.Example:
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertion will pass assertThat(values).startsWith(new float[] {1.01f, 2.01f}, withPrecision(0.1f)); // assertions will fail assertThat(values).startsWith(new float[] {2.0f, 1.0f}, withPrecision(0.1f)) assertThat(values).startsWith(new float[] {1.1f, 2.1f}, withPrecision(0.5f))
- Parameters:
values
- the sequence of values to look for.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not end with the given sequence.
-
startsWith
public SELF startsWith(Float[] values, Offset<Float> precision)
Verifies that the actual 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 first element of the actual array.containsSequence(float...)
The comparison is done at the given precision/offset set with
Assertions.withPrecision(Float)
.Example:
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).startsWith(new Float[] { 1.01f, 2.01f }, withPrecision(0.1f)); // assertions will fail assertThat(values).startsWith(new Float[] { 2.0f, 1.0f }, withPrecision(0.1f)) assertThat(values).startsWith(new Float[] { 1.1f, 2.1f }, withPrecision(0.5f))
- Parameters:
values
- the sequence of values to look for.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not end with the given sequence.- Since:
- 3.19.0
-
endsWith
public SELF endsWith(float... sequence)
Verifies that the actual 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 last element of the actual array.containsSequence(float...)
If you want to set a precision for the comparison either use
endsWith(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Example:
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).endsWith(2.0f, 3.0f) .usingComparatorWithPrecision(0.5f) .endsWith(2.1f, 3.1f); // assertion will fail assertThat(values).endsWith(1.0f, 3.0f);
- Parameters:
sequence
- the sequence of values to look for.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not end with the given sequence.
-
endsWith
public SELF endsWith(Float[] sequence)
Verifies that the actual 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 last element of the actual array.containsSequence(Float[])
Example:
// assertion will pass assertThat(new boolean[] { 1.0f, 2.0f, 3.0f, 4.0f }).endsWith(new Float[] { 3.0f, 4.0f }); // assertion will fail assertThat(new boolean[] { 1.0f, 2.0f, 3.0f, 4.0f }).endsWith(new Float[] { 2.0f, 3.0f });
- Parameters:
sequence
- the sequence of values to look for.- Returns:
- myself assertion object.
- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not end with the given sequence.- Since:
- 3.19.0
-
endsWith
public SELF endsWith(float[] values, Offset<Float> precision)
Verifies that the actual 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 last element of the actual array.containsSequence(float...)
The comparison is done at the given precision/offset set with
Assertions.withPrecision(Float)
.Example:
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertion will pass assertThat(values).endsWith(new float[] {2.01f, 3.01f}, withPrecision(0.1f)); // assertions will fail assertThat(values).endsWith(new float[] {3.0f, 2.0f}, withPrecision(0.1f)) assertThat(values).endsWith(new float[] {2.1f, 3.1f}, withPrecision(0.5f))
- Parameters:
values
- the sequence of values to look for.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not end with the given sequence.
-
endsWith
public SELF endsWith(Float[] values, Offset<Float> precision)
Verifies that the actual 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 last element of the actual array.containsSequence(float...)
The comparison is done at the given precision/offset set with
Assertions.withPrecision(Float)
.Example:
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).endsWith(new Float[] { 2.01f, 3.01f }, withPrecision(0.1f)); // assertions will fail assertThat(values).endsWith(new Float[] { 3.0f, 2.0f }, withPrecision(0.1f)) assertThat(values).endsWith(new Float[] { 2.1f, 3.1f }, withPrecision(0.5f))
- Parameters:
values
- the sequence of values to look for.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.IllegalArgumentException
- if the given argument is an empty array.AssertionError
- if the actual array isnull
.AssertionError
- if the actual array does not end with the given sequence.- Since:
- 3.19.0
-
isSorted
public SELF isSorted()
Verifies that the actual array is sorted in ascending order according to the natural ordering of its elements.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 :- a array composed of {2, 4, 6} is ok because the element type is a primitive type.
- a array composed of {"a1", "a2", "a3"} is ok because the element type (String) is Comparable
- a array composed of Rectangle {r1, r2, r3} is NOT ok because Rectangle is not Comparable
- a array composed of {True, "abc", False} is NOT ok because elements are not mutually comparable (even though each element type implements Comparable)
- Returns:
this
assertion object.
-
isSortedAccordingTo
public SELF isSortedAccordingTo(Comparator<? super Float> 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.- Parameters:
comparator
- theComparator
used to compare array elements- Returns:
this
assertion object.
-
usingElementComparator
public SELF usingElementComparator(Comparator<? super Float> customComparator)
Use given custom comparator instead of relying on actual type Aequals
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);
- Parameters:
customComparator
- the comparator to use for incoming assertion checks.- Returns:
this
assertion object.
-
usingDefaultElementComparator
public SELF usingDefaultElementComparator()
Revert to standard comparison for incoming assertion group element checks.This method should be used to disable a custom comparison strategy set by calling
EnumerableAssert.usingElementComparator(Comparator)
.- Returns:
this
assertion object.
-
containsExactly
public SELF containsExactly(float... values)
Verifies that the actual group contains only the given values and nothing else, in order.If you want to set a precision for the comparison either use
containsExactly(float[], Offset)
orusingComparatorWithPrecision(Float)
before calling the assertion.Example :
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).containsExactly(1.0f, 2.0f, 3.0f) .usingComparatorWithPrecision(0.2f) .containsExactly(1.1f, 2.1f, 2.9f); // assertion will fail as actual and expected order differ assertThat(values).containsExactly(2.0f, 1.0f, 3.0f);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual group isnull
.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.
-
containsExactly
public SELF containsExactly(Float[] values)
Verifies that the actual group contains only the values of the given array and nothing else, in order.Example :
// assertion will pass assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).containsExactly(new Float[] { 1.0f, 2.0f, 3.0f, 4.0f }); // assertion will fail as actual and expected order differ assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).containsExactly(new Float[] { 1.0f, 5.0f });
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual group isnull
.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.- Since:
- 3.19.0
-
containsExactly
public SELF containsExactly(float[] values, Offset<Float> precision)
Verifies that the actual group contains only the given values and nothing else, in order. The values may vary with a specified precision.Example :
float[] values = new float[] {1.0f, 2.0f, 3.0f}; // assertion will pass assertThat(values).containsExactly(new float[] {1.0f, 1.98f, 3.01f}, withPrecision(0.05f)); // assertion fails because |1.0 - 1.1| > 0.05 (precision) assertThat(values).containsExactly(new float[] {1.1f, 2.0f, 3.01f}, withPrecision(0.05f)); // assertion will fail as actual and expected order differ assertThat(values).containsExactly(new float[] {1.98f, 1.0f, 3.01f}, withPrecision(0.05f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not contain the given values within the specified precision 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.
-
containsExactly
public SELF containsExactly(Float[] values, Offset<Float> precision)
Verifies that the actual group contains only the values of the given array and nothing else, in order. The values may vary with a specified precision.Example :
float[] values = new float[] { 1.0f, 2.0f, 3.0f }; // assertion will pass assertThat(values).containsExactly(new Float[] { 1.0f, 1.98f, 3.01f }, withPrecision(0.05f)); // assertion fails because |1.0 - 1.1| > 0.05 (precision) assertThat(values).containsExactly(new Float[] { 1.1f, 2.0f, 3.01f }, withPrecision(0.05f)); // assertion will fail as actual and expected order differ assertThat(values).containsExactly(new Float[] { 1.98f, 1.0f, 3.01f }, withPrecision(0.05f));
- Parameters:
values
- the given values.precision
- the precision under which the values may vary.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual group isnull
.AssertionError
- if the actual group does not contain the given values within the specified precision 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.- Since:
- 3.19.0
-
containsExactlyInAnyOrder
public SELF containsExactlyInAnyOrder(float... values)
Verifies that the actual group contains exactly the given values and nothing else, in any order.
Example :
// assertions will pass assertThat(new float[] { 1.0F, 2.0F }).containsExactlyInAnyOrder(1.0F, 2.0F); assertThat(new float[] { 1.0F, 2.0F, 1.0F }).containsExactlyInAnyOrder(1.0F, 1.0F, 2.0F); // assertions will fail assertThat(new float[] { 1.0F, 2.0F }).containsExactlyInAnyOrder(1.0F); assertThat(new float[] { 1.0F }).containsExactlyInAnyOrder(1.0F, 2.0F); assertThat(new float[] { 1.0F, 2.0F, 1.0F }).containsExactlyInAnyOrder(1.0F, 2.0F);
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual group isnull
.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.- Since:
- 2.6.0 / 3.6.0
-
containsExactlyInAnyOrder
public SELF containsExactlyInAnyOrder(Float[] values)
Verifies that the actual group contains exactly the values of the given array and nothing else, in any order.
Example :
// assertions will pass assertThat(new float[] { 1.0f, 2.0f }).containsExactlyInAnyOrder(new Float[] { 2.0f, 1.0f }); assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(new Float[] { 3.0f, 1.0f, 2.0f }); // assertions will fail assertThat(new float[] { 1.0f, 2.0f }).containsExactlyInAnyOrder(new Float[] { 1.0f }); assertThat(new float[] { 1.0f}).containsExactlyInAnyOrder(new Float[] { 2.0f, 1.0f }); assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(new Float[] { 2.0f, 1.0f });
- Parameters:
values
- the given values.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the given argument isnull
.AssertionError
- if the actual group isnull
.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.- Since:
- 3.19.0
-
usingComparatorWithPrecision
public SELF usingComparatorWithPrecision(Float precision)
Create aFloat
comparator which compares floats at the given precision and pass it tousingElementComparator(Comparator)
. All the following assertions will use this comparator to compare float[] elements.- Parameters:
precision
- precision used to compareFloat
.- Returns:
this
assertion object.
-
containsAnyOf
public SELF containsAnyOf(float... values)
Verifies that the actual array contains at least one of the given values.Example :
float[] oneTwoThree = { 1.0f, 2.0f, 3.0f }; // assertions will pass assertThat(oneTwoThree).containsAnyOf(2.0f) .containsAnyOf(2.0f, 3.0f) .containsAnyOf(1.0f, 2.0f, 3.0f) .containsAnyOf(1.0f, 2.0f, 3.0f, 4.0f) .containsAnyOf(5.0f, 6.0f, 7.0f, 2.0f); // assertions will fail assertThat(oneTwoThree).containsAnyOf(4.0f); assertThat(oneTwoThree).containsAnyOf(4.0f, 5.0f, 6.0f, 7.0f);
- Parameters:
values
- the values whose at least one which is expected to be in the array under test.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty and the array under test is not empty.AssertionError
- if the array under test isnull
.AssertionError
- if the array under test does not contain any of the givenvalues
.- Since:
- 2.9.0 / 3.9.0
-
containsAnyOf
public SELF containsAnyOf(Float[] values)
Verifies that the actual array contains at least one of the values of the given array.Example :
float[] soFloats = { 1.0f, 2.0f, 3.0f }; // assertions will pass assertThat(soFloats).containsAnyOf(new Float[] { 1.0f }) .containsAnyOf(new Float[] { 3.0f, 4.0f, 5.0f, 6.0f }); // assertions will fail assertThat(soFloats).containsAnyOf(new Float[] { 8.0f }); assertThat(soFloats).containsAnyOf(new Float[] { 11.0f, 15.0f, 420.0f });
- Parameters:
values
- the values whose at least one which is expected to be in the array under test.- Returns:
this
assertion object.- Throws:
NullPointerException
- if the array of values isnull
.IllegalArgumentException
- if the array of values is empty and the array under test is not empty.AssertionError
- if the array under test isnull
.AssertionError
- if the array under test does not contain any of the givenvalues
.- Since:
- 3.19.0
-
toPrimitiveFloatArray
private static float[] toPrimitiveFloatArray(Float[] values)
-
-