Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test added for impact method #102

Merged
merged 1 commit into from
Jun 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/main/java/src/land/LandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public Vector3d[] plotTrajectory(Vector3d landerLocation,
/**
* @return true if the position is within the radius of (0,0,0)
*/
protected boolean impact(Vector3d landerPosition, double radius)
public boolean impact(Vector3d landerPosition, double radius)
{
double distance = landerPosition.dist(new Vector3d(0,0,0));
distance = Math.abs(distance);
return distance > radius;
return distance <= radius;
}

/**
Expand Down
120 changes: 118 additions & 2 deletions app/src/test/java/src/test/TestLandingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,126 @@ void testOnlyLanderFall()
lc.plotTrajectory(landerPos, landerVel, landerMass, titanPos, titanVel, titanMass, titanRadius);

}
/**
* Testing Strategy:
* | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
* x | >0 | <0 | >0 | <0 | 0 | 0 | 0 | 0 | >0 | >0 | >0 | >0 | <0 | <0 | <0 | <0 |
* y | 0 | 0 | 0 | 0 | >0 | <0 | >0 | <0 | <0 | >0 | <0 | >0 | <0 | >0 | <0 | >0 |
* d<=r | T | T | F | F | T | T | F | F | T | T | F | F | T | T | F | F |
*/
// TODO (Jerome) 4hrs
@Test void testImpact1()
{
Vector3d v = new Vector3d(35.0, 0.0, 0.0);
double r = 50.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), true);
}
@Test void testImpact2()
{
Vector3d v = new Vector3d(-20, 0.0, 0.0);
double r = 20.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), true);
}
@Test void testImpact3()
{
Vector3d v = new Vector3d(60.0, 0.0, 0.0);
double r = 45.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), false);
}
@Test void testImpact4()
{
Vector3d v = new Vector3d(-40.0, 0.0, 0.0);
double r = 30.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), false);
}
@Test void testImpact5()
{
Vector3d v = new Vector3d(0.0, 60, 0.0);
double r = 60.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), true);
}
@Test void testImpact6()
{
Vector3d v = new Vector3d(0.0, -20.0, 0.0);
double r = 25.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), true);
}

@Test void testImpact()
@Test void testImpact7()
{
Vector3d v = new Vector3d(0.0, 35.0, 0.0);
double r = 25.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), false);
}
@Test void testImpact8()
{
Vector3d v = new Vector3d(0.0, -40.0, 0.0);
double r = 30.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), false);
}
@Test void testImpact9()
{
Vector3d v = new Vector3d(50.0, -30.0, 0.0);
double r = 58.30951895;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), true);
}
@Test void testImpact10()
{
Vector3d v = new Vector3d(15.0, 20.0, 0.0);
double r = 25.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), true);
}
@Test void testImpact11()
{
Vector3d v = new Vector3d(30.0, -15.0, 0.0);
double r = 30.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), false);
}
@Test void testImpact12()
{
// TODO (Jerome) 4hrs
Vector3d v = new Vector3d(31.0, 46.0, 0.0);
double r = 40.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), false);
}
@Test void testImpact13()
{
Vector3d v = new Vector3d(-20.0, -15.0, 0.0);
double r = 25.0;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), true);
}
@Test void testImpact14()
{
Vector3d v = new Vector3d(-30.0, 20.0, 0.0);
double r = 37;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), true);
}
@Test void testImpact15()
{
Vector3d v = new Vector3d(-40.0, -30.0, 0.0);
double r = 30;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), false);
}
@Test void testImpact16()
{
Vector3d v = new Vector3d(-20.0, 60.0, 0.0);
double r = 60;
LandingController lc = new LandingController();
assertEquals(lc.impact(v, r), false);
}

@Test void testDrag()
Expand Down