use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Floats_assertIsCloseTo_Test method should_fail_if_actual_is_not_close_enough_to_expected_value_with_a_strict_offset.
@Test
public void should_fail_if_actual_is_not_close_enough_to_expected_value_with_a_strict_offset() {
AssertionInfo info = someInfo();
try {
floats.assertIsCloseTo(info, ONE, TEN, byLessThan(ONE));
} catch (AssertionError e) {
verify(failures).failure(info, shouldBeEqual(ONE, TEN, byLessThan(ONE), TEN - ONE));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Floats_assertIsNotCloseToPercentage_Test method should_fail_if_difference_is_equal_to_given_percentage.
@Test
@DataProvider({ "1, 1, 0", "2, 1, 100", "1, 2, 50", "-1, -1, 0", "-2, -1, 100", "-1, -2, 50" })
public void should_fail_if_difference_is_equal_to_given_percentage(Float actual, Float other, Float percentage) {
AssertionInfo info = someInfo();
try {
floats.assertIsNotCloseToPercentage(someInfo(), actual, other, withPercentage(percentage));
} catch (AssertionError e) {
verify(failures).failure(info, shouldNotBeEqualWithinPercentage(actual, other, withPercentage(percentage), abs(actual - other)));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Floats_assertIsNotCloseToPercentage_Test method should_fail_if_actual_is_too_close_to_expected_value.
@Test
public void should_fail_if_actual_is_too_close_to_expected_value() {
AssertionInfo info = someInfo();
try {
floats.assertIsNotCloseToPercentage(someInfo(), ONE, TEN, withPercentage(ONE_HUNDRED));
} catch (AssertionError e) {
verify(failures).failure(info, shouldNotBeEqualWithinPercentage(ONE, TEN, withinPercentage(100), TEN - ONE));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class Floats_assertIsNotCloseTo_Test method should_fail_if_actual_is_too_close_to_expected_value_with_strict_offset.
@Test
public void should_fail_if_actual_is_too_close_to_expected_value_with_strict_offset() {
AssertionInfo info = someInfo();
try {
floats.assertIsNotCloseTo(info, ONE, TWO, byLessThan(TEN));
} catch (AssertionError e) {
verify(failures).failure(info, shouldNotBeEqual(ONE, TWO, byLessThan(TEN), TWO - ONE));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
use of org.assertj.core.api.AssertionInfo in project assertj-core by joel-costigliola.
the class InputStreams_assertSameContentAs_Test method should_fail_if_inputstreams_do_not_have_equal_content.
@Test
public void should_fail_if_inputstreams_do_not_have_equal_content() throws IOException {
@SuppressWarnings("unchecked") List<Delta<String>> diffs = newArrayList((Delta<String>) mock(Delta.class));
when(diff.diff(actual, expected)).thenReturn(diffs);
AssertionInfo info = someInfo();
try {
inputStreams.assertSameContentAs(info, actual, expected);
} catch (AssertionError e) {
verify(failures).failure(info, shouldHaveSameContent(actual, expected, diffs));
return;
}
failBecauseExpectedAssertionErrorWasNotThrown();
}
Aggregations