package com.yuzhouwan.hacker.algorithms;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Copyright @ 2019 yuzhouwan.com
 * All right reserved.
 * Function：Double Test
 *
 * @author Benedict Jin
 * @since 2018/6/27
 */
public class DoubleTest {

    @Test
    public void count2One() {
        double d = 0;
        d += 0.1;
        assertEquals("0.1", String.valueOf(d));
        d += 0.1;
        assertEquals("0.2", String.valueOf(d));
        d += 0.1;
        assertEquals("0.30000000000000004", String.valueOf(d));
        d += 0.1;
        assertEquals("0.4", String.valueOf(d));
        d += 0.1;
        assertEquals("0.5", String.valueOf(d));
        d += 0.1;
        assertEquals("0.6", String.valueOf(d));
        d += 0.1;
        assertEquals("0.7", String.valueOf(d));
        d += 0.1;
        assertEquals("0.7999999999999999", String.valueOf(d));
        d += 0.1;
        assertEquals("0.8999999999999999", String.valueOf(d));
        d += 0.1;
        assertEquals("0.9999999999999999", String.valueOf(d));
    }
}

@@ -103,16 +103,64 @@
 tEquals;
+%0Aimport static org.junit.Assert.assertNotEquals;
 %0A%0A/**%0A *
@@ -316,16 +316,321 @@
 Test %7B%0A%0A
+    @Test%0A    public void testAssertDouble() %7B%0A        assertEquals(0.1, Double.parseDouble(%220.1%22), 0.1);%0A        assertEquals(0.02, Double.parseDouble(%220.01%22), 0.1);%0A        assertNotEquals(0.02, Double.parseDouble(%220.01%22), 0.001);%0A        assertEquals(0.002, Double.parseDouble(%220.001%22), 0.001);%0A    %7D%0A%0A
     @Tes

Add testAssertDouble