-
Notifications
You must be signed in to change notification settings - Fork 0
/
xml_test.go
82 lines (67 loc) · 1.65 KB
/
xml_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
78
79
80
81
82
package balafon_test
import (
"bytes"
"testing"
"github.com/mgnsk/balafon"
. "github.com/onsi/gomega"
)
func TestXMLSharpNotes(t *testing.T) {
t.Run("natural base note plus sharp", func(t *testing.T) {
g := NewWithT(t)
var buf bytes.Buffer
err := balafon.ToXML(&buf, []byte(`
:assign c 60
c#
`))
g.Expect(err).NotTo(HaveOccurred())
g.Expect(buf.String()).To(ContainSubstring("<pitch>"))
g.Expect(buf.String()).To(ContainSubstring("<alter>1</alter>"))
g.Expect(buf.String()).To(ContainSubstring("<step>C</step>"))
g.Expect(buf.String()).To(ContainSubstring("<octave>4</octave>"))
})
t.Run("sharp base note", func(t *testing.T) {
g := NewWithT(t)
var buf bytes.Buffer
err := balafon.ToXML(&buf, []byte(`
:assign c 61
c
`))
g.Expect(err).NotTo(HaveOccurred())
g.Expect(buf.String()).To(ContainSubstring("<pitch>"))
g.Expect(buf.String()).To(ContainSubstring("<alter>1</alter>"))
g.Expect(buf.String()).To(ContainSubstring("<step>C</step>"))
g.Expect(buf.String()).To(ContainSubstring("<octave>4</octave>"))
})
}
func TestXMLChords(t *testing.T) {
t.Run("single voice can chord", func(t *testing.T) {
g := NewWithT(t)
var buf bytes.Buffer
err := balafon.ToXML(&buf, []byte(`
:assign c 60
:bar one
c
c
:end
:play one
`))
g.Expect(err).NotTo(HaveOccurred())
g.Expect(buf.String()).To(ContainSubstring("<chord>"))
})
t.Run("multiple voice cannot chord", func(t *testing.T) {
g := NewWithT(t)
var buf bytes.Buffer
err := balafon.ToXML(&buf, []byte(`
:assign c 60
:bar one
:voice 1
c
:voice 2
c
:end
:play one
`))
g.Expect(err).NotTo(HaveOccurred())
g.Expect(buf.String()).NotTo(ContainSubstring("<chord>"))
})
}