CS计算机代考程序代写 Java junit package comp1110.ass1;

package comp1110.ass1;

import org.junit.jupiter.api.*;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;

@Timeout(value = 1000, unit = MILLISECONDS)
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class LocationTask2Test {

private void offBoardTest(Location input, boolean expected) {
boolean output = input.offBoard();
assertEquals(expected, output, “Expected offBoard called on Location (” + input.getX() +
“,” + input.getY() + “) to return ” + expected +
“, but got ” + output + “.”);
}

@Test
public void testOffBoard() {
for (int x = -10; x < 10; x++) { for (int y = -10; y < 10; y++) { offBoardTest(new Location(x, y), x < 0 || x >= 4 || y < 0 || y >= 4);
}
}
}
}