-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser_test.go
67 lines (62 loc) · 1.12 KB
/
parser_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package kbo
import (
"fmt"
"net/http"
"testing"
"time"
)
func TestParserParse(t *testing.T) {
parser := NewParser(URL, &http.Client{})
tables := []struct {
date time.Time
expected []Game
}{
{
time.Date(2018, 5, 6, 0, 0, 0, 0, time.UTC),
[]Game{
{
Home: Lions,
Away: Eagles,
Canceled: true,
Score: [2]int{},
},
{
Home: Wyverns,
Away: Giants,
Canceled: true,
Score: [2]int{},
},
{
Home: Tigers,
Away: Dinos,
Canceled: false,
Score: [2]int{3, 11},
},
{
Home: Twins,
Away: Bears,
Canceled: false,
Score: [2]int{13, 5},
},
{
Home: Wiz,
Away: Heroes,
Canceled: true,
Score: [2]int{},
},
},
},
}
for _, c := range tables {
result, _ := parser.Parse(c.date)
if len(result) != len(c.expected) {
t.Errorf("length is not same.")
}
for i := range result {
fmt.Println(result[i])
if result[i] != c.expected[i] {
t.Errorf("expected:\n%s\ngot:\n%s\nat index %d.", c.expected[i], result[i], i)
}
}
}
}