123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
-
- import static org.junit.Assert.*;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- /**
- * The test class CoreTest.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class CoreTest
- {
- /**
- * Default constructor for test class CoreTest
- */
- private Core test;
- public CoreTest()
- {
- }
-
- /**
- * Sets up the test fixture.
- *
- * Called before every test case method.
- */
- @Before
- public void setUp()
- {
- Core test = new Core();
- }
-
- /**
- * Tears down the test fixture.
- *
- * Called after every test case method.
- */
- @After
- public void tearDown()
- {
- }
-
- @Test
- public void testAdd()
- {
- //expected
- double expected = 2.0;
- //actual
- double actual = test.add(1.0,1.0);
- //assertion
- assertEquals(expected, actual, 0.1);
-
- }
-
- @Test
- public void testSubtract()
- {
- //expected
- double expected = 0.0;
- //actual
- double actual = test.subtract(2.0,2.0);
- //assertion
- assertEquals(expected, actual, 0.1);
-
- }
-
- @Test
- public void testDivide()
- {
- //expected
- double expected = 1.0;
- //actual
- double actual = test.divide(2.0,2.0);
- //assertion
- assertEquals(expected, actual, 0.1);
- }
-
- @Test
- public void testMultiply()
- {
- //expected
- double expected = 4.0;
- //actual
- double actual = test.multiply(2.0,2.0);
- //assertion
- assertEquals(expected, actual, 0.1);
- }
-
- @Test
- public void testsquareRoot()
- {
- //expected
- double expected = 3.0;
- //actual
- double actual = test.squareRoot(9.0);
- //assertion
- assertEquals(expected, actual, 0.1);
- }
-
- @Test
- public void testexponentiation()
- {
- //expected
- double expected = 4;
- //actual
- double actual = test.exponentiation(2.0,2.0);
- //assertion
- assertEquals(expected, actual, 0.1);
- }
-
- @Test
- public void testinverse()
- {
- //expected
- double expected = 0.25;
- //actual
- double actual = test.inverse(4.0);
- //assertion
- assertEquals(expected, actual, 0.1);
- }
-
- @Test
- public void testreverse()
- {
- //expected
- double expected = -4.0;
- //actual
- double actual = test.reverse(4.0);
- //assertion
- assertEquals(expected, actual, 0.1);
- }
- }
-
|