78 lines
1.3 KiB
Go
78 lines
1.3 KiB
Go
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")
|
|
})
|
|
}
|
|
}
|