How to use toPrimitiveDoubleArray method of org.assertj.core.api.AbstractDoubleArrayAssert class

Best Assertj code snippet using org.assertj.core.api.AbstractDoubleArrayAssert.toPrimitiveDoubleArray

Source:AbstractDoubleArrayAssert.java Github

copy

Full Screen

...230 * @since 3.19.0231 */232 public SELF contains(Double[] values) {233 requireNonNullParameter(values, "values");234 arrays.assertContains(info, actual, toPrimitiveDoubleArray(values));235 return myself;236 }237 /**238 * Verifies that the actual array contains the given values, in any order,239 * the comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.240 * <p>241 * Examples :242 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };243 *244 * // assertion will pass245 * assertThat(values).contains(new double[] { 1.01, 3.01, 2.0 }, withPrecision(0.02));246 *247 * // assertions will fail248 * assertThat(values).contains(new double[] { 1.0, 4.0 }, withPrecision(0.5));249 * assertThat(values).contains(new double[] { 4.0, 7.0 }, withPrecision(2));</code></pre>250 *251 * @param values the given values.252 * @param precision the precision under which the value may vary253 * @return {@code this} assertion object.254 * @throws NullPointerException if the given argument is {@code null}.255 * @throws IllegalArgumentException if the given argument is an empty array.256 * @throws AssertionError if the actual array is {@code null}.257 * @throws AssertionError if the actual array does not contain the given values.258 */259 public SELF contains(double[] values, Offset<Double> precision) {260 return usingComparatorWithPrecision(precision.value).contains(values);261 }262 /**263 * Verifies that the actual array contains the values of the given array, in any order,264 * the comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.265 * <p>266 * Examples :267 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };268 *269 * // assertion will pass270 * assertThat(values).contains(new Double[] { 1.01, 3.01, 2.0 }, withPrecision(0.02));271 *272 * // assertions will fail273 * assertThat(values).contains(new Double[] { 1.0, 4.0 }, withPrecision(0.5));274 * assertThat(values).contains(new Double[] { 4.0, 7.0 }, withPrecision(2));</code></pre>275 *276 * @param values the given values.277 * @param precision the precision under which the value may vary278 * @return {@code this} assertion object.279 * @throws NullPointerException if the given argument is {@code null}.280 * @throws IllegalArgumentException if the given argument is an empty array.281 * @throws AssertionError if the actual array is {@code null}.282 * @throws AssertionError if the actual array does not contain the given values.283 * @since 3.19.0284 */285 public SELF contains(Double[] values, Offset<Double> precision) {286 return usingComparatorWithPrecision(precision.value).contains(toPrimitiveDoubleArray(values));287 }288 /**289 * Verifies that the actual array contains only the given values and nothing else, in any order.290 * <p>291 * If you want to set a precision for the comparison either use {@link #containsOnly(double[], Offset)}292 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.293 * <p>294 * Examples :295 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };296 *297 * // assertion will pass298 * assertThat(values).containsOnly(1.0, 2.0, 3.0)299 * .containsOnly(2.0, 3.0, 1.0)300 * .usingComparatorWithPrecision(0.5)301 * .containsOnly(1.1, 3.1, 2.1);302 303 * // assertions will fail304 * assertThat(values).containsOnly(1.0, 4.0, 2.0, 3.0);305 * assertThat(values).containsOnly(4.0, 7.0);306 * assertThat(values).containsOnly(1.1, 2.1, 3.1);307 * assertThat(values).usingComparatorWithPrecision(0.01)308 * .containsOnly(1.1, 2.1, 3.1);</code></pre>309 *310 * @param values the given values.311 * @return {@code this} assertion object.312 * @throws NullPointerException if the given argument is {@code null}.313 * @throws IllegalArgumentException if the given argument is an empty array.314 * @throws AssertionError if the actual array is {@code null}.315 * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some316 * or none of the given values, or the actual array contains more values than the given ones.317 */318 public SELF containsOnly(double... values) {319 arrays.assertContainsOnly(info, actual, values);320 return myself;321 }322 /**323 * Verifies that the actual array contains only the values of the given array and nothing else, in any order.324 * <p>325 * Example:326 * <pre><code class='java'> // assertions will pass327 * assertThat(new double[] { 1.0 , 2.0 }).containsOnly(new Double[] { 1.0, 2.0 });328 * assertThat(new double[] { 2.0, 1.0 }).containsOnly(new Double[] { 1.0, 2.0 });329 * assertThat(new double[] { 1.0, 1.0, 2.0 }).containsOnly(new Double[] { 1.0, 2.0 });330 *331 * // assertions will fail332 * assertThat(new double[] { 1.0, 2.0 }).containsOnly(new Double[] { 2.0 });333 * assertThat(new double[] { 1.0 }).containsOnly(new Double[] { 1.0, 2.0 });</code></pre>334 *335 * @param values the given values.336 * @return {@code this} assertion object.337 * @throws NullPointerException if the given argument is {@code null}.338 * @throws IllegalArgumentException if the given argument is an empty array.339 * @throws AssertionError if the actual array is {@code null}.340 * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some341 * or none of the given values, or the actual array contains more values than the given ones.342 * @since 3.19.0343 */344 public SELF containsOnly(Double[] values) {345 requireNonNullParameter(values, "values");346 arrays.assertContainsOnly(info, actual, toPrimitiveDoubleArray(values));347 return myself;348 }349 /**350 * Verifies that the actual array contains only the given values and nothing else, in any order.351 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.352 * <p>353 * Examples :354 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };355 *356 * // assertion will pass357 * assertThat(values).containsOnly(new double[] { 1.0, 2.0, 3.0 }, withPrecision(0.00001))358 * .containsOnly(new double[] { 2.0, 3.0, 0.7 }, withPrecision(0.5));359 *360 * // assertions will fail361 * assertThat(values).containsOnly(new double[] { 1.0, 4.0, 2.0, 3.0 }, withPrecision(0.5));362 * assertThat(values).containsOnly(new double[] { 4.0, 7.0 }, withPrecision(0.2));</code></pre>363 *364 * @param values the given values.365 * @param precision the precision under which the value may vary366 * @return {@code this} assertion object.367 * @throws NullPointerException if the given argument is {@code null}.368 * @throws IllegalArgumentException if the given argument is an empty array.369 * @throws AssertionError if the actual array is {@code null}.370 * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some371 * or none of the given values, or the actual array contains more values than the given ones.372 */373 public SELF containsOnly(double[] values, Offset<Double> precision) {374 return usingComparatorWithPrecision(precision.value).containsOnly(values);375 }376 /**377 * Verifies that the actual array contains only the values of the given array and nothing else, in any order.378 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.379 * <p>380 * Examples :381 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };382 *383 * // assertion will pass384 * assertThat(values).containsOnly(new Double[] { 1.0, 2.0, 3.0 }, withPrecision(0.00001))385 * .containsOnly(new Double[] { 2.0, 3.0, 0.7 }, withPrecision(0.5));386 *387 * // assertions will fail388 * assertThat(values).containsOnly(new Double[] { 1.0, 4.0, 2.0, 3.0 }, withPrecision(0.5));389 * assertThat(values).containsOnly(new Double[] { 4.0, 7.0 }, withPrecision(0.2));</code></pre>390 *391 * @param values the given values.392 * @param precision the precision under which the value may vary393 * @return {@code this} assertion object.394 * @throws NullPointerException if the given argument is {@code null}.395 * @throws IllegalArgumentException if the given argument is an empty array.396 * @throws AssertionError if the actual array is {@code null}.397 * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some398 * or none of the given values, or the actual array contains more values than the given ones.399 * @since 3.19.0400 */401 public SELF containsOnly(Double[] values, Offset<Double> precision) {402 return usingComparatorWithPrecision(precision.value).containsOnly(toPrimitiveDoubleArray(values));403 }404 /**405 * Verifies that the actual array contains the given values only once.406 * <p>407 * If you want to set a precision for the comparison either use {@link #containsOnlyOnce(double[], Offset)}408 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.409 * <p>410 * Examples :411 * <pre><code class='java'> // assertion will pass412 * assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(1.0, 2.0)413 * .usingComparatorWithPrecision(0.5)414 * .containsOnlyOnce(1.1, 3.1, 2.1);415 *416 * // assertions will fail417 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsOnlyOnce(1.0);418 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsOnlyOnce(1.0, 2.0);419 * assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(4.0);420 * assertThat(new double[] { 1.0, 2.0, 3.0 }).usingComparatorWithPrecision(0.05)421 * .containsOnlyOnce(1.1, 2.1);</code></pre>422 *423 * @param values the given values.424 * @return {@code this} assertion object.425 * @throws NullPointerException if the given argument is {@code null}.426 * @throws IllegalArgumentException if the given argument is an empty array.427 * @throws AssertionError if the actual array is {@code null}.428 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some429 * or none of the given values, or the actual group contains more than once these values.430 */431 public SELF containsOnlyOnce(double... values) {432 arrays.assertContainsOnlyOnce(info, actual, values);433 return myself;434 }435 /**436 * Verifies that the actual array contains the values of the given array only once.437 * <p>438 * Examples :439 * <pre><code class='java'> // assertion will pass440 * assertThat(new double[] { 1.0, 2.0 }).containsOnlyOnce(new Double[] { 1.0, 2.0 });441 *442 * // assertions will fail443 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsOnlyOnce(new Double[] { 1.0 });444 * assertThat(new double[] { 1.0 }).containsOnlyOnce(new Double[] { 2.0 });445 * assertThat(new double[] { 1.0 }).containsOnlyOnce(new Double[] { 1.0, 2.0 });</code></pre>446 *447 * @param values the given values.448 * @return {@code this} assertion object.449 * @throws NullPointerException if the given argument is {@code null}.450 * @throws IllegalArgumentException if the given argument is an empty array.451 * @throws AssertionError if the actual array is {@code null}.452 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some453 * or none of the given values, or the actual group contains more than once these values.454 * @since 3.19.0455 */456 public SELF containsOnlyOnce(Double[] values) {457 requireNonNullParameter(values, "values");458 arrays.assertContainsOnlyOnce(info, actual, toPrimitiveDoubleArray(values));459 return myself;460 }461 /**462 * Verifies that the actual array contains the given values only once.463 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.464 * <p>465 * Examples :466 * <pre><code class='java'> // assertion will pass467 * assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(new double[] {1.1, 2.0}, withPrecision(0.2));468 *469 * // assertions will fail470 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsOnlyOnce(new double[] {1.05}, withPrecision(0.1));471 * assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(new double[] {4.0}, withPrecision(0.1));472 * 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));</code></pre>473 *474 * @param values the given values.475 * @param precision the precision under which the value may vary476 * @return {@code this} assertion object.477 * @throws NullPointerException if the given argument is {@code null}.478 * @throws IllegalArgumentException if the given argument is an empty array.479 * @throws AssertionError if the actual array is {@code null}.480 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some481 * or none of the given values, or the actual group contains more than once these values.482 */483 public SELF containsOnlyOnce(double[] values, Offset<Double> precision) {484 return usingComparatorWithPrecision(precision.value).containsOnlyOnce(values);485 }486 /**487 * Verifies that the actual array contains the values of the given array only once.488 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.489 * <p>490 * Examples :491 * <pre><code class='java'> // assertion will pass492 * assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(new Double[] { 1.1, 2.0 }, withPrecision(0.2));493 *494 * // assertions will fail495 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsOnlyOnce(new Double[] { 1.05 }, withPrecision(0.1));496 * assertThat(new double[] { 1.0, 2.0, 3.0 }).containsOnlyOnce(new Double[] { 4.0 }, withPrecision(0.1));497 * 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));</code></pre>498 *499 * @param values the given values.500 * @param precision the precision under which the value may vary501 * @return {@code this} assertion object.502 * @throws NullPointerException if the given argument is {@code null}.503 * @throws IllegalArgumentException if the given argument is an empty array.504 * @throws AssertionError if the actual array is {@code null}.505 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some506 * or none of the given values, or the actual group contains more than once these values.507 * @since 3.19.0508 */509 public SELF containsOnlyOnce(Double[] values, Offset<Double> precision) {510 return usingComparatorWithPrecision(precision.value).containsOnlyOnce(toPrimitiveDoubleArray(values));511 }512 /**513 * Verifies that the actual array contains the given sequence, without any other values between them.514 * <p>515 * If you want to set a precision for the comparison either use {@link #containsSequence(double[], Offset)}516 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.517 * <p>518 * Examples :519 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };520 *521 * // assertion will pass522 * assertThat(values).containsSequence(1.0, 2.0)523 * .containsSequence(1.0, 2.0, 3.0)524 * .containsSequence(2.0, 3.0)525 * .usingComparatorWithPrecision(0.5)526 * .containsSequence(1.1, 2.1);527 *528 * // assertions will fail529 * assertThat(values).containsSequence(1.0, 3.0);530 * assertThat(values).containsSequence(4.0, 7.0);531 * assertThat(values).usingComparatorWithPrecision(0.01)532 * .containsSequence(1.1, 2.0, 3.0);</code></pre>533 *534 * @param sequence the sequence of values to look for.535 * @return {@code this} assertion object.536 * @throws AssertionError if the actual array is {@code null}.537 * @throws AssertionError if the given array is {@code null}.538 * @throws AssertionError if the actual array does not contain the given sequence.539 */540 public SELF containsSequence(double... sequence) {541 arrays.assertContainsSequence(info, actual, sequence);542 return myself;543 }544 /**545 * Verifies that the actual array contains the given sequence, without any other values between them.546 * <p>547 * Example:548 * <pre><code class='java'> // assertion will pass549 * assertThat(new double[] { 1.0, 2.0 }).containsSequence(new Double[] { 1.0, 2.0 });550 * assertThat(new double[] { 1.0, 2.0, 2.0, 1.0 }).containsSequence(new Double[] { 2.0, 1.0 });551 *552 * // assertion will fail553 * assertThat(new double[] { 1.0, 1.0, 2.0 }).containsSequence(new Double[] { 2.0, 1.0 });</code></pre>554 *555 * @param sequence the sequence of values to look for.556 * @return myself assertion object.557 * @throws AssertionError if the actual array is {@code null}.558 * @throws AssertionError if the given array is {@code null}.559 * @throws AssertionError if the actual array does not contain the given sequence.560 * @since 3.19.0561 */562 public SELF containsSequence(Double[] sequence) {563 requireNonNullParameter(sequence, "sequence");564 arrays.assertContainsSequence(info, actual, toPrimitiveDoubleArray(sequence));565 return myself;566 }567 /**568 * Verifies that the actual array contains the given sequence, without any other values between them.569 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.570 * <p>571 * Examples :572 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };573 *574 * // assertion will pass575 * assertThat(values).containsSequence(new double[] {1.07, 2.0}, withPrecision(0.1))576 * .containsSequence(new double[] {1.1, 2.1, 3.0}, withPrecision(0.2))577 * .containsSequence(new double[] {2.2, 3.0}, withPrecision(0.3));578 *579 * // assertions will fail580 * assertThat(values).containsSequence(new double[] {1.0, 3.0}, withPrecision(0.2));581 * assertThat(values).containsSequence(new double[] {4.0, 7.0}, withPrecision(0.1));</code></pre>582 *583 * @param sequence the sequence of values to look for.584 * @param precision the precision under which the value may vary585 * @return {@code this} assertion object.586 * @throws AssertionError if the actual array is {@code null}.587 * @throws AssertionError if the given array is {@code null}.588 * @throws AssertionError if the actual array does not contain the given sequence.589 */590 public SELF containsSequence(double[] sequence, Offset<Double> precision) {591 return usingComparatorWithPrecision(precision.value).containsSequence(sequence);592 }593 /**594 * Verifies that the actual array contains the given sequence, without any other values between them.595 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.596 * <p>597 * Examples :598 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };599 *600 * // assertion will pass601 * assertThat(values).containsSequence(new Double[] { 1.07, 2.0 }, withPrecision(0.1))602 * .containsSequence(new Double[] { 1.1, 2.1, 3.0 }, withPrecision(0.2))603 * .containsSequence(new Double[] { 2.2, 3.0 }, withPrecision(0.3));604 *605 * // assertions will fail606 * assertThat(values).containsSequence(new Double[] { 1.0, 3.0 }, withPrecision(0.2));607 * assertThat(values).containsSequence(new Double[] { 4.0, 7.0 }, withPrecision(0.1));</code></pre>608 *609 * @param sequence the sequence of values to look for.610 * @param precision the precision under which the value may vary611 * @return {@code this} assertion object.612 * @throws AssertionError if the actual array is {@code null}.613 * @throws AssertionError if the given array is {@code null}.614 * @throws AssertionError if the actual array does not contain the given sequence.615 * @since 3.19.0616 */617 public SELF containsSequence(Double[] sequence, Offset<Double> precision) {618 return usingComparatorWithPrecision(precision.value).containsSequence(toPrimitiveDoubleArray(sequence));619 }620 /**621 * Verifies that the actual array contains the given subsequence (possibly with other values between them).622 * <p>623 * If you want to set a precision for the comparison either use {@link #containsSubsequence(double[], Offset)}624 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.625 * <p>626 * Examples :627 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };628 *629 * // assertion will pass630 * assertThat(values).containsSubsequence(1.0, 2.0);631 * .containsSubsequence(1.0, 2.0, 3.0)632 * .containsSubsequence(1.0, 3.0)633 * .usingComparatorWithPrecision(0.5)634 * .containsSubsequence(1.1, 2.1);635 *636 * // assertions will fail637 * assertThat(values).containsSubsequence(3.0, 1.0);638 * assertThat(values).containsSubsequence(4.0, 7.0);639 * assertThat(values).usingComparatorWithPrecision(0.01)640 * .containsSubsequence(1.1, 2.0);</code></pre>641 *642 * @param subsequence the subsequence of values to look for.643 * @return {@code this} assertion object.644 * @throws AssertionError if the actual array is {@code null}.645 * @throws AssertionError if the given array is {@code null}.646 * @throws AssertionError if the actual array does not contain the given subsequence.647 */648 public SELF containsSubsequence(double... subsequence) {649 arrays.assertContainsSubsequence(info, actual, subsequence);650 return myself;651 }652 /**653 * Verifies that the actual array contains the given subsequence (possibly with other values between them).654 * <p>655 * Example:656 * <pre><code class='java'> // assertion will pass657 * assertThat(new double[] { 1.0, 2.0 }).containsSubsequence(new Double[] { 1.0, 2.0 });658 * assertThat(new double[] { 1.0, 2.0, 2.0, 1.0 }).containsSubsequence(new Double[] { 1.0, 1.0 });659 *660 * // assertion will fail661 * assertThat(new double[] { 1.0, 1.0, 2.0 }).containsSubsequence(new Double[] { 2.0, 1.0 });</code></pre>662 *663 * @param subsequence the subsequence of values to look for.664 * @return myself assertion object.665 * @throws AssertionError if the actual array is {@code null}.666 * @throws AssertionError if the given array is {@code null}.667 * @throws AssertionError if the actual array does not contain the given subsequence.668 * @since 3.19.0669 */670 public SELF containsSubsequence(Double[] subsequence) {671 requireNonNullParameter(subsequence, "subsequence");672 arrays.assertContainsSubsequence(info, actual, toPrimitiveDoubleArray(subsequence));673 return myself;674 }675 /**676 * Verifies that the actual array contains the given subsequence (possibly with other values between them).677 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.678 * <p>679 * Examples :680 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };681 *682 * // assertion will pass683 * assertThat(values).containsSubsequence(new double[] {1.0, 2.0}, withPrecision(0.1))684 * .containsSubsequence(new double[] {1.0, 2.07, 3.0}, withPrecision(0.1))685 * .containsSubsequence(new double[] {2.1, 2.9}, withPrecision(0.2));686 *687 * // assertions will fail688 * assertThat(values).containsSubsequence(new double[] {1.0, 3.0}, withPrecision(0.1));689 * assertThat(values).containsSubsequence(new double[] {4.0, 7.0}, withPrecision(0.1));</code></pre>690 *691 * @param subsequence the subsequence of values to look for.692 * @param precision the precision under which the value may vary.693 * @return {@code this} assertion object.694 * @throws AssertionError if the actual array is {@code null}.695 * @throws AssertionError if the given array is {@code null}.696 * @throws AssertionError if the actual array does not contain the given subsequence.697 */698 public SELF containsSubsequence(double[] subsequence, Offset<Double> precision) {699 return usingComparatorWithPrecision(precision.value).containsSubsequence(subsequence);700 }701 /**702 * Verifies that the actual array contains the given subsequence (possibly with other values between them).703 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.704 * <p>705 * Examples :706 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };707 *708 * // assertion will pass709 * assertThat(values).containsSubsequence(new Double[] { 1.0, 2.0 }, withPrecision(0.1))710 * .containsSubsequence(new Double[] { 1.0, 2.07, 3.0 }, withPrecision(0.1))711 * .containsSubsequence(new Double[] { 2.1, 2.9 }, withPrecision(0.2));712 *713 * // assertions will fail714 * assertThat(values).containsSubsequence(new Double[] { 1.0, 3.0 }, withPrecision(0.1));715 * assertThat(values).containsSubsequence(new Double[] { 4.0, 7.0 }, withPrecision(0.1));</code></pre>716 *717 * @param subsequence the subsequence of values to look for.718 * @param precision the precision under which the value may vary.719 * @return {@code this} assertion object.720 * @throws AssertionError if the actual array is {@code null}.721 * @throws AssertionError if the given array is {@code null}.722 * @throws AssertionError if the actual array does not contain the given subsequence.723 * @since 3.19.0724 */725 public SELF containsSubsequence(Double[] subsequence, Offset<Double> precision) {726 return usingComparatorWithPrecision(precision.value).containsSubsequence(toPrimitiveDoubleArray(subsequence));727 }728 /**729 * Verifies that the actual array contains the given value at the given index.730 * <p>731 * If you want to set a precision for the comparison either use {@link #contains(double, Index, Offset)}732 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.733 * <p>734 * Example:735 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };736 *737 * // assertion will pass738 * assertThat(values).contains(1.0, atIndex(O))739 * .contains(3.0, atIndex(2))740 * .usingComparatorWithPrecision(0.5)741 * .contains(3.1, atIndex(2));742 *743 * // assertions will fail744 * assertThat(values).contains(1.0, atIndex(1));745 * assertThat(values).contains(4.0, atIndex(2));746 * assertThat(values).usingComparatorWithPrecision(0.01)747 * .contains(3.1, atIndex(2));</code></pre>748 *749 * @param value the value to look for.750 * @param index the index where the value should be stored in the actual array.751 * @return {@code this} assertion object.752 * @throws AssertionError if the actual array is {@code null} or empty.753 * @throws NullPointerException if the given {@code Index} is {@code null}.754 * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of755 * the actual array.756 * @throws AssertionError if the actual array does not contain the given value at the given index.757 */758 public SELF contains(double value, Index index) {759 arrays.assertContains(info, actual, value, index);760 return myself;761 }762 /**763 * Verifies that the actual array contains the given value at the given index.764 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.765 * <p>766 * Example:767 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };768 *769 * // assertion will pass770 * assertThat(values).contains(1.0, atIndex(O), withPrecision(0.01))771 * .contains(3.3, atIndex(2), withPrecision(0.5));772 *773 * // assertions will fail774 * assertThat(values).contains(1.0, atIndex(1), withPrecision(0.2));775 * assertThat(values).contains(4.5, atIndex(2), withPrecision(0.1));</code></pre>776 *777 * @param value the value to look for.778 * @param index the index where the value should be stored in the actual array.779 * @param precision the precision under which the value may vary.780 * @return {@code this} assertion object.781 * @throws AssertionError if the actual array is {@code null} or empty.782 * @throws NullPointerException if the given {@code Index} is {@code null}.783 * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of784 * the actual array.785 * @throws AssertionError if the actual array does not contain the given value at the given index.786 */787 public SELF contains(double value, Index index, Offset<Double> precision) {788 return usingComparatorWithPrecision(precision.value).contains(value, index);789 }790 /**791 * Verifies that the actual array does not contain the given values.792 * <p>793 * If you want to set a precision for the comparison either use {@link #doesNotContain(double[], Offset)}794 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.795 * <p>796 * Example:797 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };798 *799 * // assertion will pass800 * assertThat(values).doesNotContain(4.0, 8.0)801 * .usingComparatorWithPrecision(0.0001)802 * .doesNotContain(1.01, 2.01);803 *804 * // assertions will fail805 * assertThat(values).doesNotContain(1.0, 4.0, 8.0);806 * assertThat(values).usingComparatorWithPrecision(0.1)807 * .doesNotContain(1.001, 2.001);</code></pre>808 *809 * @param values the given values.810 * @return {@code this} assertion object.811 * @throws NullPointerException if the given argument is {@code null}.812 * @throws IllegalArgumentException if the given argument is an empty array.813 * @throws AssertionError if the actual array is {@code null}.814 * @throws AssertionError if the actual array contains any of the given values.815 */816 public SELF doesNotContain(double... values) {817 arrays.assertDoesNotContain(info, actual, values);818 return myself;819 }820 /**821 * Verifies that the actual array does not contain the values of the given array.822 * <p>823 * Example:824 * <pre><code class='java'> // assertion will pass825 * assertThat(new double[] { 1.0, 1.0 }).doesNotContain(new Double[] { 2.0 });826 *827 * // assertion will fail828 * assertThat(new double[] { 1.0, 1.0, 2.0 }).doesNotContain(new Double[] { 2.0 });</code></pre>829 *830 * @param values the given values.831 * @return {@code this} assertion object.832 * @throws NullPointerException if the given argument is {@code null}.833 * @throws IllegalArgumentException if the given argument is an empty array.834 * @throws AssertionError if the actual array is {@code null}.835 * @throws AssertionError if the actual array contains any of the given values.836 * @since 3.19.0837 */838 public SELF doesNotContain(Double[] values) {839 requireNonNullParameter(values, "values");840 arrays.assertDoesNotContain(info, actual, toPrimitiveDoubleArray(values));841 return myself;842 }843 /**844 * Verifies that the actual array does not contain the given values.845 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.846 * <p>847 * Example:848 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };849 *850 * // assertion will pass851 * assertThat(values).doesNotContain(new double[] {4.0, 8.0}, withPrecision(0.5));852 *853 * // assertion will fail854 * assertThat(values).doesNotContain(new double[] {1.05, 4.0, 8.0}, withPrecision(0.1));</code></pre>855 *856 * @param values the given values.857 * @param precision the precision under which the values may vary.858 * @return {@code this} assertion object.859 * @throws NullPointerException if the given argument is {@code null}.860 * @throws IllegalArgumentException if the given argument is an empty array.861 * @throws AssertionError if the actual array is {@code null}.862 * @throws AssertionError if the actual array contains any of the given values.863 */864 public SELF doesNotContain(double[] values, Offset<Double> precision) {865 return usingComparatorWithPrecision(precision.value).doesNotContain(values);866 }867 /**868 * Verifies that the actual array does not contain the values of the given array.869 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.870 * <p>871 * Example:872 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };873 *874 * // assertion will pass875 * assertThat(values).doesNotContain(new Double[] { 4.0, 8.0 }, withPrecision(0.5));876 *877 * // assertion will fail878 * assertThat(values).doesNotContain(new Double[] { 1.05, 4.0, 8.0 }, withPrecision(0.1));</code></pre>879 *880 * @param values the given values.881 * @param precision the precision under which the values may vary.882 * @return {@code this} assertion object.883 * @throws NullPointerException if the given argument is {@code null}.884 * @throws IllegalArgumentException if the given argument is an empty array.885 * @throws AssertionError if the actual array is {@code null}.886 * @throws AssertionError if the actual array contains any of the given values.887 * @since 3.19.0888 */889 public SELF doesNotContain(Double[] values, Offset<Double> precision) {890 return usingComparatorWithPrecision(precision.value).doesNotContain(toPrimitiveDoubleArray(values));891 }892 /**893 * Verifies that the actual array does not contain the given value at the given index.894 * <p>895 * If you want to set a precision for the comparison either use {@link #doesNotContain(double, Index, Offset)}896 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.897 * <p>898 * Example:899 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };900 *901 * // assertion will pass902 * assertThat(values).doesNotContain(1.0, atIndex(1))903 * .doesNotContain(2.0, atIndex(0))904 * .usingComparatorWithPrecision(0.001)905 * .doesNotContain(1.1, atIndex(0));906 *907 * // assertions will fail908 * assertThat(values).doesNotContain(1.0, atIndex(0));909 * assertThat(values).usingComparatorWithPrecision(0.1)910 * .doesNotContain(1.001, atIndex(0));</code></pre>911 *912 * @param value the value to look for.913 * @param index the index where the value should be stored in the actual array.914 * @return {@code this} assertion object.915 * @throws AssertionError if the actual array is {@code null}.916 * @throws NullPointerException if the given {@code Index} is {@code null}.917 * @throws AssertionError if the actual array contains the given value at the given index.918 */919 public SELF doesNotContain(double value, Index index) {920 arrays.assertDoesNotContain(info, actual, value, index);921 return myself;922 }923 /**924 * Verifies that the actual array does not contain the given value at the given index.925 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.926 * <p>927 * Example:928 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };929 *930 * // assertion will pass931 * assertThat(values).doesNotContain(1.01, atIndex(1), withPrecision(0.0001))932 * .doesNotContain(2.05, atIndex(0), withPrecision(0.1));933 *934 * // assertion will fail935 * assertThat(values).doesNotContain(1.01, atIndex(0), withPrecision(0.1));</code></pre>936 *937 * @param value the value to look for.938 * @param index the index where the value should be stored in the actual array.939 * @param precision the precision under which the values may vary.940 * @return {@code this} assertion object.941 * @throws AssertionError if the actual array is {@code null}.942 * @throws NullPointerException if the given {@code Index} is {@code null}.943 * @throws AssertionError if the actual array contains the given value at the given index.944 */945 public SELF doesNotContain(double value, Index index, Offset<Double> precision) {946 return usingComparatorWithPrecision(precision.value).doesNotContain(value, index);947 }948 /**949 * Verifies that the actual array does not contain duplicates.950 * <p>951 * If you want to set a precision for the comparison either use {@link #doesNotHaveDuplicates(Offset)}952 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.953 * <p>954 * Example:955 * <pre><code class='java'> // assertion will pass956 * assertThat(new double[] { 1.0, 2.0, 3.0 }).doesNotHaveDuplicates();957 * assertThat(new double[] { 1.0, 1.1 }).usingComparatorWithPrecision(0.01)958 * .doesNotHaveDuplicates();959 *960 * // assertion will fail961 * assertThat(new double[] { 1.0, 1.0, 2.0, 3.0 }).doesNotHaveDuplicates();962 * assertThat(new double[] { 1.0, 1.1 }).usingComparatorWithPrecision(0.5)963 * .doesNotHaveDuplicates();</code></pre>964 *965 * @return {@code this} assertion object.966 * @throws AssertionError if the actual array is {@code null}.967 * @throws AssertionError if the actual array contains duplicates.968 */969 public SELF doesNotHaveDuplicates() {970 arrays.assertDoesNotHaveDuplicates(info, actual);971 return myself;972 }973 /**974 * Verifies that the actual array does not contain duplicates.975 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.976 * <p>977 * Example:978 * <pre><code class='java'> // assertion will pass979 * assertThat(new double[] { 1.0, 2.0, 3.0 }).doesNotHaveDuplicates(withPrecision(0.1));980 * assertThat(new double[] { 1.1, 1.2, 1.3 }).doesNotHaveDuplicates(withPrecision(0.05));981 *982 * // assertion will fail983 * assertThat(new double[] { 1.0, 1.01, 2.0 }).doesNotHaveDuplicates(withPrecision(0.1));</code></pre>984 *985 * @param precision the precision under which the values may vary.986 * @return {@code this} assertion object.987 * @throws AssertionError if the actual array is {@code null}.988 * @throws AssertionError if the actual array contains duplicates.989 */990 public SELF doesNotHaveDuplicates(Offset<Double> precision) {991 return usingComparatorWithPrecision(precision.value).doesNotHaveDuplicates();992 }993 /**994 * Verifies that the actual array starts with the given sequence of values, without any other values between them.995 * Similar to <code>{@link #containsSequence(double...)}</code>, but it also verifies that the first element in the996 * sequence is also first element of the actual array.997 * <p>998 * If you want to set a precision for the comparison either use {@link #startsWith(double[], Offset)}999 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.1000 * <p>1001 * Example:1002 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1003 *1004 * // assertion will pass1005 * assertThat(values).startsWith(1.0, 2.0)1006 * .usingComparatorWithPrecision(0.5)1007 * .startsWith(1.1, 2.1);1008 *1009 * // assertion will fail1010 * assertThat(values).startsWith(2.0, 3.0);</code></pre>1011 *1012 * @param sequence the sequence of values to look for.1013 * @return {@code this} assertion object.1014 * @throws NullPointerException if the given argument is {@code null}.1015 * @throws IllegalArgumentException if the given argument is an empty array.1016 * @throws AssertionError if the actual array is {@code null}.1017 * @throws AssertionError if the actual array does not start with the given sequence.1018 */1019 public SELF startsWith(double... sequence) {1020 arrays.assertStartsWith(info, actual, sequence);1021 return myself;1022 }1023 /**1024 * Verifies that the actual array starts with the given sequence of values, without any other values between them.1025 * Similar to <code>{@link #containsSequence(Double[])}</code>, but it also verifies that the first element in the1026 * sequence is also first element of the actual array.1027 * <p>1028 * Example:1029 * <pre><code class='java'> // assertion will pass1030 * assertThat(new double[] { 1.0, 2.0, 2.0, 1.0 }).startsWith(new Double[] { 1.0, 2.0 });1031 *1032 * // assertion will fail1033 * assertThat(new double[] { 1.0, 2.0, 2.0, 1.0 }).startsWith(new Double[] { 2.0, 2.0 });</code></pre>1034 *1035 * @param sequence the sequence of values to look for.1036 * @return myself assertion object.1037 * @throws NullPointerException if the given argument is {@code null}.1038 * @throws IllegalArgumentException if the given argument is an empty array.1039 * @throws AssertionError if the actual array is {@code null}.1040 * @throws AssertionError if the actual array does not start with the given sequence.1041 * @since 3.19.01042 */1043 public SELF startsWith(Double[] sequence) {1044 requireNonNullParameter(sequence, "sequence");1045 arrays.assertStartsWith(info, actual, toPrimitiveDoubleArray(sequence));1046 return myself;1047 }1048 /**1049 * Verifies that the actual array starts with the given sequence of values, without any other values between them.1050 * Similar to <code>{@link #containsSequence(double...)}</code>, but it also verifies that the first element in the1051 * sequence is also first element of the actual array.1052 * <p>1053 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.1054 * <p>1055 * Example:1056 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1057 *1058 * // assertion will pass1059 * assertThat(values).startsWith(new double[] {1.01, 2.01}, withPrecision(0.1));1060 *1061 * // assertions will fail1062 * assertThat(values).startsWith(new double[] {2.0, 1.0}, withPrecision(0.1))1063 * assertThat(values).startsWith(new double[] {1.1, 2.1}, withPrecision(0.5))</code></pre>1064 *1065 * @param values the sequence of values to look for.1066 * @param precision the precision under which the values may vary.1067 * @return {@code this} assertion object.1068 * @throws NullPointerException if the given argument is {@code null}.1069 * @throws IllegalArgumentException if the given argument is an empty array.1070 * @throws AssertionError if the actual array is {@code null}.1071 * @throws AssertionError if the actual array does not end with the given sequence.1072 */1073 public SELF startsWith(double[] values, Offset<Double> precision) {1074 return usingComparatorWithPrecision(precision.value).startsWith(values);1075 }1076 /**1077 * Verifies that the actual array starts with the given sequence of values, without any other values between them.1078 * Similar to <code>{@link #containsSequence(double...)}</code>, but it also verifies that the first element in the1079 * sequence is also first element of the actual array.1080 * <p>1081 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.1082 * <p>1083 * Example:1084 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1085 *1086 * // assertion will pass1087 * assertThat(values).startsWith(new Double[] { 1.01, 2.01 }, withPrecision(0.1));1088 *1089 * // assertions will fail1090 * assertThat(values).startsWith(new Double[] { 2.0, 1.0 }, withPrecision(0.1))1091 * assertThat(values).startsWith(new Double[] { 1.1, 2.1 }, withPrecision(0.5))</code></pre>1092 *1093 * @param values the sequence of values to look for.1094 * @param precision the precision under which the values may vary.1095 * @return {@code this} assertion object.1096 * @throws NullPointerException if the given argument is {@code null}.1097 * @throws IllegalArgumentException if the given argument is an empty array.1098 * @throws AssertionError if the actual array is {@code null}.1099 * @throws AssertionError if the actual array does not end with the given sequence.1100 * @since 3.19.01101 */1102 public SELF startsWith(Double[] values, Offset<Double> precision) {1103 return usingComparatorWithPrecision(precision.value).startsWith(toPrimitiveDoubleArray(values));1104 }1105 /**1106 * Verifies that the actual array ends with the given sequence of values, without any other values between them.1107 * Similar to <code>{@link #containsSequence(double...)}</code>, but it also verifies that the last element in the1108 * sequence is also last element of the actual array.1109 * <p>1110 * If you want to set a precision for the comparison either use {@link #endsWith(double[], Offset)}1111 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.1112 * <p>1113 * Example:1114 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1115 *1116 * // assertion will pass1117 * assertThat(values).endsWith(2.0, 3.0)1118 * .usingComparatorWithPrecision(0.5)1119 * .endsWith(2.1, 3.1);1120 *1121 * // assertion will fail1122 * assertThat(values).endsWith(1.0, 3.0);</code></pre>1123 *1124 * @param sequence the sequence of values to look for.1125 * @return {@code this} assertion object.1126 * @throws NullPointerException if the given argument is {@code null}.1127 * @throws IllegalArgumentException if the given argument is an empty array.1128 * @throws AssertionError if the actual array is {@code null}.1129 * @throws AssertionError if the actual array does not end with the given sequence.1130 */1131 public SELF endsWith(double... sequence) {1132 arrays.assertEndsWith(info, actual, sequence);1133 return myself;1134 }1135 /**1136 * Verifies that the actual array ends with the given sequence of values, without any other values between them.1137 * Similar to <code>{@link #containsSequence(Double[])}</code>, but it also verifies that the last element in the1138 * sequence is also last element of the actual array.1139 * <p>1140 * Example:1141 * <pre><code class='java'> // assertion will pass1142 * assertThat(new double[] { 1.0, 2.0, 2.0, 1.0 }).endsWith(new Double[] { 2.0, 1.0 });1143 *1144 * // assertion will fail1145 * assertThat(new double[] { 1.0, 2.0, 2.0, 1.0 }).endsWith(new Double[] { 1.0, 2.0 });</code></pre>1146 *1147 * @param sequence the sequence of values to look for.1148 * @return myself assertion object.1149 * @throws NullPointerException if the given argument is {@code null}.1150 * @throws IllegalArgumentException if the given argument is an empty array.1151 * @throws AssertionError if the actual array is {@code null}.1152 * @throws AssertionError if the actual array does not end with the given sequence.1153 * @since 3.19.01154 */1155 public SELF endsWith(Double[] sequence) {1156 requireNonNullParameter(sequence, "sequence");1157 arrays.assertEndsWith(info, actual, toPrimitiveDoubleArray(sequence));1158 return myself;1159 }1160 /**1161 * Verifies that the actual array ends with the given sequence of values, without any other values between them.1162 * Similar to <code>{@link #containsSequence(double...)}</code>, but it also verifies that the last element in the1163 * sequence is also last element of the actual array.1164 * <p>1165 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.1166 * <p>1167 * Example:1168 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1169 *1170 * // assertion will pass1171 * assertThat(values).endsWith(new double[] {2.01, 3.01}, withPrecision(0.1));1172 *1173 * // assertion will fail1174 * assertThat(values).endsWith(new double[] {3.0, 2.0}, withPrecision(0.1))1175 * assertThat(values).endsWith(new double[] {2.1, 3.1}, withPrecision(0.5))</code></pre>1176 *1177 * @param values the sequence of values to look for.1178 * @param precision the precision under which the values may vary.1179 * @return {@code this} assertion object.1180 * @throws NullPointerException if the given argument is {@code null}.1181 * @throws IllegalArgumentException if the given argument is an empty array.1182 * @throws AssertionError if the actual array is {@code null}.1183 * @throws AssertionError if the actual array does not end with the given sequence.1184 */1185 public SELF endsWith(double[] values, Offset<Double> precision) {1186 return usingComparatorWithPrecision(precision.value).endsWith(values);1187 }1188 /**1189 * Verifies that the actual array ends with the given sequence of values, without any other values between them.1190 * Similar to <code>{@link #containsSequence(double...)}</code>, but it also verifies that the last element in the1191 * sequence is also last element of the actual array.1192 * <p>1193 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Double)}.1194 * <p>1195 * Example:1196 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1197 *1198 * // assertion will pass1199 * assertThat(values).endsWith(new Double[] { 2.01, 3.01 }, withPrecision(0.1));1200 *1201 * // assertion will fail1202 * assertThat(values).endsWith(new Double[] { 3.0, 2.0 }, withPrecision(0.1))1203 * assertThat(values).endsWith(new Double[] { 2.1, 3.1 }, withPrecision(0.5))</code></pre>1204 *1205 * @param values the sequence of values to look for.1206 * @param precision the precision under which the values may vary.1207 * @return {@code this} assertion object.1208 * @throws NullPointerException if the given argument is {@code null}.1209 * @throws IllegalArgumentException if the given argument is an empty array.1210 * @throws AssertionError if the actual array is {@code null}.1211 * @throws AssertionError if the actual array does not end with the given sequence.1212 * @since 3.19.01213 */1214 public SELF endsWith(Double[] values, Offset<Double> precision) {1215 return usingComparatorWithPrecision(precision.value).endsWith(toPrimitiveDoubleArray(values));1216 }1217 /** {@inheritDoc} */1218 @Override1219 public SELF isSorted() {1220 arrays.assertIsSorted(info, actual);1221 return myself;1222 }1223 /** {@inheritDoc} */1224 @Override1225 public SELF isSortedAccordingTo(Comparator<? super Double> comparator) {1226 arrays.assertIsSortedAccordingToComparator(info, actual, comparator);1227 return myself;1228 }1229 /** {@inheritDoc} */1230 @Override1231 @CheckReturnValue1232 public SELF usingElementComparator(Comparator<? super Double> customComparator) {1233 this.arrays = new DoubleArrays(new ComparatorBasedComparisonStrategy(customComparator));1234 return myself;1235 }1236 /** {@inheritDoc} */1237 @Override1238 @CheckReturnValue1239 public SELF usingDefaultElementComparator() {1240 this.arrays = DoubleArrays.instance();1241 return myself;1242 }1243 /**1244 * <p>1245 * Verifies that the actual group contains only the given values and nothing else, <b>in order</b>.1246 * <p>1247 * If you want to set a precision for the comparison either use {@link #containsExactly(double[], Offset)}1248 * or {@link #usingComparatorWithPrecision(Double)} before calling the assertion.1249 * <p>1250 * Example :1251 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1252 *1253 * // assertions will pass1254 * assertThat(values).containsExactly(1.0, 2.0, 3.0)1255 * .usingComparatorWithPrecision(0.2)1256 * .containsExactly(1.1, 2.1, 2.9);1257 *1258 * // assertion will fail as actual and expected order differ1259 * assertThat(values).containsExactly(2.0, 1.0, 3.0);</code></pre>1260 *1261 * @param values the given values.1262 * @return {@code this} assertion object.1263 * @throws NullPointerException if the given argument is {@code null}.1264 * @throws AssertionError if the actual group is {@code null}.1265 * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group1266 * contains some or none of the given values, or the actual group contains more values than the given ones1267 * or values are the same but the order is not.1268 */1269 public SELF containsExactly(double... values) {1270 arrays.assertContainsExactly(info, actual, values);1271 return myself;1272 }1273 /**1274 * Verifies that the actual group contains only the values of the given array and nothing else, <b>in order</b>.1275 * <p>1276 * Example :1277 * <pre><code class='java'> // assertion will pass1278 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsExactly(new Double[] { 1.0, 2.0, 1.0 });1279 *1280 * // assertion will fail as actual and expected order differ1281 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsExactly(new Double[] { 2.0, 1.0, 1.0 });</code></pre>1282 *1283 * @param values the given values.1284 * @return {@code this} assertion object.1285 * @throws NullPointerException if the given argument is {@code null}.1286 * @throws AssertionError if the actual group is {@code null}.1287 * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group1288 * contains some or none of the given values, or the actual group contains more values than the given ones1289 * or values are the same but the order is not.1290 * @since 3.19.01291 */1292 public SELF containsExactly(Double[] values) {1293 requireNonNullParameter(values, "values");1294 arrays.assertContainsExactly(info, actual, toPrimitiveDoubleArray(values));1295 return myself;1296 }1297 /**1298 * Verifies that the actual group contains exactly the given values and nothing else, <b>in any order</b>.<br>1299 * <p>1300 * Example :1301 * <pre><code class='java'> // assertions will pass1302 * assertThat(new double[] { 1.0, 2.0 }).containsExactlyInAnyOrder(1.0, 2.0);1303 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsExactlyInAnyOrder(1.0, 1.0, 2.0);1304 *1305 * // assertions will fail1306 * assertThat(new double[] { 1.0, 2.0 }).containsExactlyInAnyOrder(1.0);1307 * assertThat(new double[] { 1.0 }).containsExactlyInAnyOrder(1.0, 2.0);1308 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsExactlyInAnyOrder(1.0, 2.0);</code></pre>1309 *1310 * @param values the given values.1311 * @return {@code this} assertion object.1312 * @throws NullPointerException if the given argument is {@code null}.1313 * @throws AssertionError if the actual group is {@code null}.1314 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group1315 * contains some or none of the given values, or the actual group contains more values than the given ones.1316 * @since 2.6.0 / 3.6.01317 */1318 public SELF containsExactlyInAnyOrder(double... values) {1319 arrays.assertContainsExactlyInAnyOrder(info, actual, values);1320 return myself;1321 }1322 /**1323 * Verifies that the actual group contains exactly the values of the given array and nothing else, <b>in any order</b>.<br>1324 * <p>1325 * Example :1326 * <pre><code class='java'> // assertions will pass1327 * assertThat(new double[] { 1.0, 2.0 }).containsExactlyInAnyOrder(new Double[] { 2.0, 1.0 });1328 * assertThat(new double[] { 1.0, 2.0, 1.0 }).containsExactlyInAnyOrder(new Double[] { 1.0, 1.0, 2.0 });1329 *1330 * // assertions will fail1331 * assertThat(new double[] { 1.0, 2.0 }).containsExactlyInAnyOrder(new Double[] { 1.0 });1332 * assertThat(new double[] { 1.0 }).containsExactlyInAnyOrder(new Double[] { 2.0, 1.0 });1333 * assertThat(new double[] { 1.0, 1.0, 2.0 }).containsExactlyInAnyOrder(new Double[] { 2.0, 1.0 });</code></pre>1334 *1335 * @param values the given values.1336 * @return {@code this} assertion object.1337 * @throws NullPointerException if the given argument is {@code null}.1338 * @throws AssertionError if the actual group is {@code null}.1339 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group1340 * contains some or none of the given values, or the actual group contains more values than the given ones.1341 * @since 3.19.01342 */1343 public SELF containsExactlyInAnyOrder(Double[] values) {1344 requireNonNullParameter(values, "values");1345 arrays.assertContainsExactlyInAnyOrder(info, actual, toPrimitiveDoubleArray(values));1346 return myself;1347 }1348 /**1349 * Verifies that the actual group contains only the given values and nothing else, <b>in order</b>.1350 * The values may vary with a specified precision.1351 * <p>1352 * Example :1353 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1354 *1355 * // assertion will pass1356 * assertThat(values).containsExactly(new double[] {1.0, 1.98, 3.01}, withPrecision(0.05));1357 *1358 * // assertion fails because |1.0 -1.1| &gt; 0.05 (precision).1359 * assertThat(values).containsExactly(new double[] {1.1, 2.0, 3.01}, withPrecision(0.05));1360 *1361 * // assertion will fail as actual and expected order differ1362 * assertThat(values).containsExactly(new double[] {1.98, 1.0, 3.01}, withPrecision(0.05));</code></pre>1363 *1364 * @param values the given values.1365 * @param precision the precision under which the values may vary.1366 * @return {@code this} assertion object.1367 * @throws NullPointerException if the given argument is {@code null}.1368 * @throws AssertionError if the actual group is {@code null}.1369 * @throws AssertionError if the actual group does not contain the given values within the specified precision1370 * with same order, i.e. the actual group contains some or none of the given values, or the actual group contains1371 * more values than the given ones or values are the same but the order is not.1372 */1373 public SELF containsExactly(double[] values, Offset<Double> precision) {1374 return usingComparatorWithPrecision(precision.value).containsExactly(values);1375 }1376 /**1377 * Verifies that the actual group contains only the values of the given array and nothing else, <b>in order</b>.1378 * The values may vary with a specified precision.1379 * <p>1380 * Example :1381 * <pre><code class='java'> double[] values = new double[] { 1.0, 2.0, 3.0 };1382 *1383 * // assertion will pass1384 * assertThat(values).containsExactly(new Double[] { 1.0, 1.98, 3.01 }, withPrecision(0.05));1385 *1386 * // assertion fails because |1.0 -1.1| &gt; 0.05 (precision).1387 * assertThat(values).containsExactly(new Double[] { 1.1, 2.0, 3.01 }, withPrecision(0.05));1388 *1389 * // assertion will fail as actual and expected order differ1390 * assertThat(values).containsExactly(new Double[] { 1.98, 1.0, 3.01 }, withPrecision(0.05));</code></pre>1391 *1392 * @param values the given values.1393 * @param precision the precision under which the values may vary.1394 * @return {@code this} assertion object.1395 * @throws NullPointerException if the given argument is {@code null}.1396 * @throws AssertionError if the actual group is {@code null}.1397 * @throws AssertionError if the actual group does not contain the given values within the specified precision1398 * with same order, i.e. the actual group contains some or none of the given values, or the actual group contains1399 * more values than the given ones or values are the same but the order is not.1400 * @since 3.19.01401 */1402 public SELF containsExactly(Double[] values, Offset<Double> precision) {1403 return usingComparatorWithPrecision(precision.value).containsExactly(toPrimitiveDoubleArray(values));1404 }1405 /**1406 * Create a {@link Double} comparator which compares double at the given precision and pass it to {@link #usingElementComparator(Comparator)}.1407 * All the following assertions will use this comparator to compare double[] elements.1408 *1409 * @param precision precision used to compare {@link Double}.1410 * @return {@code this} assertion object.1411 */1412 @CheckReturnValue1413 public SELF usingComparatorWithPrecision(Double precision) {1414 return usingElementComparator(ComparatorFactory.INSTANCE.doubleComparatorWithPrecision(precision));1415 }1416 /**1417 * Verifies that the actual array contains at least one of the given values.1418 * <p>1419 * Example :1420 * <pre><code class='java'> double[] oneTwoThree = { 1.0, 2.0, 3.0 };1421 *1422 * // assertions will pass1423 * assertThat(oneTwoThree).containsAnyOf(2.0)1424 * .containsAnyOf(2.0, 3.0)1425 * .containsAnyOf(1.0, 2.0, 3.0)1426 * .containsAnyOf(1.0, 2.0, 3.0, 4.0)1427 * .containsAnyOf(5.0, 6.0, 7.0, 2.0);1428 *1429 * // assertions will fail1430 * assertThat(oneTwoThree).containsAnyOf(4.0);1431 * assertThat(oneTwoThree).containsAnyOf(4.0, 5.0, 6.0, 7.0);</code></pre>1432 *1433 * @param values the values whose at least one which is expected to be in the array under test.1434 * @return {@code this} assertion object.1435 * @throws NullPointerException if the array of values is {@code null}.1436 * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty.1437 * @throws AssertionError if the array under test is {@code null}.1438 * @throws AssertionError if the array under test does not contain any of the given {@code values}.1439 * @since 2.9.0 / 3.9.01440 */1441 public SELF containsAnyOf(double... values) {1442 arrays.assertContainsAnyOf(info, actual, values);1443 return myself;1444 }1445 /**1446 * Verifies that the actual array contains at least one of the values of the given array.1447 * <p>1448 * Example :1449 * <pre><code class='java'>1450 *1451 * // assertions will pass1452 * assertThat(new double[] { 1.0, 1.0, 1.0 }).containsAnyOf(new Double[] { 1.0 })1453 * assertThat(new double[] { 1.0, 1.0, 1.0 }).containsAnyOf(new Double[] { 2.0, 2.0, 2.0, 1.0 });1454 *1455 * // assertions will fail1456 * assertThat(new double[] { 1.0, 2.0, 3.0 }).containsAnyOf(new Double[] { 8.0 });1457 * assertThat(new double[] { 1.0, 2.0, 3.0 }).containsAnyOf(new Double[] { 12.0, 11.0, 15.0 };</code></pre>1458 *1459 * @param values the values whose at least one which is expected to be in the array under test.1460 * @return {@code this} assertion object.1461 * @throws NullPointerException if the array of values is {@code null}.1462 * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty.1463 * @throws AssertionError if the array under test is {@code null}.1464 * @throws AssertionError if the array under test does not contain any of the given {@code values}.1465 * @since 3.19.01466 */1467 public SELF containsAnyOf(Double[] values) {1468 requireNonNullParameter(values, "values");1469 arrays.assertContainsAnyOf(info, actual, toPrimitiveDoubleArray(values));1470 return myself;1471 }1472 private static double[] toPrimitiveDoubleArray(Double[] values) {1473 return Arrays.stream(values).mapToDouble(Double::doubleValue).toArray();1474 }1475}...

