28 lines
454 B
Go
28 lines
454 B
Go
package walk
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestWalk(t *testing.T) {
|
|
t.Run("walk function test", func(t *testing.T) {
|
|
expected := "Chris"
|
|
var got []string
|
|
|
|
x := struct {
|
|
Name string
|
|
}{expected}
|
|
|
|
Walk(x, func(input string) {
|
|
got = append(got, input)
|
|
})
|
|
|
|
if len(got) != 1 {
|
|
t.Errorf("wrong number of function calls, got %d want %d", len(got), 1)
|
|
}
|
|
if got[0] != expected {
|
|
t.Errorf("got %q want %q", got[0], expected)
|
|
}
|
|
})
|
|
}
|