Commit 127c3cdc authored by nathan1505's avatar nathan1505
Browse files

Version 1.0: All the functions exist but only sum and PI have passed the test cases

parent 1a8ae0ce
/.DS_Store
/trigCode/
No preview for this file type
package trigCode;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
public class TestRunner {
public static void main(String[] args) {
Result result = JUnitCore.runClasses(TrigTest.class);
for(Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
System.out.println("Result=="+result.wasSuccessful());
}
}
......@@ -2,6 +2,10 @@ package trigCode;
public class Trig {
public Integer sum(int a, int b) {
// TODO Auto-generated method stub
return a + b;
}
// takes in a double that is in radians or degrees
public double trigCos(double x) {
......@@ -22,4 +26,12 @@ public class Trig {
public double convertDegreesToRadians(double x) {
return x;
}
// simply converts radians to degrees
public double convertRadiansToDegrees(double x) {
// TODO Auto-generated method stub
return 0;
}
}
......@@ -12,6 +12,8 @@ public class TrigTest {
double x1;
double x2;
double x3;
double x4;
double x5;
static double PI = 3.1415926535;
@BeforeEach
......@@ -21,6 +23,8 @@ public class TrigTest {
x1 = 0;
x2 = 90;
x3 = PI;
x4 = 45;
x5 = 180;
}
@Test
......@@ -48,10 +52,38 @@ public class TrigTest {
assertEquals(t.trigTan(x3), Math.tan(x3), 0.000005);
}
@Test
void testDegToRad()
{
assertEquals(t.convertDegreesToRadians(x), Math.toRadians(x), 0.000005);
assertEquals(t.convertDegreesToRadians(x1), Math.toRadians(x1), 0.000005);
assertEquals(t.convertDegreesToRadians(x2), Math.toRadians(x2), 0.000005);
assertEquals(t.convertDegreesToRadians(x4), Math.toRadians(x4), 0.000005);
assertEquals(t.convertDegreesToRadians(x5), Math.toRadians(x5), 0.000005);
}
@Test
void testRadToDeg()
{
assertEquals(t.convertRadiansToDegrees(x), Math.toDegrees(x), 0.000005);
assertEquals(t.convertRadiansToDegrees(x1), Math.toDegrees(x1), 0.000005);
assertEquals(t.convertRadiansToDegrees(x2), Math.toDegrees(x2), 0.000005);
assertEquals(t.convertRadiansToDegrees(x4), Math.toDegrees(x4), 0.000005);
assertEquals(t.convertRadiansToDegrees(x5), Math.toDegrees(x5), 0.000005);
}
@Test
void testEquals() {
assertEquals(x3, Math.PI, 0.0000005);
}
@Test
void testSum()
{
assertEquals(t.sum(6,4), 10);
assertEquals(t.sum(0,0), 0);
assertEquals(t.sum(999999999,1), 1000000000);
}
}
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