123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
-
- 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);
- }
- }
|