Skip to content

Commit 95e2cc7

Browse files
committed
[typ] add TestInput()
1 parent b43928a commit 95e2cc7

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

kadai3/imura81gt/typ/typing/typing_test.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,37 @@ import (
66
"testing"
77
)
88

9-
func TestInput(t *testing.T) {}
9+
func TestInput(t *testing.T) {
10+
testcases := []struct {
11+
caseName string
12+
input string
13+
expected string
14+
}{
15+
{caseName: "input some word", input: "foo bar", expected: "foo bar"},
16+
{caseName: "input line feed", input: "\n", expected: ""},
17+
}
18+
fmt.Println(testcases)
19+
for _, tc := range testcases {
20+
tc := tc // capture range variable. need to set when run parallel test.
21+
22+
t.Run(tc.caseName, func(t *testing.T) {
23+
t.Parallel()
24+
25+
var buf bytes.Buffer
26+
buf.Write([]byte(tc.input))
27+
actual := <-input(&buf)
28+
29+
if tc.expected != actual {
30+
t.Errorf("\ncaseName:%s\nactual:%+v\nExpected:%+v\n",
31+
tc.caseName,
32+
actual,
33+
tc.expected,
34+
)
35+
}
36+
})
37+
}
38+
39+
}
1040

1141
func TestLoad(t *testing.T) {}
1242

0 commit comments

Comments
 (0)