import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; /** * The test class FunctionsTest. * * @author (your name) * @version (a version number or a date) */ public class FunctionsTest { /** * Default constructor for test class FunctionsTest */ public FunctionsTest() { } /** * Sets up the test fixture. * * Called before every test case method. */ @Before public void setUp() { } /** * Tears down the test fixture. * * Called after every test case method. */ @After public void tearDown() { } @Test public void testAdd() { // : Given double expected = 17.0; double first = 9; double second = 8; // : When double actual = Functions.add(first, second); // : Then assertEquals(expected, actual, 0); } @Test public void testSubtract() { // : Given double expected = 17.0; double first = 40; double second = 23; // : When double actual = Functions.subtract(first, second); // : Then assertEquals(expected, actual, 0); } @Test public void testMultiply() { // : Given double expected = 72.0; double first = 9; double second = 8; // : When double actual = Functions.multiply(first, second); // : Then assertEquals(expected, actual, 0); } @Test public void testDivide() { // : Given double expected = 1.125; double first = 9; double second = 8; // : When double actual = Functions.divide(first, second); // : Then assertEquals(expected, actual, 0); } @Test public void testSquare() { // : Given double expected = 144.0; double input = 12; // : When double actual = Functions.square(input); // : Then assertEquals(expected, actual, 0); } @Test public void testSqRoot() { // : Given double expected = 12.0; double first = 144; // : When double actual = Functions.squareRoot(first); // : Then assertEquals(expected, actual, 0); } @Test public void testExponent() { // : Given double expected = 43046721.0; double first = 9; double second = 8; // : When double actual = Functions.exponent(first, second); // : Then assertEquals(expected, actual, 0); } @Test public void testInverse() { // : Given double expected = 0.25; double first = 4; // : When double actual = Functions.inverse(first); // : Then assertEquals(expected, actual, 0); } @Test public void testInvert() { // : Given double expected = -17.0; double first = 17; // : When double actual = Functions.invertSign(first); // : Then assertEquals(expected, actual, 0); } final double pi = Math.PI; @Test public void testSin() { // : Given double expected = 1.0; double first = 90; // : When double actual = Functions.sin(first); // : Then assertEquals(expected, actual, 0); } @Test public void testCos() { // : Given double expected = 1.0; double first = 0; // : When double actual = Functions.cos(first); // : Then assertEquals(expected, actual, 0); } @Test public void testTan() { // : Given double expected = 1.0; double first = 45; // : When double actual = (float)Functions.tan(first); // : Then assertEquals(expected, actual, 0.1); } @Test public void testArcsin() { // : Given double expected = 90.0; double first = 1; // : When double actual = Functions.arcsin(first); // : Then assertEquals(expected, actual, 0); } @Test public void testArccos() { // : Given double expected = 90.0; double first = 0; // : When double actual = Functions.arccos(first); // : Then assertEquals(expected, actual, 0); } @Test public void testArctan() { // : Given double expected = 45.0; double first = 1; // : When double actual = Functions.arctan(first); // : Then assertEquals(expected, actual, 0); } @Test public void testCsc() { // : Given double expected = Math.sqrt(2); double first = 45; // : When double actual = Functions.csc(first); // : Then assertEquals(expected, actual, 0); } @Test public void testSec() { // : Given double expected = (float)Math.sqrt(2); double first = 45; // : When double actual = (float)Functions.sec(first); // : Then assertEquals(expected, actual, 0); } @Test public void testCot() { // : Given double expected = 1.0; double first = 45; // : When double actual = (float)Functions.cot(first); // : Then assertEquals(expected, actual, 0); } @Test public void testLn() { // : Given double expected = 0.0; double first = 1; // : When double actual = Functions.ln(first); // : Then assertEquals(expected, actual, 0); } @Test public void testinverseLn() { // : Given double expected = 17.0; double first = 17; // : When double actual = Functions.inverseLn(first); // : Then assertEquals(expected, actual, 0); } }