Move code out of cmd

This commit is contained in:
2025-12-03 23:03:27 +02:00
parent 1d458af093
commit 9b17ee26b9
16 changed files with 1 additions and 1 deletions

77
day2/main_test.go Normal file
View File

@@ -0,0 +1,77 @@
package main
import (
"strconv"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_scanPart1(t *testing.T) {
tests := []struct {
id uint
advance uint
ok bool
}{
// {
// id: 9,
// advance: 1,
// ok: true,
// },
// {
// id: 10,
// advance: 1,
// ok: true,
// },
// {
// id: 11,
// advance: 1,
// ok: false,
// },
// {
// id: 99,
// advance: 1,
// ok: false,
// },
// {
// id: 100,
// advance: 900,
// ok: true,
// },
{
id: 1234,
advance: 1,
ok: true,
},
}
for _, tt := range tests {
name := strconv.FormatUint(uint64(tt.id), 10)
t.Run(name, func(t *testing.T) {
advance, ok := scanPart1(tt.id)
assert.Equal(t, tt.advance, advance, "advance")
assert.Equal(t, tt.ok, ok, "ok")
})
}
}
func Test_scanPart2(t *testing.T) {
tests := []struct {
id uint
advance uint
ok bool
}{
{
id: 111,
advance: 1,
ok: false,
},
}
for _, tt := range tests {
name := strconv.FormatUint(uint64(tt.id), 10)
t.Run(name, func(t *testing.T) {
advance, ok := scanPart2(tt.id)
assert.Equal(t, tt.advance, advance, "advance")
assert.Equal(t, tt.ok, ok, "ok")
})
}
}