This commit is contained in:
2018-03-30 16:40:00 +02:00
parent b613303b29
commit 049d3ba14b
3 changed files with 9 additions and 10 deletions

View File

@@ -4,7 +4,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.RepeatedTest;
import static org.junit.jupiter.api.Assertions.*;
import worms.util.Tuple;
import worms.util.Coordinate;
import java.util.Random;
@@ -15,12 +15,12 @@ class WormTest {
@BeforeAll
static void setUp() {
worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1);
worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1);
}
@RepeatedTest(5000)
void move() {
worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1);
worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1);
int steps = r.nextInt(5101) - 100;
double maxAngle = Math.abs(2 * Math.PI - worm.getOrientation());
double minAngle = worm.getOrientation();
@@ -36,7 +36,7 @@ class WormTest {
double newLocX = worm.getLocation().item1 + steps * worm.getRadius() * Math.cos(worm.getOrientation());
double newLocY = worm.getLocation().item2 + steps * worm.getRadius() * Math.sin(worm.getOrientation());
worm.move(steps);
assertEquals(Tuple.create(newLocX, newLocY), worm.getLocation());
assertEquals(Coordinate.create(newLocX, newLocY), worm.getLocation());
}
}
@@ -47,7 +47,7 @@ class WormTest {
if (!Worm.isValidOrientation(oldAngle + angle) || worm.getActionPoints() - (long) Math.ceil(Math.toDegrees(angle) / 6) < 0) {
assertThrows(AssertionError.class, () -> worm.turn(angle));
worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1);
worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1);
}
else {
worm.turn(angle);
@@ -64,7 +64,7 @@ class WormTest {
@RepeatedTest(5000)
void jump() {
worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1);
worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1);
double maxAngle = Math.abs(2 * Math.PI - worm.getOrientation());
double minAngle = worm.getOrientation();
double combAngle = maxAngle + minAngle;
@@ -82,12 +82,12 @@ class WormTest {
double v = force / worm.getMass() * Worm.FORCE_TIME;
double newLocX = worm.getLocation().item1 + Math.pow(v, 2) * Math.sin(2 * orient) / Worm.G;
worm.jump();
assertEquals(Tuple.create(newLocX, worm.getLocation().item2), worm.getLocation());
assertEquals(Coordinate.create(newLocX, worm.getLocation().getCoordinateY()), worm.getLocation());
}
}
@Test
void doubleJump() {
worm = new Worm(Tuple.create(0.0, 0.0), 0, "Test", 1);
worm = new Worm(Coordinate.create(0.0, 0.0), 0, "Test", 1);
worm.jump();
assertThrows(IllegalStateException.class, () -> worm.jump());
}