Move code out of cmd
This commit is contained in:
77
day2/main_test.go
Normal file
77
day2/main_test.go
Normal 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")
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user