feat: solve day 1 part 1

This commit is contained in:
Stevan Freeborn
2025-12-01 06:49:26 -06:00
parent 2734425a33
commit df4bd2cfa3
10 changed files with 297 additions and 3 deletions
+39
View File
@@ -0,0 +1,39 @@
package instruction_test
import (
"fmt"
"testing"
"github.com/StevanFreeborn/advent-of-code-2025/cmd/01/instruction"
)
func TestFromLine(t *testing.T) {
expectedDirection := "L"
expectedDistance := 7
line := fmt.Sprintf("%s%d", expectedDirection, expectedDistance)
result := instruction.FromLine(line)
if result.Direction() != expectedDirection {
t.Errorf("got direction %s but expected direction %s", result.Direction(), expectedDirection)
}
if result.Distance() != expectedDistance {
t.Errorf("got distance %d but expected distance %d", result.Distance(), expectedDistance)
}
}
func TestFromParts(t *testing.T) {
expectedDirection := "L"
expectedDistance := 7
result := instruction.FromParts(expectedDirection, expectedDistance)
if result.Direction() != expectedDirection {
t.Errorf("got direction %s but expected direction %s", result.Direction(), expectedDirection)
}
if result.Distance() != expectedDistance {
t.Errorf("got distance %d but expected distance %d", result.Distance(), expectedDistance)
}
}