Commit b74013c0 authored by Snigdha Saha's avatar Snigdha Saha
Browse files

more thorough program testing

parent c5c884a5
No related merge requests found
Pipeline #78459 failed with stage
in 0 seconds
Showing with 6 additions and 5 deletions
+6 -5
......@@ -84,14 +84,14 @@ public class ProgramTests {
return new Program(program);
}
private void testProgram(Program program, int maxColors) {
private void testProgram(Program program, Program controlProgram, int maxColors) {
NodeGraph interference = program.constructInterferenceGraph();
DSatur.color(interference);
Program modified = program.color(interference.getColoring());
assertTrue(modified.variables().size() <= maxColors,
"Interference graph coloring uses more colors than expected " +
"(ie: more variables were connected by edges than expected).");
assertIterableEquals(interpret(program), interpret(modified), "Interference graph does not validly "
assertIterableEquals(interpret(controlProgram), interpret(modified), "Interference graph does not validly "
+ " reflect interferences (ie: the resulting program overwrites its own variables).");
}
......@@ -99,14 +99,14 @@ public class ProgramTests {
@Tag("A")
@DisplayName("Test on 8-instruction program")
public void testProgram1() {
testProgram(program1(), 3);
testProgram(program1(), program1(),3);
}
@Test
@Tag("A")
@DisplayName("Test on 10-instruction program")
public void testProgram2(){
testProgram(program2(), 3);
testProgram(program2(), program2(),3);
}
@Test
......@@ -116,7 +116,8 @@ public class ProgramTests {
List<Integer> answers = List.of(2, 5, 2, 3, 3, 3, 2, 1, 4, 3, 2, 3, 3, 4, 2, 2, 4, 2, 3, 2, 2, 4, 2, 2, 3, 3, 3, 2, 4, 3, 4, 3, 2, 1, 4, 2, 2, 4, 3, 4, 2, 5, 3, 2, 3, 3, 3, 3, 3, 1, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 2, 2, 2, 2, 2, 3, 2, 2, 3, 3, 3, 2, 2, 3, 2, 2, 4, 2, 4, 3, 3, 2, 3, 4, 1, 2, 3, 2, 3, 1, 3, 3, 3, 2, 2, 2, 3, 2, 3, 4, 2, 4, 4, 4, 3, 5, 3, 5, 2, 3, 2, 2, 3, 2, 4, 2, 4, 2, 2, 3, 4, 2, 3, 3, 3, 4, 3, 3, 3, 4, 3, 2, 3, 2, 3, 4, 3, 3, 3, 4, 3, 3, 3, 2, 2, 3, 2);
for (int seed = 1; seed < 150; seed++) {
Program p = programGen(15, seed);
testProgram(p, answers.get(seed - 1));
Program cP = programGen(15, seed);
testProgram(p, cP, answers.get(seed - 1));
}
}
}
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