Class AbstractDoubleArrayAssert<SELF extends AbstractDoubleArrayAssert<SELF>>

    • Constructor Detail

      • AbstractDoubleArrayAssert

        public AbstractDoubleArrayAssert​(double[] actual,
                                         Class<?> selfType)
    • Method Detail

      • isNullOrEmpty

        public void isNullOrEmpty()
        Verifies that the actual group of values is null 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 double[] { 1.0, 2.0, 3.0 }).hasSize(3);
        
         // assertion will fail
         assertThat(new double[] { 1.0, 2.0, 1.0 }).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 double[] { 1.0, 2.0 }).hasSizeGreaterThan(1);
        
         // assertion will fail
         assertThat(new double[] { 1.0 }).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 double[] { 1.0, 2.0 }).hasSizeGreaterThanOrEqualTo(1)
                                              .hasSizeGreaterThanOrEqualTo(2);
        
         // assertion will fail
         assertThat(new double[] { 1.0 }).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 double[] { 1.0, 2.0 }).hasSizeLessThan(3);
        
         // assertion will fail
         assertThat(new double[] { 1.0, 2.0 }).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 double[] { 1.0, 2.0 }).hasSizeLessThanOrEqualTo(3)
                                              .hasSizeLessThanOrEqualTo(2);
        
         // assertion will fail
         assertThat(new double[] { 1.0, 2.0 }).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 double[] { 1.0, 2.0 }).hasSizeBetween(1, 3)
                                              .hasSizeBetween(2, 2);
        
         // assertion will fail
         assertThat(new double[] { 1.0, 2.0 }).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 given Iterable.

        Examples :

         // assertion will pass
         assertThat(new double[] { 1.0, 2.0, 3.0 }).hasSameSizeAs(Arrays.asList(1, 2, 3));
        
         // assertion will fail
         assertThat(new double[] { 1.0, 2.0, 1.0 }).hasSameSizeAs(Arrays.asList(1, 2));
        Parameters:
        other - the Iterable to compare size with actual group.
        Returns:
        this assertion object.
      • contains

        public SELF contains​(double... 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(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Examples :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).contains(1.0, 3.0, 2.0)
                           .contains(3.0, 1.0)
                           .usingComparatorWithPrecision(0.5)
                           .contains(1.1, 2.1);
        
         // assertions will fail
         assertThat(values).contains(1.0, 4.0);
         assertThat(values).usingComparatorWithPrecision(0.01)
                           .contains(1.1, 2.1);
        Parameters:
        values - the given values.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array does not contain the given values.
      • contains

        public SELF contains​(double[] values,
                             Offset<Double> precision)
        Verifies that the actual array contains the given values, in any order, the comparison is done at the given precision/offset set with Assertions.withPrecision(Double).

        Examples :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).contains(new double[] {1.01, 3.01, 2.0}, withPrecision(0.02));
        
         // assertions will fail
         assertThat(values).contains(new double[] {1.0, 4.0}, withPrecision(0.5));
         assertThat(values).contains(new double[] {4.0, 7.0}, withPrecision(2));
        Parameters:
        values - the given values.
        precision - the precision under which the value may vary
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array does not contain the given values.
      • containsOnly

        public SELF containsOnly​(double... 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(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Examples :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).containsOnly(1.0, 2.0, 3.0)
                           .containsOnly(2.0, 3.0, 1.0)
                           .usingComparatorWithPrecision(0.5)
                           .containsOnly(1.1, 3.1, 2.1);
          
         // assertions will fail
         assertThat(values).containsOnly(1.0, 4.0, 2.0, 3.0);
         assertThat(values).containsOnly(4.0, 7.0);
         assertThat(values).containsOnly(1.1, 2.1, 3.1);
         assertThat(values).usingComparatorWithPrecision(0.01)
                           .containsOnly(1.1, 2.1, 3.1);
        Parameters:
        values - the given values.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array does not contain the given values, i.e. the actual array contains some or none of the given values, or the actual array contains more values than the given ones.
      • containsOnly

        public SELF containsOnly​(double[] values,
                                 Offset<Double> 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 with Assertions.withPrecision(Double).

        Examples :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).containsOnly(new double[] {1.0, 2.0, 3.0}, withPrecision(0.00001))
                           .containsOnly(new double[] {2.0, 3.0, 0.7}, withPrecision(0.5));
        
         // assertions will fail
         assertThat(values).containsOnly(new double[] {1.0, 4.0, 2.0, 3.0}, withPrecision(0.5));
         assertThat(values).containsOnly(new double[] {4.0, 7.0}, withPrecision(0.2));
        Parameters:
        values - the given values.
        precision - the precision under which the value may vary
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array does not contain the given values, i.e. the actual array contains some or none of the given values, or the actual array contains more values than the given ones.
      • containsOnlyOnce

        public SELF containsOnlyOnce​(double... 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(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Examples :

         // assertion will pass
         assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(1.0, 2.0)
                                                   .usingComparatorWithPrecision(0.5)
                                                   .containsOnlyOnce(1.1, 3.1, 2.1);
        
         // assertions will fail
         assertThat(new double[] { 1.0, 2.0, 1.0 }).containsOnlyOnce(1.0);
         assertThat(new double[] { 1.0, 2.0, 1.0 }).containsOnlyOnce(1.0, 2.0);
         assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(4.0);
         assertThat(new double[] { 1.0, 2.0, 3.0 }).usingComparatorWithPrecision(0.05)
                                                   .containsOnlyOnce(1.1, 2.1);
        Parameters:
        values - the given values.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual 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​(double[] values,
                                     Offset<Double> precision)
        Verifies that the actual array contains the given values only once. The comparison is done at the given precision/offset set with Assertions.withPrecision(Double).

        Examples :

         // assertion will pass
         assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(new double[] {1.1, 2.0}, withPrecision(0.2));
        
         // assertions will fail
         assertThat(new double[] { 1.0, 2.0, 1.0 }).containsOnlyOnce(new double[] {1.05}, withPrecision(0.1));
         assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(new double[] {4.0}, withPrecision(0.1));
         assertThat(new double[] { 1.0, 2.0, 3.0, 3.0 }).containsOnlyOnce(new double[] {0.1, 0.9, 2.0, 3.11, 4.0, 5.0}, withPrecision(0.2));
        Parameters:
        values - the given values.
        precision - the precision under which the value may vary
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual 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.
      • containsSequence

        public SELF containsSequence​(double... 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(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Examples :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).containsSequence(1.0, 2.0)
                           .containsSequence(1.0, 2.0, 3.0)
                           .containsSequence(2.0, 3.0)
                           .usingComparatorWithPrecision(0.5)
                           .containsSequence(1.1, 2.1);
        
         // assertions will fail
         assertThat(values).containsSequence(1.0, 3.0);
         assertThat(values).containsSequence(4.0, 7.0);
         assertThat(values).usingComparatorWithPrecision(0.01)
                           .containsSequence(1.1, 2.0, 3.0);
        Parameters:
        sequence - the sequence of values to look for.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is null.
        AssertionError - if the given array is null.
        AssertionError - if the actual array does not contain the given sequence.
      • containsSequence

        public SELF containsSequence​(double[] sequence,
                                     Offset<Double> 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 with Assertions.withPrecision(Double).

        Examples :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).containsSequence(new double[] {1.07, 2.0}, withPrecision(0.1))
                           .containsSequence(new double[] {1.1, 2.1, 3.0}, withPrecision(0.2))
                           .containsSequence(new double[] {2.2, 3.0}, withPrecision(0.3));
        
         // assertions will fail
         assertThat(values).containsSequence(new double[] {1.0, 3.0}, withPrecision(0.2));
         assertThat(values).containsSequence(new double[] {4.0, 7.0}, withPrecision(0.1));
        Parameters:
        sequence - the sequence of values to look for.
        precision - the precision under which the value may vary
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is null.
        AssertionError - if the given array is null.
        AssertionError - if the actual array does not contain the given sequence.
      • containsSubsequence

        public SELF containsSubsequence​(double... 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(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Examples :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).containsSubsequence(1.0, 2.0);
                           .containsSubsequence(1.0, 2.0, 3.0)
                           .containsSubsequence(1.0, 3.0)
                           .usingComparatorWithPrecision(0.5)
                           .containsSubsequence(1.1, 2.1);
        
         // assertions will fail
         assertThat(values).containsSubsequence(3.0, 1.0);
         assertThat(values).containsSubsequence(4.0, 7.0);
         assertThat(values).usingComparatorWithPrecision(0.01)
                           .containsSubsequence(1.1, 2.0);
        Parameters:
        subsequence - the subsequence of values to look for.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is null.
        AssertionError - if the given array is null.
        AssertionError - if the actual array does not contain the given subsequence.
      • containsSubsequence

        public SELF containsSubsequence​(double[] subsequence,
                                        Offset<Double> 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 with Assertions.withPrecision(Double).

        Examples :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).containsSubsequence(new double[] {1.0, 2.0}, withPrecision(0.1))
                           .containsSubsequence(new double[] {1.0, 2.07, 3.0}, withPrecision(0.1))
                           .containsSubsequence(new double[] {2.1, 2.9}, withPrecision(0.2));
        
         // assertions will fail
         assertThat(values).containsSubsequence(new double[] {1.0, 3.0}, withPrecision(0.1));
         assertThat(values).containsSubsequence(new double[] {4.0, 7.0}, withPrecision(0.1));
        Parameters:
        subsequence - the subsequence of values to look for.
        precision - the precision under which the value may vary.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is null.
        AssertionError - if the given array is null.
        AssertionError - if the actual array does not contain the given subsequence.
      • contains

        public SELF contains​(double 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(double, Index, Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).contains(1.0, atIndex(O))
                           .contains(3.0, atIndex(2))
                           .usingComparatorWithPrecision(0.5)
                           .contains(3.1, atIndex(2));
        
         // assertions will fail
         assertThat(values).contains(1.0, atIndex(1));
         assertThat(values).contains(4.0, atIndex(2));
         assertThat(values).usingComparatorWithPrecision(0.01)
                           .contains(3.1, 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 is null or empty.
        NullPointerException - if the given Index is null.
        IndexOutOfBoundsException - if the value of the given Index is equal to or greater than the size of the actual array.
        AssertionError - if the actual array does not contain the given value at the given index.
      • contains

        public SELF contains​(double value,
                             Index index,
                             Offset<Double> precision)
        Verifies that the actual array contains the given value at the given index. The comparison is done at the given precision/offset set with Assertions.withPrecision(Double).

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).contains(1.0, atIndex(O), withPrecision(0.01))
                           .contains(3.3, atIndex(2), withPrecision(0.5));
        
         // assertions will fail
         assertThat(values).contains(1.0, atIndex(1), withPrecision(0.2));
         assertThat(values).contains(4.5, atIndex(2), withPrecision(0.1));
        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 is null or empty.
        NullPointerException - if the given Index is null.
        IndexOutOfBoundsException - if the value of the given Index is equal to or greater than the size of the actual array.
        AssertionError - if the actual array does not contain the given value at the given index.
      • doesNotContain

        public SELF doesNotContain​(double... 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(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).doesNotContain(4.0, 8.0)
                           .usingComparatorWithPrecision(0.0001)
                           .doesNotContain(1.01, 2.01);
        
         // assertions will fail
         assertThat(values).doesNotContain(1.0, 4.0, 8.0);
         assertThat(values).usingComparatorWithPrecision(0.1)
                           .doesNotContain(1.001, 2.001);
        Parameters:
        values - the given values.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array contains any of the given values.
      • doesNotContain

        public SELF doesNotContain​(double[] values,
                                   Offset<Double> precision)
        Verifies that the actual array does not contain the given values. The comparison is done at the given precision/offset set with Assertions.withPrecision(Double).

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).doesNotContain(new double[] {4.0, 8.0}, withPrecision(0.5));
        
         // assertion will fail
         assertThat(values).doesNotContain(new double[] {1.05, 4.0, 8.0}, withPrecision(0.1));
        Parameters:
        values - the given values.
        precision - the precision under which the values may vary.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array contains any of the given values.
      • doesNotContain

        public SELF doesNotContain​(double 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(double, Index, Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).doesNotContain(1.0, atIndex(1))
                           .doesNotContain(2.0, atIndex(0))
                           .usingComparatorWithPrecision(0.001)
                           .doesNotContain(1.1, atIndex(0));
        
         // assertions will fail
         assertThat(values).doesNotContain(1.0, atIndex(0));
         assertThat(values).usingComparatorWithPrecision(0.1)
                           .doesNotContain(1.001, 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 is null.
        NullPointerException - if the given Index is null.
        AssertionError - if the actual array contains the given value at the given index.
      • doesNotContain

        public SELF doesNotContain​(double value,
                                   Index index,
                                   Offset<Double> 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 with Assertions.withPrecision(Double).

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).doesNotContain(1.01, atIndex(1), withPrecision(0.0001))
                           .doesNotContain(2.05, atIndex(0), withPrecision(0.1));
        
         // assertion will fail
         assertThat(values).doesNotContain(1.01, atIndex(0), withPrecision(0.1));
        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 values may vary.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is null.
        NullPointerException - if the given Index is null.
        AssertionError - if the actual array contains the given value at the given index.
      • 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) or usingComparatorWithPrecision(Double) before calling the assertion.

        Example:

         // assertion will pass
         assertThat(new double[] { 1.0, 2.0, 3.0 }).doesNotHaveDuplicates();
         assertThat(new double[] { 1.0, 1.1 }).usingComparatorWithPrecision(0.01)
                                              .doesNotHaveDuplicates();
        
         // assertion will fail
         assertThat(new double[] { 1.0, 1.0, 2.0, 3.0 }).doesNotHaveDuplicates();
         assertThat(new double[] { 1.0, 1.1 }).usingComparatorWithPrecision(0.5)
                                              .doesNotHaveDuplicates();
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is null.
        AssertionError - if the actual array contains duplicates.
      • doesNotHaveDuplicates

        public SELF doesNotHaveDuplicates​(Offset<Double> precision)
        Verifies that the actual array does not contain duplicates. The comparison is done at the given precision/offset set with Assertions.withPrecision(Double).

        Example:

         // assertion will pass
         assertThat(new double[] { 1.0, 2.0, 3.0 }).doesNotHaveDuplicates(withPrecision(0.1));
         assertThat(new double[] { 1.1, 1.2, 1.3 }).doesNotHaveDuplicates(withPrecision(0.05));
        
         // assertion will fail
         assertThat(new double[] { 1.0, 1.01, 2.0 }).doesNotHaveDuplicates(withPrecision(0.1));
        Parameters:
        precision - the precision under which the values may vary.
        Returns:
        this assertion object.
        Throws:
        AssertionError - if the actual array is null.
        AssertionError - if the actual array contains duplicates.
      • startsWith

        public SELF startsWith​(double... sequence)
        Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to containsSequence(double...), but it also verifies that the first element in the sequence is also first element of the actual array.

        If you want to set a precision for the comparison either use startsWith(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).startsWith(1.0, 2.0)
                           .usingComparatorWithPrecision(0.5)
                           .startsWith(1.1, 2.1);
        
         // assertion will fail
         assertThat(values).startsWith(2.0, 3.0);
        Parameters:
        sequence - the sequence of values to look for.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array does not start with the given sequence.
      • startsWith

        public SELF startsWith​(double[] values,
                               Offset<Double> precision)
        Verifies that the actual array starts with the given sequence of values, without any other values between them. Similar to containsSequence(double...), but it also verifies that the first element in the sequence is also first element of the actual array.

        The comparison is done at the given precision/offset set with Assertions.withPrecision(Double).

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).startsWith(new double[] {1.01, 2.01}, withPrecision(0.1));
        
         // assertions will fail
         assertThat(values).startsWith(new double[] {2.0, 1.0}, withPrecision(0.1))
         assertThat(values).startsWith(new double[] {1.1, 2.1}, withPrecision(0.5))
        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 is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array does not end with the given sequence.
      • endsWith

        public SELF endsWith​(double... sequence)
        Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to containsSequence(double...), but it also verifies that the last element in the sequence is also last element of the actual array.

        If you want to set a precision for the comparison either use endsWith(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).endsWith(2.0, 3.0)
                           .usingComparatorWithPrecision(0.5)
                           .endsWith(2.1, 3.1);
        
         // assertion will fail
         assertThat(values).endsWith(1.0, 3.0);
        Parameters:
        sequence - the sequence of values to look for.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array does not end with the given sequence.
      • endsWith

        public SELF endsWith​(double[] values,
                             Offset<Double> precision)
        Verifies that the actual array ends with the given sequence of values, without any other values between them. Similar to containsSequence(double...), but it also verifies that the last element in the sequence is also last element of the actual array.

        The comparison is done at the given precision/offset set with Assertions.withPrecision(Double).

        Example:

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).endsWith(new double[] {2.01, 3.01}, withPrecision(0.1));
        
         // assertion will fail
         assertThat(values).endsWith(new double[] {3.0, 2.0}, withPrecision(0.1))
         assertThat(values).endsWith(new double[] {2.1, 3.1}, withPrecision(0.5))
        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 is null.
        IllegalArgumentException - if the given argument is an empty array.
        AssertionError - if the actual array is null.
        AssertionError - if the actual array does not end with the given sequence.
      • 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)
        Empty or one element arrays are considered sorted (unless the array element type is not Comparable).

        Returns:
        this assertion object.
      • isSortedAccordingTo

        public SELF isSortedAccordingTo​(Comparator<? super Double> 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 - the Comparator used to compare array elements
        Returns:
        this assertion object.
      • usingElementComparator

        public SELF usingElementComparator​(Comparator<? super Double> customComparator)
        Use given custom comparator instead of relying on actual type A equals 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​(double... 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(double[], Offset) or usingComparatorWithPrecision(Double) before calling the assertion.

        Example :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertions will pass
         assertThat(values).containsExactly(1.0, 2.0, 3.0)
                           .usingComparatorWithPrecision(0.2)
                           .containsExactly(1.1, 2.1, 2.9);
        
         // assertion will fail as actual and expected order differ
         assertThat(values).containsExactly(2.0, 1.0, 3.0);
        Parameters:
        values - the given values.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        AssertionError - if the actual group is null.
        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.
      • containsExactlyInAnyOrder

        public SELF containsExactlyInAnyOrder​(double... values)
        Verifies that the actual group contains exactly the given values and nothing else, in any order.

        Example :

         // assertions will pass
         assertThat(new double[] { 1.0, 2.0 }).containsExactlyInAnyOrder(1.0, 2.0);
         assertThat(new double[] { 1.0, 2.0, 1.0 }).containsExactlyInAnyOrder(1.0, 1.0, 2.0);
        
         // assertions will fail
         assertThat(new double[] { 1.0, 2.0 }).containsExactlyInAnyOrder(1.0);
         assertThat(new double[] { 1.0 }).containsExactlyInAnyOrder(1.0, 2.0);
         assertThat(new double[] { 1.0, 2.0, 1.0 }).containsExactlyInAnyOrder(1.0, 2.0);
        Parameters:
        values - the given values.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        AssertionError - if the actual group is null.
        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
      • containsExactly

        public SELF containsExactly​(double[] values,
                                    Offset<Double> 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 :

         double[] values = new double[] { 1.0, 2.0, 3.0 };
        
         // assertion will pass
         assertThat(values).containsExactly(new double[] {1.0, 1.98, 3.01}, withPrecision(0.05));
        
         // assertion fails because |1.0 -1.1| > 0.05 (precision).
         assertThat(values).containsExactly(new double[] {1.1, 2.0, 3.01}, withPrecision(0.05));
        
         // assertion will fail as actual and expected order differ
         assertThat(values).containsExactly(new double[] {1.98, 1.0, 3.01}, withPrecision(0.05));
        Parameters:
        values - the given values.
        precision - the precision under which the values may vary.
        Returns:
        this assertion object.
        Throws:
        NullPointerException - if the given argument is null.
        AssertionError - if the actual group is null.
        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.
      • usingComparatorWithPrecision

        public SELF usingComparatorWithPrecision​(Double precision)
        Create a Double comparator which compares double at the given precision and pass it to usingElementComparator(Comparator). All the following assertions will use this comparator to compare double[] elements.
        Parameters:
        precision - precision used to compare Double.
        Returns:
        this assertion object.
      • containsAnyOf

        public SELF containsAnyOf​(double... values)
        Verifies that the actual array contains at least one of the given values.

        Example :

         double[] oneTwoThree = { 1.0, 2.0, 3.0 };
        
         // assertions will pass
         assertThat(oneTwoThree).containsAnyOf(2.0)
                                .containsAnyOf(2.0, 3.0)
                                .containsAnyOf(1.0, 2.0, 3.0)
                                .containsAnyOf(1.0, 2.0, 3.0, 4.0)
                                .containsAnyOf(5.0, 6.0, 7.0, 2.0);
        
         // assertions will fail
         assertThat(oneTwoThree).containsAnyOf(4.0);
         assertThat(oneTwoThree).containsAnyOf(4.0, 5.0, 6.0, 7.0);
        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 is null.
        IllegalArgumentException - if the array of values is empty and the array under test is not empty.
        AssertionError - if the array under test is null.
        AssertionError - if the array under test does not contain any of the given values.
        Since:
        2.9.0 / 3.9.0