/** * Verifies that the actual array contains the given values, in any order. * <p> * Example: * <pre><code class='java'> // assertion will pass * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, (byte) 2); * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 3, (byte) 1); * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, (byte) 3, (byte) 2); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, (byte) 4); * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 4, (byte) 7);</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 SELF contains(byte... 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 byte[] { 1, 2, 3 }).containsOnly((byte) 1, (byte) 2, (byte) 3); * assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 2, (byte) 3, (byte) 1); * assertThat(new byte[] { 1, 1, 2 }).containsOnly((byte) 1, (byte) 2); * * // assertions will fail * assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 1, (byte) 2, (byte) 3, (byte) 4); * assertThat(new byte[] { 1, 2, 3 }).containsOnly((byte) 4, (byte) 7);</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 SELF containsOnly(byte... 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 byte[] { 1, 2, 3 }).containsOnlyOnce((byte) 1, (byte) 2); * * // assertions will fail * assertThat(new byte[] { 1, 2, 1 }).containsOnlyOnce((byte) 1); * assertThat(new byte[] { 1, 2, 3 }).containsOnlyOnce((byte) 4); * assertThat(new byte[] { 1, 2, 3, 3 }).containsOnlyOnce((byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 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 SELF containsOnlyOnce(byte... values) { arrays.assertContainsOnlyOnce(info, actual, values); return myself; }
/** * Verifies that the actual array does not contain the given values. * <p> * Example: * <pre><code class='java'> // assertion will pass * assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 4); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 2);</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 SELF doesNotContain(byte... values) { arrays.assertDoesNotContain(info, actual, values); 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(byte...)}</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 byte[] { 1, 2, 3 }).endsWith((byte) 2, (byte) 3); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).endsWith((byte) 3, (byte) 4);</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 SELF endsWith(byte... sequence) { arrays.assertEndsWith(info, actual, sequence); 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 byte[] { 1, 2, 3 }).containsSequence(1, 2); * assertThat(new byte[] { 1, 2, 3 }).containsSequence(1, 2, 3); * assertThat(new byte[] { 1, 2, 3 }).containsSequence(2, 3); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).containsSequence(1, 3); * assertThat(new byte[] { 1, 2, 3 }).containsSequence(4, 7);</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. * @since 2.6.0 / 3.6.0 */ public SELF containsSequence(int... 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 byte[] { 1, 2, 3 }).containsSubsequence((byte) 1, (byte) 2, (byte) 3); * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 1, (byte) 2); * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 1, (byte) 3); * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 2, (byte) 3); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 2, (byte) 1); * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence((byte) 4, (byte) 7);</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 SELF containsSubsequence(byte... subsequence) { arrays.assertContainsSubsequence(info, actual, subsequence); return myself; }
/** {@inheritDoc} */ @Override @CheckReturnValue public SELF usingElementComparator(Comparator<? super Byte> customComparator) { this.arrays = new ByteArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; }
/** {@inheritDoc} */ @Override public void isEmpty() { arrays.assertEmpty(info, actual); }
/** * Verifies that the actual array does not contain duplicates. * <p> * Example: * <pre><code class='java'> // assertion will pass * assertThat(new byte[] { 1, 2, 3 }).doesNotHaveDuplicates(); * * // assertion will fail * assertThat(new byte[] { 1, 1, 2, 3 }).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 SELF doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return myself; }
/** * Verifies that the actual array does not contain the given values. * <p> * Example: * <pre><code class='java'> // assertion will pass * assertThat(new byte[] { 1, 2, 3 }).doesNotContain(4); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).doesNotContain(2);</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. * @since 2.6.0 / 3.6.0 */ public SELF doesNotContain(int... values) { arrays.assertDoesNotContain(info, actual, values); 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(byte...)}</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 byte[] { 1, 2, 3 }).endsWith(2, 3); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).endsWith(3, 4);</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. * @since 2.6.0 / 3.6.0 */ public SELF endsWith(int... sequence) { arrays.assertEndsWith(info, actual, sequence); 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 byte[] { 1, 2, 3 }).containsSequence((byte) 1, (byte) 2); * assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 1, (byte) 2, (byte) 3); * assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 2, (byte) 3); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 1, (byte) 3); * assertThat(new byte[] { 1, 2, 3 }).containsSequence((byte) 4, (byte) 7);</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 SELF containsSequence(byte... 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 byte[] { 1, 2, 3 }).containsSubsequence(1, 2, 3); * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(1, 2); * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(1, 3); * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(2, 3); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(2, 1); * assertThat(new byte[] { 1, 2, 3 }).containsSubsequence(4, 7);</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. * @since 2.6.0 / 3.6.0 */ public SELF containsSubsequence(int... subsequence) { arrays.assertContainsSubsequence(info, actual, subsequence); return myself; }
/** {@inheritDoc} */ @Override @CheckReturnValue public SELF usingElementComparator(Comparator<? super Byte> customComparator) { this.arrays = new ByteArrays(new ComparatorBasedComparisonStrategy(customComparator)); return myself; }
/** {@inheritDoc} */ @Override public void isEmpty() { arrays.assertEmpty(info, actual); }
/** * Verifies that the actual array does not contain duplicates. * <p> * Example: * <pre><code class='java'> // assertion will pass * assertThat(new byte[] { 1, 2, 3 }).doesNotHaveDuplicates(); * * // assertion will fail * assertThat(new byte[] { 1, 1, 2, 3 }).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 SELF doesNotHaveDuplicates() { arrays.assertDoesNotHaveDuplicates(info, actual); return myself; }
/** * Verifies that the actual array does not contain the given value at the given index. * <p> * Example: * <pre><code class='java'> // assertion will pass * assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 1, atIndex(1)); * assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 2, atIndex(0)); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 1, atIndex(0)); * assertThat(new byte[] { 1, 2, 3 }).doesNotContain((byte) 2, 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 SELF doesNotContain(byte value, Index index) { arrays.assertDoesNotContain(info, actual, value, index); return myself; }
/** * Verifies that the actual array contains the given value at the given index. * <p> * Example: * <pre><code class='java'> // assertion will pass * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, atIndex(O)); * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 3, atIndex(2)); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 1, atIndex(1)); * assertThat(new byte[] { 1, 2, 3 }).contains((byte) 4, 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 SELF contains(byte value, Index index) { arrays.assertContains(info, actual, value, index); 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(byte...)}</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 byte[] { 1, 2, 3 }).endsWith((byte) 2, (byte) 3); * * // assertion will fail * assertThat(new byte[] { 1, 2, 3 }).endsWith((byte) 3, (byte) 4);</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 SELF endsWith(byte... sequence) { arrays.assertEndsWith(info, actual, sequence); return myself; }