day8: rearrange unittest location
This commit is contained in:
parent
d0c3bb0464
commit
531b0d6632
1 changed files with 20 additions and 20 deletions
|
@ -29,6 +29,26 @@ auto executeProgramAndReturnAcc(Program program)
|
|||
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)
|
||||
{
|
||||
return program.enumerate
|
||||
|
@ -48,26 +68,6 @@ auto fixProgramAndReturnAcc(Program program)
|
|||
.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
|
||||
{
|
||||
auto program = `nop +0
|
||||
|
|
Loading…
Reference in a new issue