merge master (ws/apifix)
This commit is contained in:
commit
48b4b4cc4e
39 files changed
+1158
-73
No files matched your search
@@ -169,6 +169,23 @@ do
|
||||
t:check(nope == nil and nerr.code == Err.ARG, "encode refuses nil")
|
||||
end
|
||||
|
||||
-- track.name is written as a 0x03 meta event at tick 0 when the track has none; an existing one wins
|
||||
do
|
||||
local m = Types.Midi.new(96)
|
||||
local notes = { { tick = 0, type = "noteOn", channel = 0, data = { 60, 100 } }, { tick = 96, type = "noteOff", channel = 0, data = { 60, 0 } } }
|
||||
m.tracks[1] = { name = "Lead", events = notes }
|
||||
m.tracks[2] = { name = "Ignored", events = { { tick = 0, type = "meta", meta = 0x03, data = { string.byte("Bass", 1, -1) } } } }
|
||||
m.tracks[3] = { name = "", events = {} }
|
||||
local back = decode(Midi.encode(m) :: buffer)
|
||||
t:eq(back.tracks[1].name, "Lead", "track.name written")
|
||||
local first = back.tracks[1].events[1]
|
||||
t:check(first.type == "meta" and first.meta == 0x03 and first.tick == 0, "as a 0x03 event at tick 0")
|
||||
t:eq(#back.tracks[1].events, 4, "name + 2 notes + end of track")
|
||||
t:eq(back.tracks[2].name, "Bass", "the track's own 0x03 event wins")
|
||||
t:eq(back.tracks[3].name, nil, "empty name: nothing written")
|
||||
t:eq(#m.tracks[1].events, 2, "the caller's events are not changed")
|
||||
end
|
||||
|
||||
-- crafted bad files
|
||||
for _, c in Bad do
|
||||
local ok, m, err = pcall(decode, c.data)
|
||||
|
||||
Reference in new issue
Block a user