/** * Verifies that the actual number is close to the given one within the given percentage.<br> * If difference is equal to the percentage value, assertion is considered valid. * <p> * Example with byte: * <pre><code class='java'> // assertions will pass: * assertThat((byte) 11).isCloseTo((byte) 10, withinPercentage((byte) 20)); * * // assertions will fail * assertThat((byte) 11).isCloseTo((byte) 10, withinPercentage((byte) 10)); * assertThat((byte) 11).isCloseTo((byte) 10, withinPercentage((byte) 5));</code></pre> * * @param expected the given number to compare the actual value to. * @param percentage the given positive percentage. * @return {@code this} assertion object. * @throws NullPointerException if the given offset is {@code null}. * @throws NullPointerException if the expected number is {@code null}. * @throws AssertionError if the actual value is close to the given one. */ public SELF isCloseTo(byte expected, Percentage percentage) { bytes.assertIsCloseToPercentage(info, actual, expected, percentage); return myself; }
/** * Verifies that the actual number is close to the given one within the given percentage.<br> * If difference is equal to the percentage value, assertion is considered valid. * <p> * Example with byte: * <pre><code class='java'> // assertions will pass: * assertThat((byte) 11).isCloseTo(Byte.valueOf(10), withinPercentage((byte) 20)); * * // if difference is exactly equals to the computed offset (1), it's ok * assertThat((byte) 11).isCloseTo(Byte.valueOf(10), withinPercentage((byte) 10)); * * // assertion will fail * assertThat((byte) 11).isCloseTo(Byte.valueOf(10), withinPercentage((byte) 5));</code></pre> * * @param expected the given number to compare the actual value to. * @param percentage the given positive percentage. * @return {@code this} assertion object. * @throws NullPointerException if the given offset is {@code null}. * @throws NullPointerException if the expected number is {@code null}. * @throws AssertionError if the actual value is not close to the given one. */ @Override public SELF isCloseTo(Byte expected, Percentage percentage) { bytes.assertIsCloseToPercentage(info, actual, expected, percentage); return myself; }
/** * Verifies that the actual number is close to the given one within the given percentage.<br> * If difference is equal to the percentage value, assertion is considered valid. * <p> * Example with byte: * <pre><code class='java'> // assertions will pass: * assertThat((byte) 11).isCloseTo((byte) 10, withinPercentage((byte) 20)); * * // assertions will fail * assertThat((byte) 11).isCloseTo((byte) 10, withinPercentage((byte) 10)); * assertThat((byte) 11).isCloseTo((byte) 10, withinPercentage((byte) 5));</code></pre> * * @param expected the given number to compare the actual value to. * @param percentage the given positive percentage. * @return {@code this} assertion object. * @throws NullPointerException if the given offset is {@code null}. * @throws NullPointerException if the expected number is {@code null}. * @throws AssertionError if the actual value is close to the given one. */ public SELF isCloseTo(byte expected, Percentage percentage) { bytes.assertIsCloseToPercentage(info, actual, expected, percentage); return myself; }
/** * Verifies that the actual number is close to the given one within the given percentage.<br> * If difference is equal to the percentage value, assertion is considered valid. * <p> * Example with byte: * <pre><code class='java'> // assertions will pass: * assertThat((byte) 11).isCloseTo(Byte.valueOf(10), withinPercentage((byte) 20)); * * // if difference is exactly equals to the computed offset (1), it's ok * assertThat((byte) 11).isCloseTo(Byte.valueOf(10), withinPercentage((byte) 10)); * * // assertion will fail * assertThat((byte) 11).isCloseTo(Byte.valueOf(10), withinPercentage((byte) 5));</code></pre> * * @param expected the given number to compare the actual value to. * @param percentage the given positive percentage. * @return {@code this} assertion object. * @throws NullPointerException if the given offset is {@code null}. * @throws NullPointerException if the expected number is {@code null}. * @throws AssertionError if the actual value is not close to the given one. */ @Override public SELF isCloseTo(Byte expected, Percentage percentage) { bytes.assertIsCloseToPercentage(info, actual, expected, percentage); return myself; }