Search in sources :

Example 81 with AssertionInfo

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();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) Test(org.junit.Test) FloatsBaseTest(org.assertj.core.internal.FloatsBaseTest)

Example 82 with AssertionInfo

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();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) DataProvider(com.tngtech.java.junit.dataprovider.DataProvider) Test(org.junit.Test) FloatsBaseTest(org.assertj.core.internal.FloatsBaseTest)

Example 83 with AssertionInfo

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();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) Test(org.junit.Test) FloatsBaseTest(org.assertj.core.internal.FloatsBaseTest)

Example 84 with AssertionInfo

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();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) Test(org.junit.Test) FloatsBaseTest(org.assertj.core.internal.FloatsBaseTest)

Example 85 with AssertionInfo

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();
}
Also used : AssertionInfo(org.assertj.core.api.AssertionInfo) Delta(org.assertj.core.util.diff.Delta) InputStreamsBaseTest(org.assertj.core.internal.InputStreamsBaseTest) Test(org.junit.Test)

Aggregations

AssertionInfo (org.assertj.core.api.AssertionInfo)1174 Test (org.junit.Test)1172 IterablesBaseTest (org.assertj.core.internal.IterablesBaseTest)94 DatesBaseTest (org.assertj.core.internal.DatesBaseTest)92 ByteArraysBaseTest (org.assertj.core.internal.ByteArraysBaseTest)84 ObjectArraysBaseTest (org.assertj.core.internal.ObjectArraysBaseTest)84 Date (java.util.Date)60 CharArraysBaseTest (org.assertj.core.internal.CharArraysBaseTest)47 FloatArraysBaseTest (org.assertj.core.internal.FloatArraysBaseTest)47 IntArraysBaseTest (org.assertj.core.internal.IntArraysBaseTest)47 LongArraysBaseTest (org.assertj.core.internal.LongArraysBaseTest)47 MapsBaseTest (org.assertj.core.internal.MapsBaseTest)47 ShortArraysBaseTest (org.assertj.core.internal.ShortArraysBaseTest)47 BigIntegersBaseTest (org.assertj.core.internal.BigIntegersBaseTest)44 BigDecimalsBaseTest (org.assertj.core.internal.BigDecimalsBaseTest)42 Index (org.assertj.core.data.Index)40 Index.atIndex (org.assertj.core.data.Index.atIndex)40 ObjectsBaseTest (org.assertj.core.internal.ObjectsBaseTest)40 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)34 DoublesBaseTest (org.assertj.core.internal.DoublesBaseTest)33