import org.junit.Assert; import org.junit.After; import org.junit.Before; import org.junit.Test; /** * The test class CalculatorTest. * * Allison & Alfredo * 5/25/2018 * */ public class CalculatorTest { @Test public void memSetTest(){ //:Given Double expected = 2.0; //:When Calculator c = new Calculator(); c.setDisplayValue(2); Double actual = c.memSet(); //:Then Assert.assertEquals(expected, actual); } @Test public void memClearTest(){ //:Given Double expected = 0.0; //:When Calculator c = new Calculator(); c.setDisplayValue(2); c.memSet(); Double actual = c.memClear(); //:Then Assert.assertEquals(expected, actual); } @Test public void additionTest(){ //:Given Double expected = 3.0; //:When Calculator c = new Calculator(); Double actual = c.add(3); //:Then Assert.assertEquals(expected, actual); } @Test public void subtractionTest(){ //:Given Double expected = 1.0; //:When Calculator c = new Calculator(); c.setDisplayValue(4); Double actual = c.subtract(3); //Then Assert.assertEquals(expected, actual); } @Test public void mutliplicationTest(){ //:Given Double expected = 6.0; //:When Calculator c = new Calculator(); c.setDisplayValue(3); Double actual = c.multiply(2); //:Then Assert.assertEquals(expected, actual); } @Test public void divisionTest(){ //:Given Double expected = 0.75; //:When Calculator c = new Calculator(); c.setDisplayValue(3); Double actual = c.divide(4); //:Then Assert.assertEquals(expected, actual); } @Test public void powTest(){ //:Given Double expected = 8.0; //:When Calculator c = new Calculator(); c.setDisplayValue(2); Double actual = c.pow(3); //:Then Assert.assertEquals(expected, actual); } @Test public void squareTest(){ //:Given Double expected = 225.0; //:When Calculator c = new Calculator(); c.setDisplayValue(15); Double actual = c.square(); //:Then Assert.assertEquals(expected, actual); } @Test public void sqrtTest(){ //:Given Double expected = 15.0; //:When Calculator c = new Calculator(); c.setDisplayValue(225); Double actual = c.squareRoot(); //:Then Assert.assertEquals(expected, actual); } @Test public void inverseTest() { //:Given Double expected = 1.0 / 5.0; //:When Calculator c = new Calculator(); c.setDisplayValue(5); Double actual = c.inverse(); //:Then Assert.assertEquals(expected, actual); } @Test public void sinTest() { //:Given Double expected = Math.sin(Math.PI); //:When Calculator c = new Calculator(); Double actual = c.sin(Math.PI); //:Then Assert.assertEquals(expected, actual); } @Test public void cosTest() { //:Given Double expected = Math.cos(Math.PI); //:When Calculator c = new Calculator(); Double actual = c.cos(Math.PI); //:Then Assert.assertEquals(expected, actual); } @Test public void tanTest() { //:Given Double expected = Math.tan(Math.PI); //:When Calculator c = new Calculator(); Double actual = c.tan(Math.PI); //:Then Assert.assertEquals(expected, actual); } @Test public void inverseSinTest() { //:Given Double expected = Math.asin(.2); //:When Calculator c = new Calculator(); Double actual = c.inverseSin(.2); //:Then Assert.assertEquals(expected, actual); } @Test public void inverseCosTest() { //:Given Double expected = Math.acos(.2); //:When Calculator c = new Calculator(); Double actual = c.inverseCos(.2); //:Then Assert.assertEquals(expected, actual); } @Test public void inverseTanTest() { //:Given Double expected = Math.atan(.2); //:When Calculator c = new Calculator(); Double actual = c.inverseTan(.2); //:then Assert.assertEquals(expected, actual); } @Test public void logTest() { //:Given Double expected = Math.log(5); //:When Calculator c = new Calculator(); c.setDisplayValue(5); Double actual = c.log(); //:Then Assert.assertEquals(expected, actual); } @Test public void inverseLogTest() { //:Given Double expected = Math.pow(100, 10); //:When Calculator c = new Calculator(); c.setDisplayValue(100); Double actual = c.inverseLog(); //:Then Assert.assertEquals(expected, actual); } @Test public void naturalLogTest() { //:Given Double expected = Math.log1p(20); //:When Calculator c = new Calculator(); c.setDisplayValue(20); Double actual = c.naturalLog(); //:Then Assert.assertEquals(expected, actual); } @Test public void inverseLnTest() { //:Given Double expected = Math.pow(Math.E, 5); //:When Calculator c = new Calculator(); c.setDisplayValue(5); Double actual = c.inverseLn(); //:Then Assert.assertEquals(expected, actual); } @Test public void factorialTest() { //:Given Double expected = 120.0; //:When Calculator c = new Calculator(); c.setDisplayValue(5); Double actual = c.factorial(); //:Then Assert.assertEquals(expected, actual); } }