day8: rearrange unittest location

This commit is contained in:
Johannes Loher 2020-12-08 12:25:23 +01:00
parent d0c3bb0464
commit 531b0d6632

View file

@ -29,6 +29,26 @@ auto executeProgramAndReturnAcc(Program program)
return tuple(accumulator, ip == program.length); return tuple(accumulator, ip == program.length);
} }
unittest
{
auto program = `nop +0
acc +1
jmp +4
acc +3
jmp -3
acc -99
acc +1
jmp -4
acc +6`.splitter("\n").filter!(not!empty)
.map!((line) {
auto opAndArg = line.split(" ");
return tuple(opAndArg[0], opAndArg[1].to!int);
})
.array;
assert(program.executeProgramAndReturnAcc == tuple(5, false));
}
auto fixProgramAndReturnAcc(Program program) auto fixProgramAndReturnAcc(Program program)
{ {
return program.enumerate return program.enumerate
@ -48,26 +68,6 @@ auto fixProgramAndReturnAcc(Program program)
.front; .front;
} }
unittest
{
auto program = `nop +0
acc +1
jmp +4
acc +3
jmp -3
acc -99
acc +1
jmp -4
acc +6`.splitter("\n").filter!(not!empty)
.map!((line) {
auto opAndArg = line.split(" ");
return tuple(opAndArg[0], opAndArg[1].to!int);
})
.array;
assert(program.executeProgramAndReturnAcc == tuple(5, false));
}
unittest unittest
{ {
auto program = `nop +0 auto program = `nop +0