Init commit

This commit is contained in:
2025-12-03 22:38:57 +02:00
commit 600b41ba7a
19 changed files with 5365 additions and 0 deletions

30
cmd/day2/digits_test.go Normal file
View File

@@ -0,0 +1,30 @@
package main
import (
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_digits_number(t *testing.T) {
tests := []struct {
n uint
d []uint8
}{
{n: 0, d: []uint8{0}},
{n: 1234, d: []uint8{4, 3, 2, 1}},
{n: 12345, d: []uint8{5, 4, 3, 2, 1}},
}
for _, tt := range tests {
name := strconv.FormatUint(uint64(tt.n), 10)
t.Run(name, func(t *testing.T) {
t.Run("digits", func(t *testing.T) {
assert.Equal(t, tt.d, digits(tt.n))
})
t.Run("number", func(t *testing.T) {
assert.Equal(t, tt.n, number(tt.d))
})
})
}
}