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