Commit 192e2c29 authored by Justin Dearden's avatar Justin Dearden
Browse files

Version 3.2

Updated to include more tests.
parent 4fbea87e
......@@ -9,7 +9,6 @@ public class TrigFunctionTest {
/* Test case to check the Factorial function
*
* */
@SuppressWarnings("deprecation")
@Test
public void testFactorial() {
int i = 4;
......@@ -130,276 +129,194 @@ public class TrigFunctionTest {
@Test
public void testSin0Degrees() {
int i = 0;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual, 0);
assertEquals(Math.sin(Math.toDegrees(0)), TrigFunctions.sin(Math.toDegrees(0)), 0.1);
}
@Test
public void testSin45Degrees() {
int i = 45;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual, 0);
}
assertEquals(Math.sin(Math.toDegrees(45)), TrigFunctions.sin(Math.toDegrees(45)), 0.1);
}
@Test
public void testSin90Degrees() {
int i = 90;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual, 0);
}
assertEquals(Math.sin(Math.toDegrees(90)), TrigFunctions.sin(Math.toDegrees(90)), 0.1);
}
@Test
public void testSin180Degrees() {
int i = 180;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual, 0);
assertEquals(Math.sin(Math.toDegrees(180)), TrigFunctions.sin(Math.toDegrees(180)), 0.1);
}
@Test
public void testSin360Degrees() {
int i = 360;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual, 0);
assertEquals(Math.sin(Math.toDegrees(360)), TrigFunctions.sin(Math.toDegrees(360)), 0.1);
}
@Test
public void testSin0Radians() {
int i = 0;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.sin(Math.toRadians(0)), TrigFunctions.sin(TrigFunctions.toRadian(0)), 0.1);
}
@Test
public void testSin45Radians() {
int i = 45;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.sin(Math.toRadians(90)), TrigFunctions.sin(TrigFunctions.toRadian(90)), 0.1);
}
@Test
public void testSin90Radians() {
int i = 90;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.sin(Math.toRadians(90)), TrigFunctions.sin(TrigFunctions.toRadian(90)), 0.1);
}
@Test
public void testSin180Radians() {
int i = 180;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.sin(Math.toRadians(180)), TrigFunctions.sin(TrigFunctions.toRadian(180)), 0.1);
}
@Test
public void testSin360Radians() {
int i = 360;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.sin(Math.toRadians(360)), TrigFunctions.sin(TrigFunctions.toRadian(360)), 0.1);
}
//COS TESTS
@Test
public void testCos0Degrees() {
int i = 0;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual, 0);
assertEquals(1.0, TrigFunctions.cos(0), 0.1);
}
@Test
public void testCos45Degrees() {
int i = 45;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual, 0);
assertEquals(0.7071067811, TrigFunctions.cos(45), 0.1);
}
@Test
public void testCos90Degrees() {
int i = 90;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual, 0);
assertEquals(Math.cos(Math.toDegrees(90)), TrigFunctions.cos(Math.toDegrees(90)), 0.1);
}
@Test
public void testCos180Degrees() {
int i = 180;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual, 0);
assertEquals(-1.0, TrigFunctions.cos(180), 0.1);
}
@Test
public void testCos360Degrees() {
int i = 360;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual, 0);
assertEquals(1.0, TrigFunctions.cos(360), 0.1);
}
@Test
public void testCos0Radians() {
int i = 0;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.cos(Math.toRadians(0)), TrigFunctions.cos(TrigFunctions.toRadian(0)), 0.1);
}
@Test
public void testCos45Radians() {
int i = 45;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
}
assertEquals(Math.cos(Math.toRadians(45)), TrigFunctions.cos(TrigFunctions.toRadian(45)), 0.1);
}
@Test
public void testCos90Radians() {
int i = 90;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.cos(Math.toRadians(90)), TrigFunctions.cos(TrigFunctions.toRadian(90)), 0.1);
}
@Test
public void testCos180Radians() {
int i = 180;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.cos(Math.toRadians(180)), TrigFunctions.cos(TrigFunctions.toRadian(180)), 0.1);
}
@Test
public void testCos360Radians() {
int i = 360;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.cos(Math.toRadians(360)), TrigFunctions.cos(TrigFunctions.toRadian(360)), 0.1);
}
//TAN TESTS
@Test
@Test
public void testTan0Degrees() {
int i = 0;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual, 0);
assertEquals(0.0, TrigFunctions.tan(0), 0.1);
}
@Test
public void testTan45Degrees() {
int i = 45;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual, 0);
assertEquals(Math.tan(Math.toDegrees(45)), TrigFunctions.tan(Math.toDegrees(45)), 0.1);
}
@Test
public void testTan90Degrees() {
int i = 90;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual, 0);
assertEquals(Math.tan(Math.toDegrees(90)), TrigFunctions.tan(Math.toDegrees(90)), 0.1);
}
@Test
public void testTan180Degrees() {
int i = 180;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual, 0);
assertEquals(0.0, TrigFunctions.tan(180), 0.1);
}
@Test
public void testTan360Degrees() {
int i = 360;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual, 0);
assertEquals(0.0, TrigFunctions.tan(360), 0.1);
}
@Test
public void testTan0Radians() {
int i = 0;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.tan(Math.toRadians(0)), TrigFunctions.tan(TrigFunctions.toRadian(0)), 0.1);
}
@Test
public void testTan45Radians() {
int i = 45;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.tan(Math.toRadians(45)), TrigFunctions.tan(TrigFunctions.toRadian(45)), 0.1);
}
@Test
public void testTan90Radians() {
int i = 90;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.tan(Math.toRadians(90)), TrigFunctions.tan(TrigFunctions.toRadian(90)), 0.1);
}
@Test
public void testTan180Radians() {
int i = 180;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.tan(Math.toRadians(180)), TrigFunctions.tan(TrigFunctions.toRadian(180)), 0.1);
}
@Test
public void testTan360Radians() {
int i = 360;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual, 0);
assertEquals(Math.tan(Math.toRadians(360)), TrigFunctions.tan(TrigFunctions.toRadian(360)), 0.1);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment