Commit 2c8e2885 authored by Justin Dearden's avatar Justin Dearden
Browse files

Added Test Cases For Trig Functions and Pow/Factorial/toRadians

parent c471fe34
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>assignment2b</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
package test;
import static org.junit.Assert.*;
import org.junit.Test;
public class TrigFunctionTest {
/* Test case to check the Factorial function
*
* */
@Test
public void testFactorial() {
int i = 4;
int expected = 24;
double actual = TrigFunctions.factorial(i);
assertEquals("Testing the factorial function",expected, actual);
}
/* Test case to check the Power function
*
* */
@Test
public void testPower() {
double i = 5;
double j = 4;
double expected = Math.pow(i, j);
double actual = TrigFunctions.power(i, j);
assertEquals("Testing the power function",expected, actual);
}
/* Test case to check the toRadian function
*
* */
@Test
public void testToRadian() {
double degrees = 45;
double expected = Math.toRadians(degrees);
double actual = TrigFunctions.toRadian(degrees);
assertEquals("Testing the toRadian function",expected, actual);
}
//SIN TESTS
@Test
public void testSin0Degrees() {
int i = 0;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual);
}
@Test
public void testSin45Degrees() {
int i = 45;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual);
}
@Test
public void testSin90Degrees() {
int i = 90;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual);
}
@Test
public void testSin180Degrees() {
int i = 180;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual);
}
@Test
public void testSin360Degrees() {
int i = 360;
double expected = Math.sin(Math.toDegrees(i));
double actual = TrigFunctions.sin(i);
assertEquals(expected, actual);
}
@Test
public void testSin0Radians() {
int i = 0;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testSin45Radians() {
int i = 45;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testSin90Radians() {
int i = 90;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testSin180Radians() {
int i = 180;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testSin360Radians() {
int i = 360;
double expected = Math.sin(Math.toRadians(i));
double actual = TrigFunctions.sin(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
//COS TESTS
public void testCos0Degrees() {
int i = 0;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual);
}
@Test
public void testCos45Degrees() {
int i = 45;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual);
}
@Test
public void testCos90Degrees() {
int i = 90;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual);
}
@Test
public void testCos180Degrees() {
int i = 180;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual);
}
@Test
public void testCos360Degrees() {
int i = 360;
double expected = Math.cos(Math.toDegrees(i));
double actual = TrigFunctions.cos(i);
assertEquals(expected, actual);
}
@Test
public void testCos0Radians() {
int i = 0;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testCos45Radians() {
int i = 45;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testCos90Radians() {
int i = 90;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testCos180Radians() {
int i = 180;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testCos360Radians() {
int i = 360;
double expected = Math.cos(Math.toRadians(i));
double actual = TrigFunctions.cos(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
//TAN TESTS
@Test
public void testTan0Degrees() {
int i = 0;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual);
}
@Test
public void testTan45Degrees() {
int i = 45;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual);
}
@Test
public void testTan90Degrees() {
int i = 90;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual);
}
@Test
public void testTan180Degrees() {
int i = 180;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual);
}
@Test
public void testTan360Degrees() {
int i = 360;
double expected = Math.tan(Math.toDegrees(i));
double actual = TrigFunctions.tan(i);
assertEquals(expected, actual);
}
@Test
public void testTan0Radians() {
int i = 0;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testTan45Radians() {
int i = 45;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testTan90Radians() {
int i = 90;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testTan180Radians() {
int i = 180;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
@Test
public void testTan360Radians() {
int i = 360;
double expected = Math.tan(Math.toRadians(i));
double actual = TrigFunctions.tan(TrigFunctions.toRadian(i));
assertEquals(expected, actual);
}
}
package test;
public class TrigFunctions {
public static double factorial(int i) {
return 0;
}
public static double power(double i, double j) {
return 0;
}
public static double toRadian(double degrees) {
return 0;
}
// Lets us pass in which mode we want
public enum TYPE {
RADIANS,
DEGREES
}
public static double sin(double degrees) {
return 0;
}
public static double cos(double degrees) {
return 0;
}
public static double tan(double degrees) {
return 0;
}
}
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