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 IsSolutionTest {

private void test(Objective obj, String solution, boolean expected) {
WalkTheDog game = new WalkTheDog(obj);
boolean output = game.isSolution(solution);

assertEquals(expected, output, “Expected isSolution to return ” + expected +
” for solution ‘” + solution +
“‘ and objective ” + obj.getProblemNumber() +
” (‘” + obj.getInitialState() + “‘)” +
“, but got ” + output + “.”);
}

@Test
public void testSimple() {
// Wrong length
Objective empty_obj = new Objective(“”,1);
String sol = “00301131223233”;
for (int i = 0; i <= 14; i++) { test(empty_obj, sol.substring(0, i), i==14); } // Off board test(empty_obj, "00301131223234", false); test(empty_obj, "00301131223233", true); // Invalid Placement // Can add more here in future if necessary test(empty_obj, "00301131223232", false); test(empty_obj, "00301131223223", false); test(empty_obj, "10301131223223", false); } // Can break this up into start, junior etc to create more tests @Test public void testAll() { for (int i = 0; i < Objective.getOBJECTIVES().length; i++) { test(Objective.getObjective(i), SolveTest.sols[i], true); } for (int i = 0; i < not_sols.length; i++) { test(Objective.getObjective(i), not_sols[i], false); } } public static String[] not_sols = { "20231210030233", "02321131001013", "01312303120220", "32231210000120", "23201210010203", "01310323302033", "32022110231303", "32022110031323", "02321100130331", "11030200232232", "01310323120220", "03331210010021", "01311232302033", "03330002111020", "03331232010020", "02321030130331", "00032022313033", "03001210232232", "23200200303132", "13103331000102", "30000103121121", "00032011222131", "03330110121120", "00031311222130", "00031120303132", "00120323222130", "00300211222133", "02321333001020", "13322000313033", "01310323201022", "00031113201023", "01313212030223", "20230103121131", "00301311020122", "02320011130331", "30332303001002", "23200201101130", "32020020231330", "10132321030231", "20221210313033", "00120323222130", "20230110030231", "00301311020131", "03332110010030", "01310323221230", "00300222110113", "20230200111013", "10133032030221", "23200301323330", "03002321302032", "00031221231332", "23023010213132", "13320200221230", "02322110303133", "03331100201022", "02211333001020", "01310323322230", "00300222132333", "00031311302032", "30330200112113", "20230110030231", "03221030121121", "01310323120232", "03330002222131", "31231210030233", "21130020303132", "20230200130331", "02321120130330", "20321210030223", "01132022313033", "32113010030223", "21130200232232", "33211311020330", "02322303001011", "32023010213123", "20231311001002", "32023010000133", "01310323201033", "00032011313033", "33211311222300", }; }