aoc2024/day-11/internal/one/util_internal_test.go

33 lines
687 B
Go

package one
import "testing"
func TestSplitNumber(t *testing.T) {
tt := map[string]struct {
number int
expectedLeft int
expectedRight int
expectedOk bool
}{
"number is 99, expect 9 and 9": {
number: 99,
expectedLeft: 9,
expectedRight: 9,
},
"number is 2024, expect 20 and 24": {
number: 2024,
expectedLeft: 20,
expectedRight: 24,
},
}
for name, tc := range tt {
t.Run(name, func(t *testing.T) {
left, right := splitNumber(tc.number)
if left != tc.expectedLeft && right != tc.expectedRight {
t.Errorf("expected left %d got %d, right %d got %d", tc.expectedLeft, left, tc.expectedRight, right)
}
})
}
}