@Test public void testMul() { DoubleMemory memory = new DoubleMemory(10); Assert.assertEquals(20, memory.mul(2).toDouble(), 0.00001); Assert.assertEquals(Memory.Type.DOUBLE, memory.mul(2).type); Assert.assertEquals(10, memory.mul(true).toDouble(), 0.00001); Assert.assertEquals(0, memory.mul(false).toDouble(), 0.00001); Assert.assertEquals(Memory.Type.DOUBLE, memory.mul(false).type); Assert.assertEquals(20, memory.mul(2.0).toDouble(), 0.0001); Assert.assertEquals(Memory.Type.DOUBLE, memory.mul(2.0).type); }
@Test public void testPlus() { DoubleMemory memory = new DoubleMemory(10); Assert.assertEquals(12, memory.plus(2).toDouble(), 0.0001); Assert.assertEquals(Memory.Type.DOUBLE, memory.plus(2).type); Assert.assertEquals(11, memory.plus(true).toDouble(), 0.00001); Assert.assertEquals(10, memory.plus(false).toDouble(), 0.00001); Assert.assertEquals(Memory.Type.DOUBLE, memory.plus(false).type); Assert.assertEquals(12, memory.plus(2.0).toDouble(), 0.0001); Assert.assertEquals(Memory.Type.DOUBLE, memory.plus(2.0).type); }
@Test public void testDiv() { DoubleMemory memory = new DoubleMemory(10); Assert.assertEquals(5, memory.div(2).toDouble(), 0.00001); Assert.assertEquals(Memory.Type.DOUBLE, memory.div(2).type); Assert.assertEquals(10, memory.div(true).toDouble(), 0.000001); Assert.assertEquals(Memory.Type.DOUBLE, memory.div(true).type); Assert.assertEquals(5, memory.div(2.0).toDouble(), 0.0001); Assert.assertEquals(Memory.Type.DOUBLE, memory.div(2.0).type); }
@Test public void testDivInvalidNull() { DoubleMemory memory = new DoubleMemory(10); Assert.assertEquals(Memory.FALSE, memory.div(Memory.NULL)); }
@Test public void testDivInvalidFalse() { DoubleMemory memory = new DoubleMemory(10); Assert.assertEquals(Memory.FALSE, memory.div(false)); }