-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathevents_test.go
56 lines (48 loc) · 1.16 KB
/
events_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
package vst2_test
import (
"fmt"
"reflect"
"testing"
"pipelined.dev/audio/vst2"
)
func TestEvents(t *testing.T) {
dump := vst2.SysExData([]byte("this is a test"))
defer dump.Free()
events := vst2.Events(
&vst2.MIDIEvent{},
&vst2.SysExMIDIEvent{
SysExDump: dump,
},
)
defer events.Free()
assertNotNil(t, "events", events)
for i := 0; i < events.NumEvents(); i++ {
fmt.Printf("%v", events.Event(i))
switch ev := events.Event(i).(type) {
case *vst2.MIDIEvent:
case *vst2.SysExMIDIEvent:
fmt.Printf("dump %v\n", string(ev.SysExDump.Bytes()))
}
}
}
func assertEqual(t *testing.T, name string, result, expected interface{}) {
t.Helper()
if !reflect.DeepEqual(expected, result) {
t.Fatalf("%v\nresult: \t%T\t%+v \nexpected: \t%T\t%+v", name, result, result, expected, expected)
}
}
func assertNotNil(t *testing.T, name string, result interface{}) {
t.Helper()
if reflect.DeepEqual(nil, result) {
t.Fatalf("%v\nresult: \t%T\t%+v \nexpected: \t%T\t%+v", name, result, result, nil, nil)
}
}
func assertPanic(t *testing.T, fn func()) {
t.Helper()
defer func() {
if r := recover(); r == nil {
t.Fatalf("expected panic")
}
}()
fn()
}