From 531b0d6632963a46354a354e0088735fcbc9f6fe Mon Sep 17 00:00:00 2001 From: Johannes Loher Date: Tue, 8 Dec 2020 12:25:23 +0100 Subject: [PATCH] day8: rearrange unittest location --- day8/part2/main.d | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/day8/part2/main.d b/day8/part2/main.d index fc94deb..8a568c3 100644 --- a/day8/part2/main.d +++ b/day8/part2/main.d @@ -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