Full Screen

Full Screen

toPrimitiveDoubleArray

Using AI Code Generation

copy

Full Screen

1[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:testCompile (default-testCompile) on project assertj-examples: Compilation failure: Compilation failure: 2[ERROR] symbol: method assertThat(double[])3[ERROR] symbol: method assertThat(double[])4[ERROR] symbol: method assertThat(double[])5[ERROR] symbol: method assertThat(double[])6[ERROR] symbol: method assertThat(double[])

Full Screen

Full Screen

toPrimitiveDoubleArray

Using AI Code Generation

copy

Full Screen

1double[] actual = new double[] { 1.0, 2.0, 3.0 };2assertThat(actual).usingDefaultComparator().contains(1.0, atIndex(0));3double[] actual = new double[] { 1.0, 2.0, 3.0 };4assertThat(actual).usingDefaultComparator().usingElementComparator(new Comparator<Double>() {5 public int compare(Double o1, Double o2) {6 return Double.compare(o1, o2);7 }8}).contains(1.0, atIndex(0));9double[] actual = new double[] { 1.0, 2.0, 3.0 };10assertThat(actual).usingDefaultComparator().usingElementComparator(new Comparator<Double>() {11 public int compare(Double o1, Double o2) {12 return Double.compare(o1, o2);13 }14}).usingComparatorForType(new Comparator<Double>() {15 public int compare(Double o1, Double o2) {16 return Double.compare(o1, o2);17 }18}).contains(1.0, atIndex(0));19double[] actual = new double[] { 1.0, 2.0, 3.0 };20assertThat(actual).usingDefaultComparator().usingElementComparator(new Comparator<Double>() {21 public int compare(Double o1, Double o2) {22 return Double.compare(o1, o2);23 }24}).usingComparatorForType(new Comparator<Double>() {25 public int compare(Double o1, Double o2) {26 return Double.compare(o1, o2);27 }28}).usingComparatorForElementFieldsWithType(new Comparator<Double>() {29 public int compare(Double o1, Double o2) {30 return Double.compare(o1, o2);31 }32}, Double.class).contains(1.0, atIndex(0));33double[] actual = new double[] { 1.0, 2.0, 3.0 };34assertThat(actual).usingDefaultComparator().usingElementComparator(new Comparator<Double>() {35 public int compare(Double o1, Double o2) {36 return Double.compare(o1, o2);37 }38}).usingComparatorForType(new Comparator<Double>() {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful