From 5d63f3c4d6f058e292164cf3ef98e63bca8f1d08 Mon Sep 17 00:00:00 2001 From: Kharec Date: Fri, 28 Nov 2025 12:02:23 +0100 Subject: [PATCH] test: add unit test for part two --- internal/2020/DaySeven/code_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/internal/2020/DaySeven/code_test.go b/internal/2020/DaySeven/code_test.go index 186d7aa..3e035ab 100644 --- a/internal/2020/DaySeven/code_test.go +++ b/internal/2020/DaySeven/code_test.go @@ -21,3 +21,31 @@ func TestPartOne(t *testing.T) { t.Errorf("PartOne() = %d, want %d", got, expected) } } + +func TestPartTwo(t *testing.T) { + secondTestInput := []string{ + "shiny gold bags contain 2 dark red bags.", + "dark red bags contain 2 dark orange bags.", + "dark orange bags contain 2 dark yellow bags.", + "dark yellow bags contain 2 dark green bags.", + "dark green bags contain 2 dark blue bags.", + "dark blue bags contain 2 dark violet bags.", + "dark violet bags contain no other bags.", + } + + t.Run("First Example", func(t *testing.T) { + expected := 32 + got := PartTwo(testInput) + if got != expected { + t.Errorf("PartTwo() = %d, want %d", got, expected) + } + }) + + t.Run("Second Example", func(t *testing.T) { + expected := 126 + got := PartTwo(secondTestInput) + if got != expected { + t.Errorf("PartTwo() = %d, want %d", got, expected) + } + }) +}