From 414f419c1481afb9e8fabfa9e315691056568b84 Mon Sep 17 00:00:00 2001 From: Kharec Date: Mon, 22 Dec 2025 10:03:50 +0100 Subject: [PATCH] test: add unit test for part two --- internal/2017/DayOne/code_test.go | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/internal/2017/DayOne/code_test.go b/internal/2017/DayOne/code_test.go index 1140d4d..a2360fc 100644 --- a/internal/2017/DayOne/code_test.go +++ b/internal/2017/DayOne/code_test.go @@ -39,3 +39,46 @@ func TestPartOne(t *testing.T) { }) } } + +func TestPartTwo(t *testing.T) { + tests := []struct { + name string + input []int + expected int + }{ + { + name: "1212 produces 6", + input: []int{1, 2, 1, 2}, + expected: 6, + }, + { + name: "1221 produces 0", + input: []int{1, 2, 2, 1}, + expected: 0, + }, + { + name: "123425 produces 4", + input: []int{1, 2, 3, 4, 2, 5}, + expected: 4, + }, + { + name: "123123 produces 12", + input: []int{1, 2, 3, 1, 2, 3}, + expected: 12, + }, + { + name: "12131415 produces 4", + input: []int{1, 2, 1, 3, 1, 4, 1, 5}, + expected: 4, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got := PartTwo(tt.input) + if got != tt.expected { + t.Errorf("PartTwo() = %d, want %d", got, tt.expected) + } + }) + } +}