Commit 1730d604 authored by Jameel Jiwani's avatar Jameel Jiwani
Browse files

initial commit

<?xml version="1.0" encoding="UTF-8"?>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
<?xml version="1.0" encoding="UTF-8"?>
<name>Assignment 4</name>
File added
File added
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()) {
package trigCode;
public class Trig {
// takes in a double that is in radians or degrees
public double trigCos(double x) {
return x;
// takes in a double value that is in radians or degrees
public double trigSin(double x) {
return x;
// calculates the tan of x (that is in degrees or radians)
public double trigTan(double x) {
return x;
// simply converts degrees to radians
public double convertDegreesToRadians(double x) {
return x;
package trigCode;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class TrigTest {
Trig t;
double x;
double x1;
double x2;
double x3;
static double PI = 3.1415926535;
void setUp() throws Exception {
t = new Trig();
x = PI/6;
x1 = 0;
x2 = 90;
x3 = PI;
void testTrigCos() {
// to do... write test cases for cosine
assertEquals(t.trigCos(x), Math.cos(x), 0.000005);
assertEquals(t.trigCos(x1), Math.cos(x1), 0.000005);
assertEquals(t.trigCos(x2), Math.cos(x2), 0.000005);
assertEquals(t.trigCos(x3), Math.cos(x3), 0.000005);
void testTrigSin() {
assertEquals(t.trigSin(x), Math.sin(x), 0.000005);
assertEquals(t.trigSin(x1), Math.sin(x1), 0.000005);
assertEquals(t.trigSin(x2), Math.sin(x2), 0.000005);
assertEquals(t.trigSin(x3), Math.sin(x3), 0.000005);
void testTrigTan() {
assertEquals(t.trigTan(x), Math.tan(x), 0.000005);
assertEquals(t.trigTan(x1), Math.tan(x1), 0.000005);
assertEquals(t.trigTan(x2), Math.tan(x2), 0.000005);
assertEquals(t.trigTan(x3), Math.tan(x3), 0.000005);
void testEquals() {
assertEquals(x3, Math.PI, 0.0000005);
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