package nl.jft.common.util;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
 * @author Oscar de Leeuw
 */
public class NumbersTest {

    @Rule
    public ExpectedException expectedException = ExpectedException.none();

    @Test
    public void checkEqual_doublesInRangeOfDelta_returnsTrue() throws Exception {
        double x = 5d;
        double y = 5d;
        double delta = 0.01d;

        boolean result = Numbers.checkEqual(x, y, delta);

        assertTrue(result);
    }

    @Test
    public void checkEqual_doublesOutOfRangeOfDelta_returnsFalse() throws Exception {
        double x = 5d;
        double y = 6d;
        double delta = 0.01d;

        boolean result = Numbers.checkEqual(x, y, delta);

        assertFalse(result);
    }

    @Test
    public void checkEqual_doublesAreNaN_returnsTrue() throws Exception {
        double x = Double.NaN;
        double y = Double.NaN;
        double delta = 0.01d;

        boolean result = Numbers.checkEqual(x, y, delta);

        assertTrue(result);
    }

    @Test
    public void checkEqual_doublesArePositiveInfinity_returnsTrue() throws Exception {
        double x = Double.POSITIVE_INFINITY;
        double y = Double.POSITIVE_INFINITY;
        double delta = 0.01d;

        boolean result = Numbers.checkEqual(x, y, delta);

        assertTrue(result);
    }

    @Test
    public void checkEqual_doublesAreNegativeInfinity_returnsTrue() throws Exception {
        double x = Double.NEGATIVE_INFINITY;
        double y = Double.NEGATIVE_INFINITY;
        double delta = 0.01d;

        boolean result = Numbers.checkEqual(x, y, delta);

        assertTrue(result);
    }

    @Test
    public void checkEqual_doublesInRangeOfConstantDelta_returnsTrue() throws Exception {
        double x = 5d;
        double y = 5d;

        boolean result = Numbers.checkEqual(x, y);

        assertTrue(result);
    }

    @Test
    public void checkEqual_doublesOutOfRangeOfConstantDelta_returnsFalse() throws Exception {
        double x = 5d;
        double y = 6d;

        boolean result = Numbers.checkEqual(x, y);

        assertFalse(result);
    }

    @Test
    public void checkEqual_withZeroDelta_returnsTrue() throws Exception {
        double x = 2.5 * 2;
        double y = 10 / 2;
        double delta = 0d;

        boolean result = Numbers.checkEqual(x, y, delta);

        assertTrue(result);
    }
}
@@ -111,16 +111,107 @@
 ption;%0A%0A
+import java.lang.reflect.Constructor;%0Aimport java.lang.reflect.InvocationTargetException;%0A%0A
 import s
@@ -434,24 +434,587 @@
 on.none();%0A%0A
+    @Test%0A    public void construct_whenCalled_throwsException() throws Throwable %7B%0A        expectedException.expect(UnsupportedOperationException.class);%0A%0A        try %7B%0A            Constructor%3CNumbers%3E constructor = Numbers.class.getDeclaredConstructor();%0A            constructor.setAccessible(true);%0A            constructor.newInstance();%0A        %7D catch (InstantiationException %7C NoSuchMethodException %7C IllegalAccessException e) %7B%0A            throw e;%0A        %7D catch (InvocationTargetException e) %7B%0A            throw e.getTargetException();%0A        %7D%0A    %7D%0A%0A
     @Test%0A  

Fix NumbersTest not having a constructor test.