/** * Verifies that the actual array does not contain the given value at the given index. * * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public LongArrayAssert doesNotContain(long value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; }
/** {@inheritDoc} */ @Override public S isNotEmpty() { arrays.assertNotEmpty(info, actual); return myself; }
/** {@inheritDoc} */ @Override public S hasSameSizeAs(Iterable<?> other) { arrays.assertHasSameSizeAs(info, actual, other); return myself; }
/** {@inheritDoc} */ @Override public S isSorted() { arrays.assertIsSorted(info, actual); return myself; }
/** {@inheritDoc} */ @Override public S usingDefaultElementComparator() { this.arrays = LongArrays.instance(); return myself; }
/** * Verifies that the actual array does not contain duplicates. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1L, 2L, 3L }).doesNotHaveDuplicates(); * * // assertion will fail * assertThat(new long[] { 1L, 1L, 2L, 3L }).doesNotHaveDuplicates();</code></pre> * * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public S doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return myself; }
/** {@inheritDoc} */ @Override public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); }
/** * Assertion methods for arrays of {@code long}s. * * <p>To create an instance of this class, invoke <code>{@link Assertions#assertThat(long[])}</code> * . * * @author Yvonne Wang * @author Alex Ruiz * @author Joel Costigliola * @author Mikhail Mazursky * @author Nicolas François */ public class LongArrayAssert extends AbstractAssert<LongArrayAssert, long[]> implements EnumerableAssert<LongArrayAssert, Long>, ArraySortedAssert<LongArrayAssert, Long> { @VisibleForTesting LongArrays arrays = LongArrays.instance(); protected LongArrayAssert(long[] actual) { super(actual, LongArrayAssert.class); } /** {@inheritDoc} */ public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ public LongArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; } /** {@inheritDoc} */ public LongArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; } /** {@inheritDoc} */ public LongArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** {@inheritDoc} */ public LongArrayAssert hasSameSizeAs(Iterable<?> other) { arrays.assertHasSameSizeAs(info, actual, other); return this; } /** * Verifies that the actual array contains the given values, in any order. * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public LongArrayAssert contains(long... values) { arrays.assertContains(info, actual, values); return this; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws 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 LongArrayAssert containsOnly(long... values) { arrays.assertContainsOnly(info, actual, values); return this; } /** * Verifies that the actual array contains the given sequence, without any other values between * them. * * @param sequence the sequence of values to look for. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public LongArrayAssert containsSequence(long... sequence) { arrays.assertContainsSequence(info, actual, sequence); return this; } /** * Verifies that the actual array contains the given value at the given index. * * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or * greater than the size of the actual array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public LongArrayAssert contains(long value, Index index) { arrays.assertContains(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain the given values. * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public LongArrayAssert doesNotContain(long... values) { arrays.assertDoesNotContain(info, actual, values); return this; } /** * Verifies that the actual array does not contain the given value at the given index. * * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return this assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public LongArrayAssert doesNotContain(long value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return this; } /** * Verifies that the actual array does not contain duplicates. * * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public LongArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; } /** * Verifies that the actual array starts with the given sequence of values, without any other * values between them. Similar to <code>{@link #containsSequence(long...)}</code>, but it also * verifies that the first element in the sequence is also first element of the actual array. * * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public LongArrayAssert startsWith(long... sequence) { arrays.assertStartsWith(info, actual, sequence); return this; } /** * Verifies that the actual array ends with the given sequence of values, without any other values * between them. Similar to <code>{@link #containsSequence(long...)}</code>, but it also verifies * that the last element in the sequence is also last element of the actual array. * * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public LongArrayAssert endsWith(long... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; } /** {@inheritDoc} */ public LongArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; } /** {@inheritDoc} */ public LongArrayAssert isSortedAccordingTo(Comparator<? super Long> comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; } /** {@inheritDoc} */ public LongArrayAssert usingElementComparator(Comparator<? super Long> customComparator) { this.arrays = new LongArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ public LongArrayAssert usingDefaultElementComparator() { this.arrays = LongArrays.instance(); return myself; } }
/** {@inheritDoc} */ public LongArrayAssert isNotEmpty() { arrays.assertNotEmpty(info, actual); return this; }
/** {@inheritDoc} */ public LongArrayAssert isSortedAccordingTo(Comparator<? super Long> comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return this; }
/** {@inheritDoc} */ public LongArrayAssert usingDefaultElementComparator() { this.arrays = LongArrays.instance(); return myself; }
/** {@inheritDoc} */ public LongArrayAssert isSorted() { arrays.assertIsSorted(info, actual); return this; }
/** * Verifies that the actual array ends with the given sequence of values, without any other values * between them. Similar to <code>{@link #containsSequence(long...)}</code>, but it also verifies * that the last element in the sequence is also last element of the actual array. * * @param sequence the sequence of values to look for. * @return this assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public LongArrayAssert endsWith(long... sequence) { arrays.assertEndsWith(info, actual, sequence); return this; }
/** * Verifies that the actual array does not contain duplicates. * * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public LongArrayAssert doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return this; }
/** * Verifies that the actual array does not contain the given values. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(4L); * * // assertion will fail * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(2L);</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public S doesNotContain(long... values) { arrays.assertDoesNotContain(info, actual, values); return myself; }
/** {@inheritDoc} */ public LongArrayAssert hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return this; }
/** * Verifies that the actual array does not contain the given value at the given index. * * <p>Example: * * <pre><code class='java'> // assertions will pass * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(1L, atIndex(1)); * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(2L, atIndex(0)); * * // assertions will fail * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(1L, atIndex(0)); * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(2L, atIndex(1));</code></pre> * * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public S doesNotContain(long value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return myself; }
/** {@inheritDoc} */ public LongArrayAssert hasSameSizeAs(Object[] other) { arrays.assertHasSameSizeAs(info, actual, other); return this; }
/** * Verifies that the actual array starts with the given sequence of values, without any other * values between them. Similar to <code>{@link #containsSequence(long...)}</code>, but it also * verifies that the first element in the sequence is also first element of the actual array. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1L, 2L, 3L }).startsWith(1L, 2L); * * // assertion will fail * assertThat(new long[] { 1L, 2L, 3L }).startsWith(2L, 3L);</code></pre> * * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public S startsWith(long... sequence) { arrays.assertStartsWith(info, actual, sequence); return myself; }
/** {@inheritDoc} */ public LongArrayAssert hasSameSizeAs(Iterable<?> other) { arrays.assertHasSameSizeAs(info, actual, other); return this; }
/** * Verifies that the actual array ends with the given sequence of values, without any other values * between them. Similar to <code>{@link #containsSequence(long...)}</code>, but it also verifies * that the last element in the sequence is also last element of the actual array. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1L, 2L, 3L }).endsWith(2L, 3L); * * // assertion will fail * assertThat(new long[] { 1L, 2L, 3L }).endsWith(3L, 4L);</code></pre> * * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public S endsWith(long... sequence) { arrays.assertEndsWith(info, actual, sequence); return myself; }
/** * Verifies that the actual array contains the given values, in any order. * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public LongArrayAssert contains(long... values) { arrays.assertContains(info, actual, values); return this; }
/** {@inheritDoc} */ @Override public S isSortedAccordingTo(Comparator<? super Long> comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return myself; }
/** * Verifies that the actual array contains the given subsequence (possibly with other values * between them). * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1, 2, 3 }).containsSubsequence(1, 2); * assertThat(new long[] { 1, 2, 3 }).containsSubsequence(1, 3); * * // assertion will fail * assertThat(new long[] { 1, 2, 3 }).containsSubsequence(2, 1);</code></pre> * * @param subsequence the subsequence of values to look for. * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given subsequence. */ public S containsSubsequence(long... subsequence) { arrays.assertContainsSubsequence(info, actual, subsequence); return myself; }
/** {@inheritDoc} */ @Override public void isEmpty() { arrays.assertEmpty(info, actual); }
/** * Verifies that the actual array contains the given value at the given index. * * <p>Example: * * <pre><code class='java'> // assertions will pass * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, atIndex(O)); * assertThat(new long[] { 1L, 2L, 3L }).contains(3L, atIndex(2)); * * // assertions will fail * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, atIndex(1)); * assertThat(new long[] { 1L, 2L, 3L }).contains(4L, atIndex(2));</code></pre> * * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return myself assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or * greater than the size of the actual array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public S contains(long value, Index index) { arrays.assertContains(info, actual, value, index); return myself; }
/** {@inheritDoc} */ @Override public S hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return myself; }
public abstract class AbstractLongArrayAssert<S extends AbstractLongArrayAssert<S>> extends AbstractArrayAssert<S, long[], Long> { @VisibleForTesting protected LongArrays arrays = LongArrays.instance(); public AbstractLongArrayAssert(long[] actual, Class<?> selfType) { super(actual, selfType); } /** {@inheritDoc} */ @Override public void isNullOrEmpty() { arrays.assertNullOrEmpty(info, actual); } /** {@inheritDoc} */ @Override public void isEmpty() { arrays.assertEmpty(info, actual); } /** {@inheritDoc} */ @Override public S isNotEmpty() { arrays.assertNotEmpty(info, actual); return myself; } /** {@inheritDoc} */ @Override public S hasSize(int expected) { arrays.assertHasSize(info, actual, expected); return myself; } /** {@inheritDoc} */ @Override public S hasSameSizeAs(Iterable<?> other) { arrays.assertHasSameSizeAs(info, actual, other); return myself; } /** * Verifies that the actual array contains the given values, in any order. * * <p>Example: * * <pre><code class='java'> // assertions will pass * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, 2L); * assertThat(new long[] { 1L, 2L, 3L }).contains(3L, 1L); * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, 3L, 2L); * * // assertions will fail * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, 4L); * assertThat(new long[] { 1L, 2L, 3L }).contains(4L, 7L);</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public S contains(long... values) { arrays.assertContains(info, actual, values); return myself; } /** * Verifies that the actual array contains only the given values and nothing else, in any order. * * <p>Example: * * <pre><code class='java'> // assertions will pass * assertThat(new long[] { 1L, 2L, 3L }).containsOnly(1L, 2L, 3L); * assertThat(new long[] { 1L, 2L, 3L }).containsOnly(2L, 3L, 1L); * * // assertions will fail * assertThat(new long[] { 1L, 2L, 3L }).containsOnly(1L, 2L, 3L, 4L); * assertThat(new long[] { 1L, 2L, 3L }).containsOnly(4L, 7L);</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws 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 S containsOnly(long... values) { arrays.assertContainsOnly(info, actual, values); return myself; } /** * Verifies that the actual array contains the given values only once. * * <p>Examples : * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1, 2, 3 }).containsOnlyOnce(1, 2); * * // assertions will fail * assertThat(new long[] { 1, 2, 1 }).containsOnlyOnce(1); * assertThat(new long[] { 1, 2, 3 }).containsOnlyOnce(4); * assertThat(new long[] { 1, 2, 3, 3 }).containsOnlyOnce(0, 1, 2, 3, 4, 5);</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual group does not contain the given values, i.e. the actual * group contains some or none of the given values, or the actual group contains more than * once these values. */ public S containsOnlyOnce(long... values) { arrays.assertContainsOnlyOnce(info, actual, values); return myself; } /** * Verifies that the actual array contains the given sequence, without any other values between * them. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1, 2, 3 }).containsSequence(1, 2); * * // assertion will fail * assertThat(new long[] { 1, 2, 3 }).containsSequence(1, 3); * assertThat(new long[] { 1, 2, 3 }).containsSequence(2, 1);</code></pre> * * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given sequence. */ public S containsSequence(long... sequence) { arrays.assertContainsSequence(info, actual, sequence); return myself; } /** * Verifies that the actual array contains the given subsequence (possibly with other values * between them). * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1, 2, 3 }).containsSubsequence(1, 2); * assertThat(new long[] { 1, 2, 3 }).containsSubsequence(1, 3); * * // assertion will fail * assertThat(new long[] { 1, 2, 3 }).containsSubsequence(2, 1);</code></pre> * * @param subsequence the subsequence of values to look for. * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the given array is {@code null}. * @throws AssertionError if the actual array does not contain the given subsequence. */ public S containsSubsequence(long... subsequence) { arrays.assertContainsSubsequence(info, actual, subsequence); return myself; } /** * Verifies that the actual array contains the given value at the given index. * * <p>Example: * * <pre><code class='java'> // assertions will pass * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, atIndex(O)); * assertThat(new long[] { 1L, 2L, 3L }).contains(3L, atIndex(2)); * * // assertions will fail * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, atIndex(1)); * assertThat(new long[] { 1L, 2L, 3L }).contains(4L, atIndex(2));</code></pre> * * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return myself assertion object. * @throws AssertionError if the actual array is {@code null} or empty. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or * greater than the size of the actual array. * @throws AssertionError if the actual array does not contain the given value at the given index. */ public S contains(long value, Index index) { arrays.assertContains(info, actual, value, index); return myself; } /** * Verifies that the actual array does not contain the given values. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(4L); * * // assertion will fail * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(2L);</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public S doesNotContain(long... values) { arrays.assertDoesNotContain(info, actual, values); return myself; } /** * Verifies that the actual array does not contain the given value at the given index. * * <p>Example: * * <pre><code class='java'> // assertions will pass * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(1L, atIndex(1)); * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(2L, atIndex(0)); * * // assertions will fail * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(1L, atIndex(0)); * assertThat(new long[] { 1L, 2L, 3L }).doesNotContain(2L, atIndex(1));</code></pre> * * @param value the value to look for. * @param index the index where the value should be stored in the actual array. * @return myself assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws NullPointerException if the given {@code Index} is {@code null}. * @throws AssertionError if the actual array contains the given value at the given index. */ public S doesNotContain(long value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return myself; } /** * Verifies that the actual array does not contain duplicates. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1L, 2L, 3L }).doesNotHaveDuplicates(); * * // assertion will fail * assertThat(new long[] { 1L, 1L, 2L, 3L }).doesNotHaveDuplicates();</code></pre> * * @return {@code this} assertion object. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains duplicates. */ public S doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return myself; } /** * Verifies that the actual array starts with the given sequence of values, without any other * values between them. Similar to <code>{@link #containsSequence(long...)}</code>, but it also * verifies that the first element in the sequence is also first element of the actual array. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1L, 2L, 3L }).startsWith(1L, 2L); * * // assertion will fail * assertThat(new long[] { 1L, 2L, 3L }).startsWith(2L, 3L);</code></pre> * * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not start with the given sequence. */ public S startsWith(long... sequence) { arrays.assertStartsWith(info, actual, sequence); return myself; } /** * Verifies that the actual array ends with the given sequence of values, without any other values * between them. Similar to <code>{@link #containsSequence(long...)}</code>, but it also verifies * that the last element in the sequence is also last element of the actual array. * * <p>Example: * * <pre><code class='java'> // assertion will pass * assertThat(new long[] { 1L, 2L, 3L }).endsWith(2L, 3L); * * // assertion will fail * assertThat(new long[] { 1L, 2L, 3L }).endsWith(3L, 4L);</code></pre> * * @param sequence the sequence of values to look for. * @return myself assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not end with the given sequence. */ public S endsWith(long... sequence) { arrays.assertEndsWith(info, actual, sequence); return myself; } /** {@inheritDoc} */ @Override public S isSorted() { arrays.assertIsSorted(info, actual); return myself; } /** {@inheritDoc} */ @Override public S isSortedAccordingTo(Comparator<? super Long> comparator) { arrays.assertIsSortedAccordingToComparator(info, actual, comparator); return myself; } /** {@inheritDoc} */ @Override public S usingElementComparator(Comparator<? super Long> customComparator) { this.arrays = new LongArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; } /** {@inheritDoc} */ @Override public S usingDefaultElementComparator() { this.arrays = LongArrays.instance(); return myself; } /** * Verifies that the actual group contains only the given values and nothing else, <b>in * order</b>. * * <p>Example : * * <pre><code class='java'> long[] longs = { 1, 2, 3 }; * * // assertion will pass * assertThat(longs).containsExactly(1, 2, 3); * * // assertion will fail as actual and expected order differ * assertThat(longs).containsExactly(2, 1, 3);</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws AssertionError if the actual group is {@code null}. * @throws AssertionError if the actual group does not contain the given values with same order, * i.e. the actual group contains some or none of the given values, or the actual group * contains more values than the given ones or values are the same but the order is not. */ public S containsExactly(long... values) { objects.assertEqual(info, actual, values); return myself; } }
/** * Verifies that the actual array contains the given values, in any order. * * <p>Example: * * <pre><code class='java'> // assertions will pass * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, 2L); * assertThat(new long[] { 1L, 2L, 3L }).contains(3L, 1L); * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, 3L, 2L); * * // assertions will fail * assertThat(new long[] { 1L, 2L, 3L }).contains(1L, 4L); * assertThat(new long[] { 1L, 2L, 3L }).contains(4L, 7L);</code></pre> * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array does not contain the given values. */ public S contains(long... values) { arrays.assertContains(info, actual, values); return myself; }
/** * Verifies that the actual array does not contain the given values. * * @param values the given values. * @return {@code this} assertion object. * @throws NullPointerException if the given argument is {@code null}. * @throws IllegalArgumentException if the given argument is an empty array. * @throws AssertionError if the actual array is {@code null}. * @throws AssertionError if the actual array contains any of the given values. */ public LongArrayAssert doesNotContain(long... values) { arrays.assertDoesNotContain(info, actual, values); return this; }