-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogram_test.go
77 lines (65 loc) · 1.5 KB
/
program_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
68
69
70
71
72
73
74
75
76
77
package radicron
import (
"embed"
"strings"
"testing"
)
var (
//go:embed test/weekly-program-test.xml
WeeklyProgramTestXML embed.FS
)
func TestWeeklyProgramUnmarshal(t *testing.T) {
xmlFile, err := WeeklyProgramTestXML.Open("test/weekly-program-test.xml")
if err != nil {
t.Error(err)
}
progs, err := decodeWeeklyProgram(xmlFile)
if err != nil {
t.Error(err)
}
if len(progs) != 1 {
t.Errorf("unmarshal failed: %v", progs)
}
p := progs[0]
var got, want string
got = p.StationID
want = "FMT"
if got != want {
t.Errorf("p.StationID => %v, want %v", got, want)
}
got = p.Ft
want = "20230605130000"
if got != want {
t.Errorf("p.Ft => %v, want %v", got, want)
}
got = p.To
want = "20230605145500"
if got != want {
t.Errorf("p.To => %v, want %v", got, want)
}
got = p.Title
want = "山崎怜奈の誰かに話したかったこと。"
if got != want {
t.Errorf("p.Title => %v, want %v", got, want)
}
got = p.Pfm
want = "山崎怜奈"
if got != want {
t.Errorf("p.Pfm => %v, want %v", got, want)
}
got = p.Genre.Personality
want = "タレント"
if got != want {
t.Errorf("p.Genre.Personality => %v, want %v", got, want)
}
got = p.Genre.Program
want = "トーク"
if got != want {
t.Errorf("p.Genre.Program => %v, want %v", got, want)
}
got = strings.Join(p.Tags, ",")
want = "山崎怜奈,音楽との出会いが楽しめる,作業がはかどる,気分転換におすすめ,学生におすすめ"
if got != want {
t.Errorf("p.Tags => %v, want %v", got, want)
}
}