Best Assertj code snippet using org.assertj.core.internal.FloatArrays.assertContainsExactlyInAnyOrder
Source:FloatArrays_assertContainsExactlyInAnyOrder_Test.java
...24import org.assertj.core.util.Lists;25import org.junit.jupiter.api.Test;26import org.mockito.Mockito;27/**28 * Tests for <code>{@link FloatArrays#assertContainsExactlyInAnyOrder(AssertionInfo, float[], float[])}</code>.29 */30public class FloatArrays_assertContainsExactlyInAnyOrder_Test extends FloatArraysBaseTest {31 @Test32 public void should_pass_if_actual_contains_given_values_exactly_in_any_order() {33 arrays.assertContainsExactlyInAnyOrder(TestData.someInfo(), actual, FloatArrays.arrayOf(6.0F, 8.0F, 10.0F));34 }35 @Test36 public void should_pass_if_actual_and_given_values_are_empty() {37 arrays.assertContainsExactlyInAnyOrder(TestData.someInfo(), FloatArrays.emptyArray(), FloatArrays.emptyArray());38 }39 @Test40 public void should_pass_if_actual_contains_given_values_exactly_but_in_different_order() {41 AssertionInfo info = TestData.someInfo();42 arrays.assertContainsExactlyInAnyOrder(info, actual, FloatArrays.arrayOf(6.0F, 10.0F, 8.0F));43 }44 @Test45 public void should_fail_if_arrays_have_different_sizes() {46 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> arrays.assertContainsExactlyInAnyOrder(someInfo(), actual, arrayOf(6.0F, 8.0F)));47 }48 @Test49 public void should_fail_if_expected_is_empty_and_actual_is_not() {50 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> arrays.assertContainsExactlyInAnyOrder(someInfo(), actual, emptyArray()));51 }52 @Test53 public void should_throw_error_if_expected_is_null() {54 Assertions.assertThatNullPointerException().isThrownBy(() -> arrays.assertContainsExactlyInAnyOrder(someInfo(), actual, null)).withMessage(ErrorMessages.valuesToLookForIsNull());55 }56 @Test57 public void should_fail_if_actual_is_null() {58 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> arrays.assertContainsExactlyInAnyOrder(someInfo(), null, arrayOf(8.0F))).withMessage(FailureMessages.actualIsNull());59 }60 @Test61 public void should_fail_if_actual_does_not_contain_given_values_exactly() {62 AssertionInfo info = TestData.someInfo();63 float[] expected = new float[]{ 6.0F, 8.0F, 20.0F };64 try {65 arrays.assertContainsExactlyInAnyOrder(info, actual, expected);66 } catch (AssertionError e) {67 Mockito.verify(failures).failure(info, ShouldContainExactlyInAnyOrder.shouldContainExactlyInAnyOrder(actual, expected, Lists.newArrayList(20.0F), Lists.newArrayList(10.0F), StandardComparisonStrategy.instance()));68 return;69 }70 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();71 }72 @Test73 public void should_fail_if_actual_contains_all_given_values_but_size_differ() {74 AssertionInfo info = TestData.someInfo();75 float[] expected = new float[]{ 6.0F, 8.0F };76 try {77 arrays.assertContainsExactlyInAnyOrder(info, actual, expected);78 } catch (AssertionError e) {79 Mockito.verify(failures).failure(info, ShouldContainExactlyInAnyOrder.shouldContainExactlyInAnyOrder(actual, expected, Lists.emptyList(), Lists.newArrayList(10.0F), StandardComparisonStrategy.instance()));80 return;81 }82 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();83 }84 @Test85 public void should_fail_if_actual_contains_duplicates_and_expected_does_not() {86 AssertionInfo info = TestData.someInfo();87 actual = FloatArrays.arrayOf(1.0F, 2.0F, 3.0F);88 float[] expected = new float[]{ 1.0F, 2.0F };89 try {90 arrays.assertContainsExactlyInAnyOrder(info, actual, expected);91 } catch (AssertionError e) {92 Mockito.verify(failures).failure(info, ShouldContainExactlyInAnyOrder.shouldContainExactlyInAnyOrder(actual, expected, Lists.emptyList(), Lists.newArrayList(3.0F), StandardComparisonStrategy.instance()));93 return;94 }95 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();96 }97 @Test98 public void should_fail_if_expected_contains_duplicates_and_actual_does_not() {99 AssertionInfo info = TestData.someInfo();100 actual = FloatArrays.arrayOf(1.0F, 2.0F);101 float[] expected = new float[]{ 1.0F, 2.0F, 3.0F };102 try {103 arrays.assertContainsExactlyInAnyOrder(info, actual, expected);104 } catch (AssertionError e) {105 Mockito.verify(failures).failure(info, ShouldContainExactlyInAnyOrder.shouldContainExactlyInAnyOrder(actual, expected, Lists.newArrayList(3.0F), Lists.emptyList(), StandardComparisonStrategy.instance()));106 return;107 }108 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();109 }110 // ------------------------------------------------------------------------------------------------------------------111 // tests using a custom comparison strategy112 // ------------------------------------------------------------------------------------------------------------------113 @Test114 public void should_pass_if_actual_contains_given_values_exactly_in_any_order_according_to_custom_comparison_strategy() {115 arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(TestData.someInfo(), actual, FloatArrays.arrayOf(6.0F, (-8.0F), 10.0F));116 }117 @Test118 public void should_pass_if_actual_contains_given_values_exactly_in_different_order_according_to_custom_comparison_strategy() {119 float[] expected = new float[]{ -6.0F, 10.0F, 8.0F };120 arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(TestData.someInfo(), actual, expected);121 }122 @Test123 public void should_fail_if_expected_is_empty_and_actual_is_not_whatever_custom_comparison_strategy_is() {124 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(someInfo(), actual, emptyArray()));125 }126 @Test127 public void should_throw_error_if_expected_is_null_whatever_custom_comparison_strategy_is() {128 Assertions.assertThatNullPointerException().isThrownBy(() -> arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(someInfo(), actual, null)).withMessage(ErrorMessages.valuesToLookForIsNull());129 }130 @Test131 public void should_fail_if_actual_is_null_whatever_custom_comparison_strategy_is() {132 Assertions.assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(someInfo(), null, arrayOf((-8.0F)))).withMessage(FailureMessages.actualIsNull());133 }134 @Test135 public void should_fail_if_actual_does_not_contain_given_values_exactly_according_to_custom_comparison_strategy() {136 AssertionInfo info = TestData.someInfo();137 float[] expected = new float[]{ 6.0F, -8.0F, 20.0F };138 try {139 arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(info, actual, expected);140 } catch (AssertionError e) {141 Mockito.verify(failures).failure(info, ShouldContainExactlyInAnyOrder.shouldContainExactlyInAnyOrder(actual, expected, Lists.newArrayList(20.0F), Lists.newArrayList(10.0F), absValueComparisonStrategy));142 return;143 }144 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();145 }146 @Test147 public void should_fail_if_actual_contains_all_given_values_but_size_differ_according_to_custom_comparison_strategy() {148 AssertionInfo info = TestData.someInfo();149 float[] expected = new float[]{ 6.0F, -8.0F };150 try {151 arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(info, actual, expected);152 } catch (AssertionError e) {153 Mockito.verify(failures).failure(info, ShouldContainExactlyInAnyOrder.shouldContainExactlyInAnyOrder(actual, expected, Lists.emptyList(), Lists.newArrayList(10.0F), absValueComparisonStrategy));154 return;155 }156 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();157 }158 @Test159 public void should_fail_if_actual_contains_duplicates_and_expected_does_not_according_to_custom_comparison_strategy() {160 AssertionInfo info = TestData.someInfo();161 actual = FloatArrays.arrayOf(1.0F, 2.0F, 3.0F);162 float[] expected = new float[]{ 1.0F, 2.0F };163 try {164 arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(info, actual, expected);165 } catch (AssertionError e) {166 Mockito.verify(failures).failure(info, ShouldContainExactlyInAnyOrder.shouldContainExactlyInAnyOrder(actual, expected, Lists.emptyList(), Lists.newArrayList(3.0F), absValueComparisonStrategy));167 return;168 }169 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();170 }171 @Test172 public void should_fail_if_expected_contains_duplicates_and_actual_does_not_according_to_custom_comparison_strategy() {173 AssertionInfo info = TestData.someInfo();174 actual = FloatArrays.arrayOf(1.0F, 2.0F);175 float[] expected = new float[]{ 1.0F, 2.0F, 3.0F };176 try {177 arraysWithCustomComparisonStrategy.assertContainsExactlyInAnyOrder(info, actual, expected);178 } catch (AssertionError e) {179 Mockito.verify(failures).failure(info, ShouldContainExactlyInAnyOrder.shouldContainExactlyInAnyOrder(actual, expected, Lists.newArrayList(3.0F), Lists.emptyList(), absValueComparisonStrategy));180 return;181 }182 TestFailures.failBecauseExpectedAssertionErrorWasNotThrown();183 }184}...
assertContainsExactlyInAnyOrder
Using AI Code Generation
1assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(3.0f, 2.0f, 1.0f);2assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(2.0f, 1.0f, 3.0f);3assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(1.0f, 2.0f, 3.0f);4assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(1.0f, 2.0f, 3.0f, 4.0f);5assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(1.0f, 2.0f);6assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(1.0f, 2.0f, 4.0f);7assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(1.0f, 2.0f, 3.0f, 4.0f);8assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(1.0f, 2.0f, 3.0f, 4.0f);9assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(1.0f, 2.0f, 3.0f, 4.0f);10assertThat(new float[] { 1.0f, 2.0f, 3.0f }).containsExactlyInAnyOrder(1.0f, 2.0f, 3.0f, 4.0f);11assertThat(new float
assertContainsExactlyInAnyOrder
Using AI Code Generation
1 public void testAssertContainsExactlyInAnyOrder() {2 float[] actual = {1.0f, 2.0f, 3.0f};3 float[] expected = {1.0f, 2.0f, 3.0f};4 float[] unexpected = {3.0f, 2.0f, 1.0f};5 FloatArrays arrays = FloatArrays.instance();6 arrays.assertContainsExactlyInAnyOrder(info(), actual, expected);7 try {8 arrays.assertContainsExactlyInAnyOrder(info(), actual, unexpected);9 } catch (AssertionError e) {10 logAssertionErrorMessage("testAssertContainsExactlyInAnyOrder", e.getMessage());11 }12 }13 private void logAssertionErrorMessage(String testName, String message) {14 System.out.format("[%s] - %s15", testName, message);16 }17}
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!!