Best Assertj code snippet using org.assertj.core.api.AbstractFloatArrayAssert.toPrimitiveFloatArray
Source:AbstractFloatArrayAssert.java
...228 * @since 3.19.0229 */230 public SELF contains(Float[] values) {231 requireNonNullParameter(values, "values");232 arrays.assertContains(info, actual, toPrimitiveFloatArray(values));233 return myself;234 }235 /**236 * Verifies that the actual array contains the given values, in any order,237 * the comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.238 * <p>239 * Examples :240 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};241 *242 * // assertion will pass243 * assertThat(values).contains(new float[] { 1.01f, 3.01f, 2.0f }, withPrecision(0.02f));244 *245 * // assertions will fail246 * assertThat(values).contains(new float[] { 1.0f, 4.0f }, withPrecision(0.5f));247 * assertThat(values).contains(new float[] { 4.0f, 7.0f }, withPrecision(2f));</code></pre>248 *249 * @param values the given values.250 * @param precision the precision under which the values may vary.251 * @return {@code this} assertion object.252 * @throws NullPointerException if the given argument is {@code null}.253 * @throws IllegalArgumentException if the given argument is an empty array.254 * @throws AssertionError if the actual array is {@code null}.255 * @throws AssertionError if the actual array does not contain the given values.256 */257 public SELF contains(float[] values, Offset<Float> precision) {258 return usingComparatorWithPrecision(precision.value).contains(values);259 }260 /**261 * Verifies that the actual array contains the values of the given array, in any order,262 * the comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.263 * <p>264 * Examples :265 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };266 *267 * // assertion will pass268 * assertThat(values).contains(new Float[] { 1.01f, 3.01f, 2.0f }, withPrecision(0.02f));269 *270 * // assertions will fail271 * assertThat(values).contains(new Float[] { 1.0f, 4.0f }, withPrecision(0.5f));272 * assertThat(values).contains(new Float[] { 4.0f, 7.0f }, withPrecision(2f));</code></pre>273 *274 * @param values the given values.275 * @param precision the precision under which the values may vary.276 * @return {@code this} assertion object.277 * @throws NullPointerException if the given argument is {@code null}.278 * @throws IllegalArgumentException if the given argument is an empty array.279 * @throws AssertionError if the actual array is {@code null}.280 * @throws AssertionError if the actual array does not contain the given values.281 * @since 3.19.0282 */283 public SELF contains(Float[] values, Offset<Float> precision) {284 return usingComparatorWithPrecision(precision.value).contains(toPrimitiveFloatArray(values));285 }286 /**287 * Verifies that the actual array contains only the given values and nothing else, in any order.288 * <p>289 * If you want to set a precision for the comparison either use {@link #containsOnly(float[], Offset)}290 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.291 * <p>292 * Examples :293 * <pre><code class='java'> float[] values = new double[] {1.0f, 2.0f, 3.0f};294 *295 * // assertions will pass296 * assertThat(values).containsOnly(1.0f, 2.0f, 3.0f)297 * .containsOnly(2.0f, 3.0f, 1.0f)298 * .usingComparatorWithPrecision(0.5f)299 * .containsOnly(1.1f, 3.1f, 2.1f);300 301 * // assertions will fail302 * assertThat(values).containsOnly(1.0f, 4.0f, 2.0f, 3.0f);303 * assertThat(values).containsOnly(4.0f, 7.0f);304 * assertThat(values).containsOnly(1.1f, 2.1f, 3.1f);305 * assertThat(values).usingComparatorWithPrecision(0.01f)306 * .containsOnly(1.1f, 2.1f, 3.1f);</code></pre>307 *308 * @param values the given values.309 * @return {@code this} assertion object.310 * @throws NullPointerException if the given argument is {@code null}.311 * @throws IllegalArgumentException if the given argument is an empty array.312 * @throws AssertionError if the actual array is {@code null}.313 * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some314 * or none of the given values, or the actual array contains more values than the given ones.315 */316 public SELF containsOnly(float... values) {317 arrays.assertContainsOnly(info, actual, values);318 return myself;319 }320 /**321 * Verifies that the actual array contains only the values of the given array and nothing else, in any order.322 * <p>323 * Example:324 * <pre><code class='java'> // assertions will pass325 * assertThat(new float[] { 1.0f, 2.0f }).containsOnly(new Float[] { 1.0f, 2.0f });326 * assertThat(new float[] { 2.0f, 1.0f }).containsOnly(new Float[] { 1.0f, 2.0f });327 * assertThat(new float[] { 1.0f, 1.0f, 2.0f }).containsOnly(new Float[] { 1.0f, 2.0f });328 *329 * // assertions will fail330 * assertThat(new float[] { 1.0f, 2.0f }).containsOnly(new Float[] { 2.0f });331 * assertThat(new float[] { 1.0f }).containsOnly(new Float[] { 1.0f, 2.0f });</code></pre>332 *333 * @param values the given values.334 * @return {@code this} assertion object.335 * @throws NullPointerException if the given argument is {@code null}.336 * @throws IllegalArgumentException if the given argument is an empty array.337 * @throws AssertionError if the actual array is {@code null}.338 * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some339 * or none of the given values, or the actual array contains more values than the given ones.340 * @since 3.19.0341 */342 public SELF containsOnly(Float[] values) {343 requireNonNullParameter(values, "values");344 arrays.assertContainsOnly(info, actual, toPrimitiveFloatArray(values));345 return myself;346 }347 /**348 * Verifies that the actual array contains only the given values and nothing else, in any order.349 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.350 * <p>351 * Examples :352 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};353 *354 * // assertion will pass355 * assertThat(values).containsOnly(new float[] {1.0f, 2.0f, 3.0f }, withPrecision(0.00001f))356 * .containsOnly(new float[] {2.0,f 3.0f, 0.7f}, withPrecision(0.5f));357 *358 * // assertions will fail359 * assertThat(values).containsOnly(new float[] {1.0f, 4.0f, 2.0f, 3.0f}, withPrecision(0.5f));360 * assertThat(values).containsOnly(new float[] {4.0f, 7.0f}, withPrecision(0.2f));</code></pre>361 *362 * @param values the given values.363 * @param precision the precision under which the values may vary.364 * @return {@code this} assertion object.365 * @throws NullPointerException if the given argument is {@code null}.366 * @throws IllegalArgumentException if the given argument is an empty array.367 * @throws AssertionError if the actual array is {@code null}.368 * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some369 * or none of the given values, or the actual array contains more values than the given ones.370 */371 public SELF containsOnly(float[] values, Offset<Float> precision) {372 return usingComparatorWithPrecision(precision.value).containsOnly(values);373 }374 /**375 * Verifies that the actual array contains only the values of the given array and nothing else, in any order.376 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.377 * <p>378 * Examples :379 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };380 *381 * // assertion will pass382 * assertThat(values).containsOnly(new Float[] { 1.0f, 2.0f, 3.0f }, withPrecision(0.00001f))383 * .containsOnly(new Float[] { 2.0,f 3.0f, 0.7f }, withPrecision(0.5f));384 *385 * // assertions will fail386 * assertThat(values).containsOnly(new Float[] { 1.0f, 4.0f, 2.0f, 3.0f }, withPrecision(0.5f));387 * assertThat(values).containsOnly(new Float[] { 4.0f, 7.0f }, withPrecision(0.2f));</code></pre>388 *389 * @param values the given values.390 * @param precision the precision under which the values may vary.391 * @return {@code this} assertion object.392 * @throws NullPointerException if the given argument is {@code null}.393 * @throws IllegalArgumentException if the given argument is an empty array.394 * @throws AssertionError if the actual array is {@code null}.395 * @throws AssertionError if the actual array does not contain the given values, i.e. the actual array contains some396 * or none of the given values, or the actual array contains more values than the given ones.397 * @since 3.19.0398 */399 public SELF containsOnly(Float[] values, Offset<Float> precision) {400 return usingComparatorWithPrecision(precision.value).containsOnly(toPrimitiveFloatArray(values));401 }402 /**403 * Verifies that the actual array contains the given values only once.404 * <p>405 * If you want to set a precision for the comparison either use {@link #containsOnlyOnce(float[], Offset)}406 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.407 * <p>408 * Examples :409 * <pre><code class='java'> // assertions will pass410 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(1.0f, 2.0f)411 * .usingComparatorWithPrecision(0.5f)412 * .containsOnlyOnce(1.1f, 3.1f, 2.1f);413 *414 * // assertions will fail415 * assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(1.0f);416 * assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(1.0f, 2.0f);417 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(4.0f);418 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).usingComparatorWithPrecision(0.05f)419 * .containsOnlyOnce(1.1f, 2.1f);</code></pre>420 *421 * @param values the given values.422 * @return {@code this} assertion object.423 * @throws NullPointerException if the given argument is {@code null}.424 * @throws IllegalArgumentException if the given argument is an empty array.425 * @throws AssertionError if the actual array is {@code null}.426 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some427 * or none of the given values, or the actual group contains more than once these values.428 */429 public SELF containsOnlyOnce(float... values) {430 arrays.assertContainsOnlyOnce(info, actual, values);431 return myself;432 }433 /**434 * Verifies that the actual array contains the values of the given array only once.435 * <p>436 * Examples :437 * <pre><code class='java'> // assertion will pass438 * assertThat(new float[] { 1.0f, 2.0f }).containsOnlyOnce(new Float[] { 1.0f, 2.0f });439 *440 * // assertions will fail441 * assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(new Float[] { 1.0f });442 * assertThat(new float[] { 1.0f }).containsOnlyOnce(new Float[] { 2.0f });443 * assertThat(new float[] { 1.0f }).containsOnlyOnce(new Float[] { 1.0f, 2.0f });</code></pre>444 *445 * @param values the given values.446 * @return {@code this} assertion object.447 * @throws NullPointerException if the given argument is {@code null}.448 * @throws IllegalArgumentException if the given argument is an empty array.449 * @throws AssertionError if the actual array is {@code null}.450 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some451 * or none of the given values, or the actual group contains more than once these values.452 * @since 3.19.0453 */454 public SELF containsOnlyOnce(Float[] values) {455 requireNonNullParameter(values, "values");456 arrays.assertContainsOnlyOnce(info, actual, toPrimitiveFloatArray(values));457 return myself;458 }459 /**460 * Verifies that the actual array contains the given values only once.461 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.462 * <p>463 * Examples :464 * <pre><code class='java'> // assertion will pass465 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(new float[] {1.1f, 2.0f}, withPrecision(0.2f));466 *467 * // assertions will fail468 * assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(new float[] {1.05f}, withPrecision(0.1f));469 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(new float[] {4.0f}, withPrecision(0.1f));470 * assertThat(new float[] { 1.0f, 2.0f, 3.0f, 3.0f }).containsOnlyOnce(new float[] {0.1f, 0.9f, 2.0f, 3.11f, 4.0f, 5.0f}, withPrecision(0.2f));</code></pre>471 *472 * @param values the given values.473 * @param precision the precision under which the values may vary.474 * @return {@code this} assertion object.475 * @throws NullPointerException if the given argument is {@code null}.476 * @throws IllegalArgumentException if the given argument is an empty array.477 * @throws AssertionError if the actual array is {@code null}.478 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some479 * or none of the given values, or the actual group contains more than once these values.480 */481 public SELF containsOnlyOnce(float[] values, Offset<Float> precision) {482 return usingComparatorWithPrecision(precision.value).containsOnlyOnce(values);483 }484 /**485 * Verifies that the actual array contains the values of the given array only once.486 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.487 * <p>488 * Examples :489 * <pre><code class='java'> // assertion will pass490 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(new Float[] { 1.1f, 2.0f }, withPrecision(0.2f));491 *492 * // assertions will fail493 * assertThat(new float[] { 1.0f, 2.0f, 1.0f }).containsOnlyOnce(new Float[] { 1.05f }, withPrecision(0.1f));494 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsOnlyOnce(new Float[] { 4.0f }, withPrecision(0.1f));495 * assertThat(new float[] { 1.0f, 2.0f, 3.0f, 3.0f }).containsOnlyOnce(new Float[] { 0.1f, 0.9f, 2.0f, 3.11f, 4.0f, 5.0f }, withPrecision(0.2f));</code></pre>496 *497 * @param values the given values.498 * @param precision the precision under which the values may vary.499 * @return {@code this} assertion object.500 * @throws NullPointerException if the given argument is {@code null}.501 * @throws IllegalArgumentException if the given argument is an empty array.502 * @throws AssertionError if the actual array is {@code null}.503 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group contains some504 * or none of the given values, or the actual group contains more than once these values.505 * @since 3.19.0506 */507 public SELF containsOnlyOnce(Float[] values, Offset<Float> precision) {508 return usingComparatorWithPrecision(precision.value).containsOnlyOnce(toPrimitiveFloatArray(values));509 }510 /**511 * Verifies that the actual array contains the given sequence, without any other values between them.512 * <p>513 * If you want to set a precision for the comparison either use {@link #containsSequence(float[], Offset)}514 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.515 * <p>516 * Examples :517 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };518 *519 * // assertion will pass520 * assertThat(values).containsSequence(1.0f, 2.0f)521 * .containsSequence(1.0f, 2.0f, 3.0f)522 * .containsSequence(2.0f, 3.0f)523 * .usingComparatorWithPrecision(0.5f)524 * .containsSequence(1.1f, 2.1f);525 *526 * // assertions will fail527 * assertThat(values).containsSequence(1.0f, 3.0f);528 * assertThat(values).containsSequence(4.0f, 7.0f);529 * assertThat(values).usingComparatorWithPrecision(0.01f)530 * .containsSequence(1.1f, 2.0f, 3.0f);</code></pre>531 *532 * @param sequence the sequence of values to look for.533 * @return {@code this} assertion object.534 * @throws AssertionError if the actual array is {@code null}.535 * @throws AssertionError if the given array is {@code null}.536 * @throws AssertionError if the actual array does not contain the given sequence.537 */538 public SELF containsSequence(float... sequence) {539 arrays.assertContainsSequence(info, actual, sequence);540 return myself;541 }542 /**543 * Verifies that the actual array contains the given sequence, without any other values between them.544 * <p>545 * Example:546 * <pre><code class='java'> // assertion will pass547 * assertThat(new float[] { 1.0f, 2.0f }).containsSequence(new Float[] { 1.0f, 2.0f });548 * assertThat(new float[] { 1.0f, 2.0f, 2.0f, 1.0f }).containsSequence(new Float[] { 2.0f, 1.0f });549 *550 * // assertion will fail551 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsSequence(new Float[] { 3.0f, 1.0f });</code></pre>552 *553 * @param sequence the sequence of values to look for.554 * @return myself assertion object.555 * @throws AssertionError if the actual array is {@code null}.556 * @throws AssertionError if the given array is {@code null}.557 * @throws AssertionError if the actual array does not contain the given sequence.558 * @since 3.19.0559 */560 public SELF containsSequence(Float[] sequence) {561 requireNonNullParameter(sequence, "sequence");562 arrays.assertContainsSequence(info, actual, toPrimitiveFloatArray(sequence));563 return myself;564 }565 /**566 * Verifies that the actual array contains the given sequence, without any other values between them.567 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.568 * <p>569 * Examples :570 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};571 *572 * // assertions will pass573 * assertThat(values).containsSequence(new float[] {1.07f, 2.0f}, withPrecision(0.1f))574 * .containsSequence(new float[] {1.1f, 2.1f, 3.0f}, withPrecision(0.2f))575 * .containsSequence(new float[] {2.2f, 3.0f}, withPrecision(0.3f));576 *577 * // assertions will fail578 * assertThat(values).containsSequence(new float[] {1.0f, 3.0f}, withPrecision(0.2f));579 * assertThat(values).containsSequence(new float[] {4.0f, 7.0f}, withPrecision(0.1f));</code></pre>580 *581 * @param sequence the sequence of values to look for.582 * @param precision the precision under which the values may vary.583 * @return {@code this} assertion object.584 * @throws AssertionError if the actual array is {@code null}.585 * @throws AssertionError if the given array is {@code null}.586 * @throws AssertionError if the actual array does not contain the given sequence.587 */588 public SELF containsSequence(float[] sequence, Offset<Float> precision) {589 return usingComparatorWithPrecision(precision.value).containsSequence(sequence);590 }591 /**592 * Verifies that the actual array contains the given sequence, without any other values between them.593 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.594 * <p>595 * Examples :596 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };597 *598 * // assertions will pass599 * assertThat(values).containsSequence(new Float[] { 1.07f, 2.0f }, withPrecision(0.1f))600 * .containsSequence(new Float[] { 1.1f, 2.1f, 3.0f }, withPrecision(0.2f))601 * .containsSequence(new Float[] { 2.2f, 3.0f }, withPrecision(0.3f));602 *603 * // assertions will fail604 * assertThat(values).containsSequence(new Float[] { 1.0f, 3.0f }, withPrecision(0.2f));605 * assertThat(values).containsSequence(new Float[] { 4.0f, 7.0f }, withPrecision(0.1f));</code></pre>606 *607 * @param sequence the sequence of values to look for.608 * @param precision the precision under which the values may vary.609 * @return {@code this} assertion object.610 * @throws AssertionError if the actual array is {@code null}.611 * @throws AssertionError if the given array is {@code null}.612 * @throws AssertionError if the actual array does not contain the given sequence.613 * @since 3.19.0614 */615 public SELF containsSequence(Float[] sequence, Offset<Float> precision) {616 return usingComparatorWithPrecision(precision.value).containsSequence(toPrimitiveFloatArray(sequence));617 }618 /**619 * Verifies that the actual array contains the given subsequence (possibly with other values between them).620 * <p>621 * If you want to set a precision for the comparison either use {@link #containsSubsequence(float[], Offset)}622 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.623 * <p>624 * Examples :625 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };626 *627 * // assertion will pass628 * assertThat(values).containsSubsequence(1.0f, 2.0f);629 * .containsSubsequence(1.0f, 2.0f, 3.0f)630 * .containsSubsequence(1.0f, 3.0f)631 * .usingComparatorWithPrecision(0.5f)632 * .containsSubsequence(1.1f, 2.1f);633 *634 * // assertions will fail635 * assertThat(values).containsSubsequence(3.0f, 1.0f);636 * assertThat(values).containsSubsequence(4.0f, 7.0f);637 * assertThat(values).usingComparatorWithPrecision(0.01f)638 * .containsSubsequence(1.1f, 2.0f);</code></pre>639 *640 * @param subsequence the subsequence of values to look for.641 * @return {@code this} assertion object.642 * @throws AssertionError if the actual array is {@code null}.643 * @throws AssertionError if the given array is {@code null}.644 * @throws AssertionError if the actual array does not contain the given subsequence.645 */646 public SELF containsSubsequence(float... subsequence) {647 arrays.assertContainsSubsequence(info, actual, subsequence);648 return myself;649 }650 /**651 * Verifies that the actual array contains the given subsequence (possibly with other values between them).652 * <p>653 * Example:654 * <pre><code class='java'> // assertion will pass655 * assertThat(new float[] { 1.0f, 2.0f }).containsSubsequence(new Float[] { 1.0f, 2.0f });656 * assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).containsSubsequence(new Float[] { 1.0f, 4.0f });657 *658 * // assertion will fail659 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsSubsequence(new Float[] { 3.0f, 1.0f });</code></pre>660 *661 * @param subsequence the subsequence of values to look for.662 * @return myself assertion object.663 * @throws AssertionError if the actual array is {@code null}.664 * @throws AssertionError if the given array is {@code null}.665 * @throws AssertionError if the actual array does not contain the given subsequence.666 * @since 3.19.0667 */668 public SELF containsSubsequence(Float[] subsequence) {669 requireNonNullParameter(subsequence, "subsequence");670 arrays.assertContainsSubsequence(info, actual, toPrimitiveFloatArray(subsequence));671 return myself;672 }673 /**674 * Verifies that the actual array contains the given subsequence (possibly with other values between them).675 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.676 * <p>677 * Examples :678 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};679 *680 * // assertions will pass681 * assertThat(values).containsSubsequence(new float[] {1.0f, 2.0f}, withPrecision(0.1f))682 * .containsSubsequence(new float[] {1.0f, 2.07f, 3.0f}, withPrecision(0.1f))683 * .containsSubsequence(new float[] {2.1f, 2.9f}, withPrecision(0.2f));684 *685 * // assertions will fail686 * assertThat(values).containsSubsequence(new float[] {1.0f, 3.0f}, withPrecision(0.1f));687 * assertThat(values).containsSubsequence(new float[] {4.0f, 7.0f}, withPrecision(0.1f));</code></pre>688 *689 * @param subsequence the subsequence of values to look for.690 * @param precision the precision under which the values may vary.691 * @return {@code this} assertion object.692 * @throws AssertionError if the actual array is {@code null}.693 * @throws AssertionError if the given array is {@code null}.694 * @throws AssertionError if the actual array does not contain the given subsequence.695 */696 public SELF containsSubsequence(float[] subsequence, Offset<Float> precision) {697 return usingComparatorWithPrecision(precision.value).containsSubsequence(subsequence);698 }699 /**700 * Verifies that the actual array contains the given subsequence (possibly with other values between them).701 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.702 * <p>703 * Examples :704 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };705 *706 * // assertions will pass707 * assertThat(values).containsSubsequence(new Float[] { 1.0f, 2.0f }, withPrecision(0.1f))708 * .containsSubsequence(new Float[] { 1.0f, 2.07f, 3.0f }, withPrecision(0.1f))709 * .containsSubsequence(new Float[] { 2.1f, 2.9f }, withPrecision(0.2f));710 *711 * // assertions will fail712 * assertThat(values).containsSubsequence(new Float[] { 1.0f, 3.0f }, withPrecision(0.1f));713 * assertThat(values).containsSubsequence(new Float[] { 4.0f, 7.0f }, withPrecision(0.1f));</code></pre>714 *715 * @param subsequence the subsequence of values to look for.716 * @param precision the precision under which the values may vary.717 * @return {@code this} assertion object.718 * @throws AssertionError if the actual array is {@code null}.719 * @throws AssertionError if the given array is {@code null}.720 * @throws AssertionError if the actual array does not contain the given subsequence.721 * @since 3.19.0722 */723 public SELF containsSubsequence(Float[] subsequence, Offset<Float> precision) {724 return usingComparatorWithPrecision(precision.value).containsSubsequence(toPrimitiveFloatArray(subsequence));725 }726 /**727 * Verifies that the actual array contains the given value at the given index.728 * <p>729 * If you want to set a precision for the comparison either use {@link #contains(float, Index, Offset)}730 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.731 * <p>732 * Example:733 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };734 *735 * // assertion will pass736 * assertThat(values).contains(1.0f, atIndex(O))737 * .contains(3.0f, atIndex(2))738 * .usingComparatorWithPrecision(0.5f)739 * .contains(3.1f, atIndex(2));740 *741 * // assertions will fail742 * assertThat(values).contains(1.0f, atIndex(1));743 * assertThat(values).contains(4.0f, atIndex(2));744 * assertThat(values).usingComparatorWithPrecision(0.01f)745 * .contains(3.1f, atIndex(2));</code></pre>746 *747 * @param value the value to look for.748 * @param index the index where the value should be stored in the actual array.749 * @return {@code this} assertion object.750 * @throws AssertionError if the actual array is {@code null} or empty.751 * @throws NullPointerException if the given {@code Index} is {@code null}.752 * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of753 * the actual array.754 * @throws AssertionError if the actual array does not contain the given value at the given index.755 */756 public SELF contains(float value, Index index) {757 arrays.assertContains(info, actual, value, index);758 return myself;759 }760 /**761 * Verifies that the actual array contains the given value at the given index.762 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.763 * <p>764 * Example:765 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};766 *767 * // assertions will pass768 * assertThat(values).contains(1.0f, atIndex(O), withPrecision(0.01f))769 * .contains(3.3f, atIndex(2), withPrecision(0.5f));770 *771 * // assertions will fail772 * assertThat(values).contains(1.0f, atIndex(1), withPrecision(0.2f));773 * assertThat(values).contains(4.5f, atIndex(2), withPrecision(0.1f));</code></pre>774 *775 * @param value the value to look for.776 * @param index the index where the value should be stored in the actual array.777 * @param precision the precision which the value may vary.778 * @return {@code this} assertion object.779 * @throws AssertionError if the actual array is {@code null} or empty.780 * @throws NullPointerException if the given {@code Index} is {@code null}.781 * @throws IndexOutOfBoundsException if the value of the given {@code Index} is equal to or greater than the size of782 * the actual array.783 * @throws AssertionError if the actual array does not contain the given value at the given index.784 */785 public SELF contains(float value, Index index, Offset<Float> precision) {786 return usingComparatorWithPrecision(precision.value).contains(value, index);787 }788 /**789 * Verifies that the actual array does not contain the given values.790 * <p>791 * If you want to set a precision for the comparison either use {@link #doesNotContain(float[], Offset)}792 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.793 * <p>794 * Example:795 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };796 *797 * // assertion will pass798 * assertThat(values).doesNotContain(4.0f, 8.0f)799 * .usingComparatorWithPrecision(0.0001f)800 * .doesNotContain(1.01f, 2.01f);801 *802 * // assertions will fail803 * assertThat(values).doesNotContain(1.0f, 4.0f, 8.0f);804 * assertThat(values).usingComparatorWithPrecision(0.1f)805 * .doesNotContain(1.001f, 2.001f);</code></pre>806 *807 * @param values the given values.808 * @return {@code this} assertion object.809 * @throws NullPointerException if the given argument is {@code null}.810 * @throws IllegalArgumentException if the given argument is an empty array.811 * @throws AssertionError if the actual array is {@code null}.812 * @throws AssertionError if the actual array contains any of the given values.813 */814 public SELF doesNotContain(float... values) {815 arrays.assertDoesNotContain(info, actual, values);816 return myself;817 }818 /**819 * Verifies that the actual array does not contain the values of the given array.820 * <p>821 * Example:822 * <pre><code class='java'> // assertion will pass823 * assertThat(new float[] { 1.0f, 2.0f }).doesNotContain(new Float[] { 3.0f });824 *825 * // assertion will fail826 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).doesNotContain(new Float[] { 1.0f });</code></pre>827 *828 * @param values the given values.829 * @return {@code this} assertion object.830 * @throws NullPointerException if the given argument is {@code null}.831 * @throws IllegalArgumentException if the given argument is an empty array.832 * @throws AssertionError if the actual array is {@code null}.833 * @throws AssertionError if the actual array contains any of the given values.834 * @since 3.19.0835 */836 public SELF doesNotContain(Float[] values) {837 requireNonNullParameter(values, "values");838 arrays.assertDoesNotContain(info, actual, toPrimitiveFloatArray(values));839 return myself;840 }841 /**842 * Verifies that the actual array does not contain the given values.843 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.844 * <p>845 * Example:846 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};847 *848 * // assertion will pass849 * assertThat(values).doesNotContain(new float[] {4.0f, 8.0f}, withPrecision(0.5f));850 *851 * // assertion will fail852 * assertThat(values).doesNotContain(new float[] {1.05f, 4.0f, 8.0f}, withPrecision(0.1f));</code></pre>853 *854 * @param values the given values.855 * @param precision the precision under which the values may vary.856 * @return {@code this} assertion object.857 * @throws NullPointerException if the given argument is {@code null}.858 * @throws IllegalArgumentException if the given argument is an empty array.859 * @throws AssertionError if the actual array is {@code null}.860 * @throws AssertionError if the actual array contains any of the given values.861 */862 public SELF doesNotContain(float[] values, Offset<Float> precision) {863 return usingComparatorWithPrecision(precision.value).doesNotContain(values);864 }865 /**866 * Verifies that the actual array does not contain the values of the given array.867 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.868 * <p>869 * Example:870 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };871 *872 * // assertion will pass873 * assertThat(values).doesNotContain(new Float[] { 4.0f, 8.0f }, withPrecision(0.5f));874 *875 * // assertion will fail876 * assertThat(values).doesNotContain(new Float[] { 1.05f, 4.0f, 8.0f }, withPrecision(0.1f));</code></pre>877 *878 * @param values the given values.879 * @param precision the precision under which the values may vary.880 * @return {@code this} assertion object.881 * @throws NullPointerException if the given argument is {@code null}.882 * @throws IllegalArgumentException if the given argument is an empty array.883 * @throws AssertionError if the actual array is {@code null}.884 * @throws AssertionError if the actual array contains any of the given values.885 * @since 3.19.0886 */887 public SELF doesNotContain(Float[] values, Offset<Float> precision) {888 return usingComparatorWithPrecision(precision.value).doesNotContain(toPrimitiveFloatArray(values));889 }890 /**891 * Verifies that the actual array does not contain the given value at the given index.892 * <p>893 * If you want to set a precision for the comparison either use {@link #doesNotContain(float, Index, Offset)}894 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.895 * <p>896 * Example:897 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };898 *899 * // assertion will pass900 * assertThat(values).doesNotContain(1.0f, atIndex(1))901 * .doesNotContain(2.0f, atIndex(0))902 * .usingComparatorWithPrecision(0.001)903 * .doesNotContain(1.1f, atIndex(0));904 *905 * // assertions will fail906 * assertThat(values).doesNotContain(1.0f, atIndex(0));907 * assertThat(values).usingComparatorWithPrecision(0.1)908 * .doesNotContain(1.001f, atIndex(0));</code></pre>909 *910 * @param value the value to look for.911 * @param index the index where the value should be stored in the actual array.912 * @return {@code this} assertion object.913 * @throws AssertionError if the actual array is {@code null}.914 * @throws NullPointerException if the given {@code Index} is {@code null}.915 * @throws AssertionError if the actual array contains the given value at the given index.916 */917 public SELF doesNotContain(float value, Index index) {918 arrays.assertDoesNotContain(info, actual, value, index);919 return myself;920 }921 /**922 * Verifies that the actual array does not contain the given value at the given index.923 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.924 * <p>925 * Example:926 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};927 *928 * // assertions will pass929 * assertThat(values).doesNotContain(1.01f, atIndex(1), withPrecision(0.0001f))930 * .doesNotContain(2.05f, atIndex(0), withPrecision(0.1f));931 *932 * // assertion will fail933 * assertThat(values).doesNotContain(1.01f, atIndex(0), withPrecision(0.1f));</code></pre>934 *935 * @param value the value to look for.936 * @param index the index where the value should be stored in the actual array.937 * @param precision the precision under which the value may vary.938 * @return {@code this} assertion object.939 * @throws AssertionError if the actual array is {@code null}.940 * @throws NullPointerException if the given {@code Index} is {@code null}.941 * @throws AssertionError if the actual array contains the given value at the given index.942 */943 public SELF doesNotContain(float value, Index index, Offset<Float> precision) {944 return usingComparatorWithPrecision(precision.value).doesNotContain(value, index);945 }946 /**947 * Verifies that the actual array does not contain duplicates.948 * <p>949 * If you want to set a precision for the comparison either use {@link #doesNotHaveDuplicates(Offset)}950 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.951 * <p>952 * Example:953 * <pre><code class='java'> // assertions will pass954 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).doesNotHaveDuplicates();955 * assertThat(new float[] { 1.0f, 1.1f }).usingComparatorWithPrecision(0.01f)956 * .doesNotHaveDuplicates();957 *958 * // assertions will fail959 * assertThat(new float[] { 1.0f, 1.0f, 2.0f, 3.0f }).doesNotHaveDuplicates();960 * assertThat(new float[] { 1.0f, 1.1f }).usingComparatorWithPrecision(0.5f)961 * .doesNotHaveDuplicates();</code></pre>962 *963 * @return {@code this} assertion object.964 * @throws AssertionError if the actual array is {@code null}.965 * @throws AssertionError if the actual array contains duplicates.966 */967 public SELF doesNotHaveDuplicates() {968 arrays.assertDoesNotHaveDuplicates(info, actual);969 return myself;970 }971 /**972 * Verifies that the actual array does not contain duplicates.973 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.974 * <p>975 * Example:976 * <pre><code class='java'> // assertions will pass977 * assertThat(new float[] {1.0f, 2.0f, 3.0f}).doesNotHaveDuplicates(withPrecision(0.1f));978 * assertThat(new float[] {1.1f, 1.2f, 1.3f}).doesNotHaveDuplicates(withPrecision(0.05f));979 *980 * // assertion will fail981 * assertThat(new float[] {1.0f, 1.01f, 2.0f}).doesNotHaveDuplicates(withPrecision(0.1f));</code></pre>982 *983 * @param precision the precision under which the values may vary.984 * @return {@code this} assertion object.985 * @throws AssertionError if the actual array is {@code null}.986 * @throws AssertionError if the actual array contains duplicates.987 */988 public SELF doesNotHaveDuplicates(Offset<Float> precision) {989 return usingComparatorWithPrecision(precision.value).doesNotHaveDuplicates();990 }991 /**992 * Verifies that the actual array starts with the given sequence of values, without any other values between them.993 * Similar to <code>{@link #containsSequence(float...)}</code>, but it also verifies that the first element in the994 * sequence is also first element of the actual array.995 * <p>996 * If you want to set a precision for the comparison either use {@link #startsWith(float[], Offset)}997 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.998 * <p>999 * Example:1000 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };1001 *1002 * // assertion will pass1003 * assertThat(values).startsWith(1.0f, 2.0f)1004 * .usingComparatorWithPrecision(0.5f)1005 * .startsWith(1.1f, 2.1f);1006 *1007 * // assertion will fail1008 * assertThat(values).startsWith(2.0f, 3.0f);</code></pre>1009 *1010 * @param sequence the sequence of values to look for.1011 * @return {@code this} assertion object.1012 * @throws NullPointerException if the given argument is {@code null}.1013 * @throws IllegalArgumentException if the given argument is an empty array.1014 * @throws AssertionError if the actual array is {@code null}.1015 * @throws AssertionError if the actual array does not start with the given sequence.1016 */1017 public SELF startsWith(float... sequence) {1018 arrays.assertStartsWith(info, actual, sequence);1019 return myself;1020 }1021 /**1022 * Verifies that the actual array starts with the given sequence of values, without any other values between them.1023 * Similar to <code>{@link #containsSequence(Float[])}</code>, but it also verifies that the first element in the1024 * sequence is also first element of the actual array.1025 * <p>1026 * Example:1027 * <pre><code class='java'> // assertion will pass1028 * assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).startsWith(new Float[] { 1.0f, 2.0f });1029 *1030 * // assertion will fail1031 * assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).startsWith(new Float[] { 2.0f, 3.0f, 4.0f });</code></pre>1032 *1033 * @param sequence the sequence of values to look for.1034 * @return myself assertion object.1035 * @throws NullPointerException if the given argument is {@code null}.1036 * @throws IllegalArgumentException if the given argument is an empty array.1037 * @throws AssertionError if the actual array is {@code null}.1038 * @throws AssertionError if the actual array does not start with the given sequence.1039 * @since 3.19.01040 */1041 public SELF startsWith(Float[] sequence) {1042 requireNonNullParameter(sequence, "sequence");1043 arrays.assertStartsWith(info, actual, toPrimitiveFloatArray(sequence));1044 return myself;1045 }1046 /**1047 * Verifies that the actual array starts with the given sequence of values, without any other values between them.1048 * Similar to <code>{@link #containsSequence(float...)}</code>, but it also verifies that the first element in the1049 * sequence is also first element of the actual array.1050 * <p>1051 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.1052 * <p>1053 * Example:1054 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};1055 *1056 * // assertion will pass1057 * assertThat(values).startsWith(new float[] {1.01f, 2.01f}, withPrecision(0.1f));1058 *1059 * // assertions will fail1060 * assertThat(values).startsWith(new float[] {2.0f, 1.0f}, withPrecision(0.1f))1061 * assertThat(values).startsWith(new float[] {1.1f, 2.1f}, withPrecision(0.5f))</code></pre>1062 *1063 * @param values the sequence of values to look for.1064 * @param precision the precision under which the values may vary.1065 * @return {@code this} assertion object.1066 * @throws NullPointerException if the given argument is {@code null}.1067 * @throws IllegalArgumentException if the given argument is an empty array.1068 * @throws AssertionError if the actual array is {@code null}.1069 * @throws AssertionError if the actual array does not end with the given sequence.1070 */1071 public SELF startsWith(float[] values, Offset<Float> precision) {1072 return usingComparatorWithPrecision(precision.value).startsWith(values);1073 }1074 /**1075 * Verifies that the actual array starts with the given sequence of values, without any other values between them.1076 * Similar to <code>{@link #containsSequence(float...)}</code>, but it also verifies that the first element in the1077 * sequence is also first element of the actual array.1078 * <p>1079 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.1080 * <p>1081 * Example:1082 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };1083 *1084 * // assertion will pass1085 * assertThat(values).startsWith(new Float[] { 1.01f, 2.01f }, withPrecision(0.1f));1086 *1087 * // assertions will fail1088 * assertThat(values).startsWith(new Float[] { 2.0f, 1.0f }, withPrecision(0.1f))1089 * assertThat(values).startsWith(new Float[] { 1.1f, 2.1f }, withPrecision(0.5f))</code></pre>1090 *1091 * @param values the sequence of values to look for.1092 * @param precision the precision under which the values may vary.1093 * @return {@code this} assertion object.1094 * @throws NullPointerException if the given argument is {@code null}.1095 * @throws IllegalArgumentException if the given argument is an empty array.1096 * @throws AssertionError if the actual array is {@code null}.1097 * @throws AssertionError if the actual array does not end with the given sequence.1098 * @since 3.19.01099 */1100 public SELF startsWith(Float[] values, Offset<Float> precision) {1101 return usingComparatorWithPrecision(precision.value).startsWith(toPrimitiveFloatArray(values));1102 }1103 /**1104 * Verifies that the actual array ends with the given sequence of values, without any other values between them.1105 * Similar to <code>{@link #containsSequence(float...)}</code>, but it also verifies that the last element in the1106 * sequence is also last element of the actual array.1107 * <p>1108 * If you want to set a precision for the comparison either use {@link #endsWith(float[], Offset)}1109 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.1110 * <p>1111 * Example:1112 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };1113 *1114 * // assertion will pass1115 * assertThat(values).endsWith(2.0f, 3.0f)1116 * .usingComparatorWithPrecision(0.5f)1117 * .endsWith(2.1f, 3.1f);1118 *1119 * // assertion will fail1120 * assertThat(values).endsWith(1.0f, 3.0f);</code></pre>1121 *1122 * @param sequence the sequence of values to look for.1123 * @return {@code this} assertion object.1124 * @throws NullPointerException if the given argument is {@code null}.1125 * @throws IllegalArgumentException if the given argument is an empty array.1126 * @throws AssertionError if the actual array is {@code null}.1127 * @throws AssertionError if the actual array does not end with the given sequence.1128 */1129 public SELF endsWith(float... sequence) {1130 arrays.assertEndsWith(info, actual, sequence);1131 return myself;1132 }1133 /**1134 * Verifies that the actual array ends with the given sequence of values, without any other values between them.1135 * Similar to <code>{@link #containsSequence(Float[])}</code>, but it also verifies that the last element in the1136 * sequence is also last element of the actual array.1137 * <p>1138 * Example:1139 * <pre><code class='java'> // assertion will pass1140 * assertThat(new boolean[] { 1.0f, 2.0f, 3.0f, 4.0f }).endsWith(new Float[] { 3.0f, 4.0f });1141 *1142 * // assertion will fail1143 * assertThat(new boolean[] { 1.0f, 2.0f, 3.0f, 4.0f }).endsWith(new Float[] { 2.0f, 3.0f });</code></pre>1144 *1145 * @param sequence the sequence of values to look for.1146 * @return myself assertion object.1147 * @throws NullPointerException if the given argument is {@code null}.1148 * @throws IllegalArgumentException if the given argument is an empty array.1149 * @throws AssertionError if the actual array is {@code null}.1150 * @throws AssertionError if the actual array does not end with the given sequence.1151 * @since 3.19.01152 */1153 public SELF endsWith(Float[] sequence) {1154 requireNonNullParameter(sequence, "sequence");1155 arrays.assertEndsWith(info, actual, toPrimitiveFloatArray(sequence));1156 return myself;1157 }1158 /**1159 * Verifies that the actual array ends with the given sequence of values, without any other values between them.1160 * Similar to <code>{@link #containsSequence(float...)}</code>, but it also verifies that the last element in the1161 * sequence is also last element of the actual array.1162 * <p>1163 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.1164 * <p>1165 * Example:1166 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};1167 *1168 * // assertion will pass1169 * assertThat(values).endsWith(new float[] {2.01f, 3.01f}, withPrecision(0.1f));1170 *1171 * // assertions will fail1172 * assertThat(values).endsWith(new float[] {3.0f, 2.0f}, withPrecision(0.1f))1173 * assertThat(values).endsWith(new float[] {2.1f, 3.1f}, withPrecision(0.5f))</code></pre>1174 *1175 * @param values the sequence of values to look for.1176 * @param precision the precision under which the values may vary.1177 * @return {@code this} assertion object.1178 * @throws NullPointerException if the given argument is {@code null}.1179 * @throws IllegalArgumentException if the given argument is an empty array.1180 * @throws AssertionError if the actual array is {@code null}.1181 * @throws AssertionError if the actual array does not end with the given sequence.1182 */1183 public SELF endsWith(float[] values, Offset<Float> precision) {1184 return usingComparatorWithPrecision(precision.value).endsWith(values);1185 }1186 /**1187 * Verifies that the actual array ends with the given sequence of values, without any other values between them.1188 * Similar to <code>{@link #containsSequence(float...)}</code>, but it also verifies that the last element in the1189 * sequence is also last element of the actual array.1190 * <p>1191 * The comparison is done at the given precision/offset set with {@link Assertions#withPrecision(Float)}.1192 * <p>1193 * Example:1194 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };1195 *1196 * // assertion will pass1197 * assertThat(values).endsWith(new Float[] { 2.01f, 3.01f }, withPrecision(0.1f));1198 *1199 * // assertions will fail1200 * assertThat(values).endsWith(new Float[] { 3.0f, 2.0f }, withPrecision(0.1f))1201 * assertThat(values).endsWith(new Float[] { 2.1f, 3.1f }, withPrecision(0.5f))</code></pre>1202 *1203 * @param values the sequence of values to look for.1204 * @param precision the precision under which the values may vary.1205 * @return {@code this} assertion object.1206 * @throws NullPointerException if the given argument is {@code null}.1207 * @throws IllegalArgumentException if the given argument is an empty array.1208 * @throws AssertionError if the actual array is {@code null}.1209 * @throws AssertionError if the actual array does not end with the given sequence.1210 * @since 3.19.01211 */1212 public SELF endsWith(Float[] values, Offset<Float> precision) {1213 return usingComparatorWithPrecision(precision.value).endsWith(toPrimitiveFloatArray(values));1214 }1215 /** {@inheritDoc} */1216 @Override1217 public SELF isSorted() {1218 arrays.assertIsSorted(info, actual);1219 return myself;1220 }1221 /** {@inheritDoc} */1222 @Override1223 public SELF isSortedAccordingTo(Comparator<? super Float> comparator) {1224 arrays.assertIsSortedAccordingToComparator(info, actual, comparator);1225 return myself;1226 }1227 /** {@inheritDoc} */1228 @Override1229 @CheckReturnValue1230 public SELF usingElementComparator(Comparator<? super Float> customComparator) {1231 this.arrays = new FloatArrays(new ComparatorBasedComparisonStrategy(customComparator));1232 return myself;1233 }1234 /** {@inheritDoc} */1235 @Override1236 @CheckReturnValue1237 public SELF usingDefaultElementComparator() {1238 this.arrays = FloatArrays.instance();1239 return myself;1240 }1241 /**1242 * Verifies that the actual group contains only the given values and nothing else, <b>in order</b>.1243 * <p>1244 * If you want to set a precision for the comparison either use {@link #containsExactly(float[], Offset)}1245 * or {@link #usingComparatorWithPrecision(Float)} before calling the assertion.1246 * <p>1247 * Example :1248 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };1249 *1250 * // assertion will pass1251 * assertThat(values).containsExactly(1.0f, 2.0f, 3.0f)1252 * .usingComparatorWithPrecision(0.2f)1253 * .containsExactly(1.1f, 2.1f, 2.9f);1254 *1255 * // assertion will fail as actual and expected order differ1256 * assertThat(values).containsExactly(2.0f, 1.0f, 3.0f);</code></pre>1257 *1258 * @param values the given values.1259 * @return {@code this} assertion object.1260 * @throws NullPointerException if the given argument is {@code null}.1261 * @throws AssertionError if the actual group is {@code null}.1262 * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group1263 * contains some or none of the given values, or the actual group contains more values than the given ones1264 * or values are the same but the order is not.1265 */1266 public SELF containsExactly(float... values) {1267 arrays.assertContainsExactly(info, actual, values);1268 return myself;1269 }1270 /**1271 * Verifies that the actual group contains only the values of the given array and nothing else, <b>in order</b>.1272 * <p>1273 * Example :1274 * <pre><code class='java'> // assertion will pass1275 * assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).containsExactly(new Float[] { 1.0f, 2.0f, 3.0f, 4.0f });1276 *1277 * // assertion will fail as actual and expected order differ1278 * assertThat(new float[] { 1.0f, 2.0f, 3.0f, 4.0f }).containsExactly(new Float[] { 1.0f, 5.0f });</code></pre>1279 *1280 * @param values the given values.1281 * @return {@code this} assertion object.1282 * @throws NullPointerException if the given argument is {@code null}.1283 * @throws AssertionError if the actual group is {@code null}.1284 * @throws AssertionError if the actual group does not contain the given values with same order, i.e. the actual group1285 * contains some or none of the given values, or the actual group contains more values than the given ones1286 * or values are the same but the order is not.1287 * @since 3.19.01288 */1289 public SELF containsExactly(Float[] values) {1290 requireNonNullParameter(values, "values");1291 arrays.assertContainsExactly(info, actual, toPrimitiveFloatArray(values));1292 return myself;1293 }1294 /**1295 * Verifies that the actual group contains only the given values and nothing else, <b>in order</b>.1296 * The values may vary with a specified precision.1297 * <p>1298 * Example :1299 * <pre><code class='java'> float[] values = new float[] {1.0f, 2.0f, 3.0f};1300 *1301 * // assertion will pass1302 * assertThat(values).containsExactly(new float[] {1.0f, 1.98f, 3.01f}, withPrecision(0.05f));1303 *1304 * // assertion fails because |1.0 - 1.1| > 0.05 (precision)1305 * assertThat(values).containsExactly(new float[] {1.1f, 2.0f, 3.01f}, withPrecision(0.05f));1306 *1307 * // assertion will fail as actual and expected order differ1308 * assertThat(values).containsExactly(new float[] {1.98f, 1.0f, 3.01f}, withPrecision(0.05f));</code></pre>1309 *1310 * @param values the given values.1311 * @param precision the precision under which the values may vary.1312 * @return {@code this} assertion object.1313 * @throws NullPointerException if the given argument is {@code null}.1314 * @throws AssertionError if the actual group is {@code null}.1315 * @throws AssertionError if the actual group does not contain the given values within the specified precision1316 * with same order, i.e. the actual group contains some or none of the given values, or the actual group contains1317 * more values than the given ones or values are the same but the order is not.1318 */1319 public SELF containsExactly(float[] values, Offset<Float> precision) {1320 return usingComparatorWithPrecision(precision.value).containsExactly(values);1321 }1322 /**1323 * Verifies that the actual group contains only the values of the given array and nothing else, <b>in order</b>.1324 * The values may vary with a specified precision.1325 * <p>1326 * Example :1327 * <pre><code class='java'> float[] values = new float[] { 1.0f, 2.0f, 3.0f };1328 *1329 * // assertion will pass1330 * assertThat(values).containsExactly(new Float[] { 1.0f, 1.98f, 3.01f }, withPrecision(0.05f));1331 *1332 * // assertion fails because |1.0 - 1.1| > 0.05 (precision)1333 * assertThat(values).containsExactly(new Float[] { 1.1f, 2.0f, 3.01f }, withPrecision(0.05f));1334 *1335 * // assertion will fail as actual and expected order differ1336 * assertThat(values).containsExactly(new Float[] { 1.98f, 1.0f, 3.01f }, withPrecision(0.05f));</code></pre>1337 *1338 * @param values the given values.1339 * @param precision the precision under which the values may vary.1340 * @return {@code this} assertion object.1341 * @throws NullPointerException if the given argument is {@code null}.1342 * @throws AssertionError if the actual group is {@code null}.1343 * @throws AssertionError if the actual group does not contain the given values within the specified precision1344 * with same order, i.e. the actual group contains some or none of the given values, or the actual group contains1345 * more values than the given ones or values are the same but the order is not.1346 * @since 3.19.01347 */1348 public SELF containsExactly(Float[] values, Offset<Float> precision) {1349 return usingComparatorWithPrecision(precision.value).containsExactly(toPrimitiveFloatArray(values));1350 }1351 /**1352 * Verifies that the actual group contains exactly the given values and nothing else, <b>in any order</b>.<br>1353 * <p>1354 * Example :1355 * <pre><code class='java'> // assertions will pass1356 * assertThat(new float[] { 1.0F, 2.0F }).containsExactlyInAnyOrder(1.0F, 2.0F);1357 * assertThat(new float[] { 1.0F, 2.0F, 1.0F }).containsExactlyInAnyOrder(1.0F, 1.0F, 2.0F);1358 *1359 * // assertions will fail1360 * assertThat(new float[] { 1.0F, 2.0F }).containsExactlyInAnyOrder(1.0F);1361 * assertThat(new float[] { 1.0F }).containsExactlyInAnyOrder(1.0F, 2.0F);1362 * assertThat(new float[] { 1.0F, 2.0F, 1.0F }).containsExactlyInAnyOrder(1.0F, 2.0F);</code></pre>1363 *1364 * @param values the given values.1365 * @return {@code this} assertion object.1366 * @throws NullPointerException if the given argument is {@code null}.1367 * @throws AssertionError if the actual group is {@code null}.1368 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group1369 * contains some or none of the given values, or the actual group contains more values than the given ones.1370 * @since 2.6.0 / 3.6.01371 */1372 public SELF containsExactlyInAnyOrder(float... values) {1373 arrays.assertContainsExactlyInAnyOrder(info, actual, values);1374 return myself;1375 }1376 /**1377 * Verifies that the actual group contains exactly the values of the given array and nothing else, <b>in any order</b>.<br>1378 * <p>1379 * Example :1380 * <pre><code class='java'> // assertions will pass1381 * assertThat(new float[] { 1.0f, 2.0f }).containsExactlyInAnyOrder(new Float[] { 2.0f, 1.0f });1382 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(new Float[] { 3.0f, 1.0f, 2.0f });1383 *1384 * // assertions will fail1385 * assertThat(new float[] { 1.0f, 2.0f }).containsExactlyInAnyOrder(new Float[] { 1.0f });1386 * assertThat(new float[] { 1.0f}).containsExactlyInAnyOrder(new Float[] { 2.0f, 1.0f });1387 * assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(new Float[] { 2.0f, 1.0f });</code></pre>1388 *1389 * @param values the given values.1390 * @return {@code this} assertion object.1391 * @throws NullPointerException if the given argument is {@code null}.1392 * @throws AssertionError if the actual group is {@code null}.1393 * @throws AssertionError if the actual group does not contain the given values, i.e. the actual group1394 * contains some or none of the given values, or the actual group contains more values than the given ones.1395 * @since 3.19.01396 */1397 public SELF containsExactlyInAnyOrder(Float[] values) {1398 requireNonNullParameter(values, "values");1399 arrays.assertContainsExactlyInAnyOrder(info, actual, toPrimitiveFloatArray(values));1400 return myself;1401 }1402 /**1403 * Create a {@link Float} comparator which compares floats at the given precision and pass it to {@link #usingElementComparator(Comparator)}.1404 * All the following assertions will use this comparator to compare float[] elements.1405 *1406 * @param precision precision used to compare {@link Float}.1407 * @return {@code this} assertion object.1408 */1409 @CheckReturnValue1410 public SELF usingComparatorWithPrecision(Float precision) {1411 return usingElementComparator(ComparatorFactory.INSTANCE.floatComparatorWithPrecision(precision));1412 }1413 /**1414 * Verifies that the actual array contains at least one of the given values.1415 * <p>1416 * Example :1417 * <pre><code class='java'> float[] oneTwoThree = { 1.0f, 2.0f, 3.0f };1418 *1419 * // assertions will pass1420 * assertThat(oneTwoThree).containsAnyOf(2.0f)1421 * .containsAnyOf(2.0f, 3.0f)1422 * .containsAnyOf(1.0f, 2.0f, 3.0f)1423 * .containsAnyOf(1.0f, 2.0f, 3.0f, 4.0f)1424 * .containsAnyOf(5.0f, 6.0f, 7.0f, 2.0f);1425 *1426 * // assertions will fail1427 * assertThat(oneTwoThree).containsAnyOf(4.0f);1428 * assertThat(oneTwoThree).containsAnyOf(4.0f, 5.0f, 6.0f, 7.0f);</code></pre>1429 *1430 * @param values the values whose at least one which is expected to be in the array under test.1431 * @return {@code this} assertion object.1432 * @throws NullPointerException if the array of values is {@code null}.1433 * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty.1434 * @throws AssertionError if the array under test is {@code null}.1435 * @throws AssertionError if the array under test does not contain any of the given {@code values}.1436 * @since 2.9.0 / 3.9.01437 */1438 public SELF containsAnyOf(float... values) {1439 arrays.assertContainsAnyOf(info, actual, values);1440 return myself;1441 }1442 /**1443 * Verifies that the actual array contains at least one of the values of the given array.1444 * <p>1445 * Example :1446 * <pre><code class='java'> float[] soFloats = { 1.0f, 2.0f, 3.0f };1447 *1448 * // assertions will pass1449 * assertThat(soFloats).containsAnyOf(new Float[] { 1.0f })1450 * .containsAnyOf(new Float[] { 3.0f, 4.0f, 5.0f, 6.0f });1451 *1452 * // assertions will fail1453 * assertThat(soFloats).containsAnyOf(new Float[] { 8.0f });1454 * assertThat(soFloats).containsAnyOf(new Float[] { 11.0f, 15.0f, 420.0f });</code></pre>1455 *1456 * @param values the values whose at least one which is expected to be in the array under test.1457 * @return {@code this} assertion object.1458 * @throws NullPointerException if the array of values is {@code null}.1459 * @throws IllegalArgumentException if the array of values is empty and the array under test is not empty.1460 * @throws AssertionError if the array under test is {@code null}.1461 * @throws AssertionError if the array under test does not contain any of the given {@code values}.1462 * @since 3.19.01463 */1464 public SELF containsAnyOf(Float[] values) {1465 requireNonNullParameter(values, "values");1466 arrays.assertContainsAnyOf(info, actual, toPrimitiveFloatArray(values));1467 return myself;1468 }1469 private static float[] toPrimitiveFloatArray(Float[] values) {1470 float[] floats = new float[values.length];1471 range(0, values.length).forEach(i -> floats[i] = values[i]);1472 return floats;1473 }1474}...
toPrimitiveFloatArray
Using AI Code Generation
1[0]: assertThat(new float[] { 1.0f, 2.0f }).usingDefaultComparator().usingElementComparator(new Comparator<Float>() {2[0]: public int compare(Float o1, Float o2) {3[0]: return o1.compareTo(o2);4[0]: }5[0]: }).usingComparatorForType(new Comparator<Float>() {6[0]: public int compare(Float o1, Float o2) {7[0]: return o1.compareTo(o2);8[0]: }9[0]: }).usingComparatorForElementFieldsWithType(new Comparator<Float>() {10[0]: public int compare(Float o1, Float o2) {11[0]: return o1.compareTo(o2);12[0]: }13[0]: }, Float.class).usingComparatorForElementFieldsWithNames(new Comparator<Float>() {14[0]: public int compare(Float o1, Float o2) {15[0]: return o1.compareTo(o2);16[0]: }17[0]: }, "name").usingComparatorForElementPropertyOrFieldNames(new Comparator<Float>() {18[0]: public int compare(Float o1, Float o2) {19[0]: return o1.compareTo(o2);20[0]: }21[0]: }, "name").usingComparatorForElementPropertyOrFieldTypes(new Comparator<Float>() {22[0]: public int compare(Float o1, Float o2) {23[0]: return o1.compareTo(o2);24[0]: }25[0]: }, Float.class).containsExactly(1.0f, 2.0f);26[0]: assertThat(new float[] { 1.0f, 2.0f }).usingDefaultComparator().usingElementComparator(new Comparator<Float>() {27[0]: public int compare(Float o1, Float o2) {28[0]: return o1.compareTo(o2);29[0]: }30[0]: }).usingComparatorForType(new Comparator
toPrimitiveFloatArray
Using AI Code Generation
1package com.zetcode;2import org.assertj.core.api.Assertions;3import org.assertj.core.api.AbstractFloatArrayAssert;4public class AssertJPrimitiveFloatArrayEx {5 public static void main(String[] args) {6 float[] array = {1.2f, 2.3f, 3.4f};7 AbstractFloatArrayAssert<?> faa = Assertions.assertThat(array);8 float[] primArray = faa.useComparatorWithPrecision(0.01f)9 .usingElementComparatorIgnoringFields("id")10 .usingDefaultComparator()11 .toPrimitiveFloatArray();12 System.out.println(primArray.length);13 }14}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!