Move code out of cmd

This commit is contained in:
2025-12-03 23:03:27 +02:00
parent dec06889a6
commit 496c7af586
13 changed files with 1 additions and 1 deletions

30
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))
})
})
}
}