midi-nibbler 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/nibbler.rb +3 -4
- data/test/helper.rb +1 -1
- data/test/hex_processor_test.rb +13 -13
- data/test/midi_message_test.rb +34 -34
- data/test/midilib_test.rb +33 -33
- data/test/parser_buffer_test.rb +15 -15
- data/test/parser_rejected_test.rb +10 -10
- data/test/parser_test.rb +41 -46
- data/test/session_test.rb +40 -40
- data/test/type_conversion_test.rb +13 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12e9cb3c3684c88cfaa6def382fd591872380563
|
4
|
+
data.tar.gz: 6f842d364c13786f66d8696ff05e8fc2a02c0ae9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 418f23d23ece2aca433e6fa7bca758f347627cea9c35fde0c6276bc5eba9af0fdb5799ba8305fabdceac8a03707e3e79596a3b52821d70f160a62930775a0a84
|
7
|
+
data.tar.gz: d9bba92335832c7138bebb7ce99aad3ad9ae898abd0e394aa17c9a8307c947ef65440fedb170b924173c5b70614b71672bf0a51ffb3df3f7faa6c7b9f4db32a4
|
data/lib/nibbler.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Parse MIDI Messages
|
3
3
|
# (c)2011-2014 Ari Russo and licensed under the Apache 2.0 License
|
4
|
-
#
|
4
|
+
#
|
5
5
|
|
6
6
|
# libs
|
7
7
|
require "forwardable"
|
@@ -18,8 +18,8 @@ require "nibbler/session"
|
|
18
18
|
# Parse MIDI Messages
|
19
19
|
#
|
20
20
|
module Nibbler
|
21
|
-
|
22
|
-
VERSION = "0.2.
|
21
|
+
|
22
|
+
VERSION = "0.2.2"
|
23
23
|
|
24
24
|
# Shortcut to a new parser session
|
25
25
|
def self.new(*a, &block)
|
@@ -27,4 +27,3 @@ module Nibbler
|
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
30
|
-
|
data/test/helper.rb
CHANGED
data/test/hex_processor_test.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class Nibbler::HexProcessorTest < Test
|
4
|
-
|
3
|
+
class Nibbler::HexProcessorTest < Minitest::Test
|
4
|
+
|
5
5
|
def test_to_nibbles_array_mixed
|
6
6
|
processor = Nibbler::HexProcessor
|
7
7
|
array = [0x90, "90", "9"]
|
8
8
|
nibbles = processor.send(:process, array)
|
9
9
|
assert_equal([0x90, "90", "9"], array)
|
10
|
-
assert_equal(["9", "0", "9", "0", "9"], nibbles)
|
10
|
+
assert_equal(["9", "0", "9", "0", "9"], nibbles)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def test_to_nibbles_mixed
|
14
14
|
processor = Nibbler::HexProcessor
|
15
15
|
array = [0x90, "90", "9"]
|
16
16
|
nibbles = processor.send(:process, *array)
|
17
17
|
assert_equal([0x90, "90", "9"], array)
|
18
|
-
assert_equal(["9", "0", "9", "0", "9"], nibbles)
|
18
|
+
assert_equal(["9", "0", "9", "0", "9"], nibbles)
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_to_nibbles_numeric
|
@@ -23,34 +23,34 @@ class Nibbler::HexProcessorTest < Test::Unit::TestCase
|
|
23
23
|
num = 0x90
|
24
24
|
nibbles = processor.send(:process, num)
|
25
25
|
assert_equal(0x90, num)
|
26
|
-
assert_equal(["9", "0"], nibbles)
|
27
|
-
end
|
26
|
+
assert_equal(["9", "0"], nibbles)
|
27
|
+
end
|
28
28
|
|
29
29
|
def test_to_nibbles_string
|
30
30
|
processor = Nibbler::HexProcessor
|
31
31
|
str = "904050"
|
32
32
|
nibbles = processor.send(:process, str)
|
33
33
|
assert_equal("904050", str)
|
34
|
-
assert_equal(["9", "0", "4", "0", "5", "0"], nibbles)
|
34
|
+
assert_equal(["9", "0", "4", "0", "5", "0"], nibbles)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def test_processor_numeric
|
38
38
|
processor = Nibbler::HexProcessor
|
39
39
|
badnum = 560
|
40
40
|
output = processor.send(:filter_numeric, badnum)
|
41
41
|
assert_equal(560, badnum)
|
42
|
-
assert_equal(nil, output)
|
42
|
+
assert_equal(nil, output)
|
43
43
|
goodnum = 50
|
44
44
|
output = processor.send(:filter_numeric, goodnum)
|
45
45
|
assert_equal(50, goodnum)
|
46
|
-
assert_equal(50, output)
|
46
|
+
assert_equal(50, output)
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def test_processor_string
|
50
50
|
processor = Nibbler::HexProcessor
|
51
51
|
str = "(0xAdjskla#(#"
|
52
52
|
outp = processor.send(:filter_string, str)
|
53
53
|
assert_equal("0ADA", outp)
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
end
|
data/test/midi_message_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "helper"
|
2
2
|
require "nibbler/midi-message"
|
3
3
|
|
4
|
-
class Nibbler::MIDIMessageTest < Test
|
4
|
+
class Nibbler::MIDIMessageTest < Minitest::Test
|
5
5
|
|
6
6
|
def test_note_off
|
7
7
|
lib = Nibbler::MIDIMessage
|
@@ -9,118 +9,118 @@ class Nibbler::MIDIMessageTest < Test::Unit::TestCase
|
|
9
9
|
assert_equal(MIDIMessage::NoteOff, message.class)
|
10
10
|
assert_equal(0, message.channel)
|
11
11
|
assert_equal(0x40, message.note)
|
12
|
-
assert_equal(0x40, message.velocity)
|
12
|
+
assert_equal(0x40, message.velocity)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def test_note_on
|
16
16
|
lib = Nibbler::MIDIMessage
|
17
17
|
message = lib.note_on(0x0, 0x40, 0x40)
|
18
18
|
assert_equal(MIDIMessage::NoteOn, message.class)
|
19
19
|
assert_equal(0, message.channel)
|
20
20
|
assert_equal(0x40, message.note)
|
21
|
-
assert_equal(0x40, message.velocity)
|
22
|
-
end
|
23
|
-
|
21
|
+
assert_equal(0x40, message.velocity)
|
22
|
+
end
|
23
|
+
|
24
24
|
def test_polyphonic_aftertouch
|
25
25
|
lib = Nibbler::MIDIMessage
|
26
26
|
message = lib.polyphonic_aftertouch(0x1, 0x40, 0x40)
|
27
27
|
assert_equal(MIDIMessage::PolyphonicAftertouch, message.class)
|
28
28
|
assert_equal(1, message.channel)
|
29
29
|
assert_equal(0x40, message.note)
|
30
|
-
assert_equal(0x40, message.value)
|
31
|
-
end
|
32
|
-
|
30
|
+
assert_equal(0x40, message.value)
|
31
|
+
end
|
32
|
+
|
33
33
|
def test_control_change
|
34
34
|
lib = Nibbler::MIDIMessage
|
35
35
|
message = lib.control_change(0x2, 0x20, 0x20)
|
36
36
|
assert_equal(MIDIMessage::ControlChange, message.class)
|
37
37
|
assert_equal(message.channel, 2)
|
38
38
|
assert_equal(0x20, message.index)
|
39
|
-
assert_equal(0x20, message.value)
|
39
|
+
assert_equal(0x20, message.value)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def test_program_change
|
43
43
|
lib = Nibbler::MIDIMessage
|
44
44
|
message = lib.program_change(0x3, 0x40)
|
45
45
|
assert_equal(MIDIMessage::ProgramChange, message.class)
|
46
46
|
assert_equal(3, message.channel)
|
47
|
-
assert_equal(0x40, message.program)
|
47
|
+
assert_equal(0x40, message.program)
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def test_channel_aftertouch
|
51
51
|
lib = Nibbler::MIDIMessage
|
52
52
|
message = lib.channel_aftertouch(0x3, 0x50)
|
53
53
|
assert_equal(MIDIMessage::ChannelAftertouch, message.class)
|
54
54
|
assert_equal(3, message.channel)
|
55
|
-
assert_equal(0x50, message.value)
|
56
|
-
end
|
57
|
-
|
55
|
+
assert_equal(0x50, message.value)
|
56
|
+
end
|
57
|
+
|
58
58
|
def test_pitch_bend
|
59
59
|
lib = Nibbler::MIDIMessage
|
60
60
|
message = lib.pitch_bend(0x0, 0x20, 0x00) # center
|
61
61
|
assert_equal(MIDIMessage::PitchBend, message.class)
|
62
62
|
assert_equal(0, message.channel)
|
63
63
|
assert_equal(0x20, message.low)
|
64
|
-
assert_equal(0x00, message.high)
|
65
|
-
end
|
66
|
-
|
64
|
+
assert_equal(0x00, message.high)
|
65
|
+
end
|
66
|
+
|
67
67
|
def test_system_exclusive_command
|
68
68
|
lib = Nibbler::MIDIMessage
|
69
|
-
message = lib.system_exclusive(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
69
|
+
message = lib.system_exclusive(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
70
70
|
assert_equal(MIDIMessage::SystemExclusive::Command, message.class)
|
71
71
|
assert_equal([0xF0, [0x41, 0x10, 0x42], 0x12, [0x40, 0x00, 0x7F], [0x00], 0x41, 0xF7], message.to_a)
|
72
72
|
assert_equal([0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7], message.to_bytes)
|
73
73
|
assert_equal("F04110421240007F0041F7", message.to_hex_s)
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
def test_system_exclusive_request
|
77
77
|
lib = Nibbler::MIDIMessage
|
78
|
-
message = lib.system_exclusive(0xF0, 0x41, 0x10, 0x42, 0x11, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
78
|
+
message = lib.system_exclusive(0xF0, 0x41, 0x10, 0x42, 0x11, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
79
79
|
assert_equal(MIDIMessage::SystemExclusive::Request, message.class)
|
80
80
|
assert_equal([0xF0, [0x41, 0x10, 0x42], 0x11, [0x40, 0x00, 0x7F], [0x00, 0x00, 0x00], 0x41, 0xF7], message.to_a)
|
81
81
|
assert_equal([0xF0, 0x41, 0x10, 0x42, 0x11, 0x40, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x41, 0xF7], message.to_bytes)
|
82
82
|
assert_equal("F04110421140007F00000041F7", message.to_hex_s)
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
def test_system_exclusive_node
|
86
86
|
lib = Nibbler::MIDIMessage
|
87
87
|
message = lib.system_exclusive(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
88
|
-
node = message.node
|
88
|
+
node = message.node
|
89
89
|
assert_equal(MIDIMessage::SystemExclusive::Node, node.class)
|
90
90
|
assert_equal(0x41, node.manufacturer_id)
|
91
91
|
assert_equal(0x42, node.model_id)
|
92
|
-
assert_equal(0x10, node.device_id)
|
92
|
+
assert_equal(0x10, node.device_id)
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
def test_system_common_generic_3_bytes
|
96
96
|
lib = Nibbler::MIDIMessage
|
97
97
|
message = lib.system_common(0x1, 0x50, 0xA0)
|
98
98
|
assert_equal(MIDIMessage::SystemCommon, message.class)
|
99
99
|
assert_equal(1, message.status[1])
|
100
100
|
assert_equal(0x50, message.data[0])
|
101
|
-
assert_equal(0xA0, message.data[1])
|
102
|
-
end
|
101
|
+
assert_equal(0xA0, message.data[1])
|
102
|
+
end
|
103
103
|
|
104
104
|
def test_system_common_generic_2_bytes
|
105
105
|
nibbler = Nibbler.new
|
106
106
|
message = nibbler.parse(0xF1, 0x50)
|
107
107
|
assert_equal(MIDIMessage::SystemCommon, message.class)
|
108
108
|
assert_equal(1, message.status[1])
|
109
|
-
assert_equal(0x50, message.data[0])
|
110
|
-
end
|
109
|
+
assert_equal(0x50, message.data[0])
|
110
|
+
end
|
111
111
|
|
112
112
|
def test_system_common_generic_1_byte
|
113
113
|
nibbler = Nibbler.new
|
114
114
|
message = nibbler.parse(0xF1)
|
115
115
|
assert_equal(MIDIMessage::SystemCommon, message.class)
|
116
116
|
assert_equal(1, message.status[1])
|
117
|
-
end
|
118
|
-
|
117
|
+
end
|
118
|
+
|
119
119
|
def test_system_realtime
|
120
120
|
nibbler = Nibbler.new
|
121
121
|
message = nibbler.parse(0xF8)
|
122
122
|
assert_equal(MIDIMessage::SystemRealtime, message.class)
|
123
123
|
assert_equal(8, message.id)
|
124
|
-
end
|
125
|
-
|
124
|
+
end
|
125
|
+
|
126
126
|
end
|
data/test/midilib_test.rb
CHANGED
@@ -1,60 +1,60 @@
|
|
1
1
|
require "helper"
|
2
2
|
require "nibbler/midilib"
|
3
3
|
|
4
|
-
class Nibbler::MidilibTest < Test
|
5
|
-
|
4
|
+
class Nibbler::MidilibTest < Minitest::Test
|
5
|
+
|
6
6
|
def test_note_off
|
7
7
|
lib = Nibbler::Midilib
|
8
8
|
message = lib.note_off(0x0, 0x40, 0x40)
|
9
9
|
assert_equal(MIDI::NoteOff, message.class)
|
10
10
|
assert_equal(0, message.channel)
|
11
11
|
assert_equal(0x40, message.note)
|
12
|
-
assert_equal(0x40, message.velocity)
|
12
|
+
assert_equal(0x40, message.velocity)
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def test_note_on
|
16
16
|
lib = Nibbler::Midilib
|
17
17
|
message = lib.note_on(0x0, 0x40, 0x40)
|
18
18
|
assert_equal(MIDI::NoteOn, message.class)
|
19
19
|
assert_equal(0, message.channel)
|
20
20
|
assert_equal(0x40, message.note)
|
21
|
-
assert_equal(0x40, message.velocity)
|
22
|
-
end
|
23
|
-
|
21
|
+
assert_equal(0x40, message.velocity)
|
22
|
+
end
|
23
|
+
|
24
24
|
def test_polyphonic_aftertouch
|
25
25
|
lib = Nibbler::Midilib
|
26
26
|
message = lib.polyphonic_aftertouch(0x1, 0x40, 0x40)
|
27
27
|
assert_equal(MIDI::PolyPressure, message.class)
|
28
28
|
assert_equal(1, message.channel)
|
29
29
|
assert_equal(0x40, message.note)
|
30
|
-
assert_equal(0x40, message.pressure)
|
31
|
-
end
|
32
|
-
|
30
|
+
assert_equal(0x40, message.pressure)
|
31
|
+
end
|
32
|
+
|
33
33
|
def test_control_change
|
34
34
|
lib = Nibbler::Midilib
|
35
35
|
message = lib.control_change(0x2, 0x20, 0x20)
|
36
36
|
assert_equal(MIDI::Controller, message.class)
|
37
37
|
assert_equal(message.channel, 2)
|
38
38
|
assert_equal(0x20, message.controller)
|
39
|
-
assert_equal(0x20, message.value)
|
39
|
+
assert_equal(0x20, message.value)
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def test_program_change
|
43
43
|
lib = Nibbler::Midilib
|
44
44
|
message = lib.program_change(0x3, 0x40)
|
45
45
|
assert_equal(MIDI::ProgramChange, message.class)
|
46
46
|
assert_equal(3, message.channel)
|
47
|
-
assert_equal(0x40, message.program)
|
47
|
+
assert_equal(0x40, message.program)
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
def test_channel_aftertouch
|
51
51
|
lib = Nibbler::Midilib
|
52
52
|
message = lib.channel_aftertouch(0x3, 0x50)
|
53
53
|
assert_equal(MIDI::ChannelPressure, message.class)
|
54
54
|
assert_equal(3, message.channel)
|
55
|
-
assert_equal(0x50, message.pressure)
|
56
|
-
end
|
57
|
-
|
55
|
+
assert_equal(0x50, message.pressure)
|
56
|
+
end
|
57
|
+
|
58
58
|
def test_pitch_bend
|
59
59
|
# to-do handle the midilib lsb/msb
|
60
60
|
# right now the second data byte is being thrown away
|
@@ -62,70 +62,70 @@ class Nibbler::MidilibTest < Test::Unit::TestCase
|
|
62
62
|
message = lib.pitch_bend(0x0, 0x20, 0x00)
|
63
63
|
assert_equal(MIDI::PitchBend, message.class)
|
64
64
|
assert_equal(0, message.channel)
|
65
|
-
assert_equal(0x20, message.value)
|
65
|
+
assert_equal(0x20, message.value)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def test_system_exclusive
|
69
69
|
lib = Nibbler::Midilib
|
70
|
-
message = lib.system_exclusive(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
70
|
+
message = lib.system_exclusive(0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7)
|
71
71
|
assert_equal(MIDI::SystemExclusive, message.class)
|
72
72
|
assert_equal([0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7], message.data)
|
73
73
|
end
|
74
|
-
|
74
|
+
|
75
75
|
def test_song_pointer
|
76
76
|
lib = Nibbler::Midilib
|
77
77
|
message = lib.system_common(0x2, 0xF0)
|
78
78
|
assert_equal(MIDI::SongPointer, message.class)
|
79
79
|
assert_equal(0xF0, message.pointer)
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
def test_song_select
|
83
83
|
lib = Nibbler::Midilib
|
84
84
|
message = lib.system_common(0x3, 0xA0)
|
85
85
|
assert_equal(MIDI::SongSelect, message.class)
|
86
86
|
assert_equal(0xA0, message.song)
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
def test_tune_request
|
90
90
|
lib = Nibbler::Midilib
|
91
91
|
message = lib.system_common(0x6)
|
92
92
|
assert_equal(MIDI::TuneRequest, message.class)
|
93
93
|
end
|
94
|
-
|
94
|
+
|
95
95
|
def test_clock
|
96
96
|
lib = Nibbler::Midilib
|
97
97
|
message = lib.system_realtime(0x8)
|
98
98
|
assert_equal(MIDI::Clock, message.class)
|
99
|
-
end
|
99
|
+
end
|
100
100
|
|
101
101
|
def test_start
|
102
102
|
lib = Nibbler::Midilib
|
103
103
|
message = lib.system_realtime(0xA)
|
104
104
|
assert_equal(MIDI::Start, message.class)
|
105
|
-
end
|
106
|
-
|
105
|
+
end
|
106
|
+
|
107
107
|
def test_continue
|
108
108
|
lib = Nibbler::Midilib
|
109
109
|
message = lib.system_realtime(0xB)
|
110
110
|
assert_equal(MIDI::Continue, message.class)
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
def test_stop
|
114
114
|
lib = Nibbler::Midilib
|
115
115
|
message = lib.system_realtime(0xC)
|
116
116
|
assert_equal(MIDI::Stop, message.class)
|
117
|
-
end
|
118
|
-
|
117
|
+
end
|
118
|
+
|
119
119
|
def test_sense
|
120
120
|
lib = Nibbler::Midilib
|
121
121
|
message = lib.system_realtime(0xE)
|
122
122
|
assert_equal(MIDI::ActiveSense, message.class)
|
123
|
-
end
|
123
|
+
end
|
124
124
|
|
125
125
|
def test_reset
|
126
126
|
lib = Nibbler::Midilib
|
127
127
|
message = lib.system_realtime(0xF)
|
128
128
|
assert_equal(MIDI::SystemReset, message.class)
|
129
|
-
end
|
130
|
-
|
129
|
+
end
|
130
|
+
|
131
131
|
end
|
data/test/parser_buffer_test.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class Nibbler::BufferTest < Test
|
3
|
+
class Nibbler::BufferTest < Minitest::Test
|
4
4
|
|
5
5
|
def test_buffer_nibble_str
|
6
6
|
nibbler = Nibbler.new
|
7
7
|
nibbler.parse("9")
|
8
8
|
assert_equal(["9"], nibbler.buffer)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def test_buffer_single_byte
|
12
12
|
nibbler = Nibbler.new
|
13
13
|
nibbler.parse(0x90)
|
@@ -19,48 +19,48 @@ class Nibbler::BufferTest < Test::Unit::TestCase
|
|
19
19
|
nibbler.parse("90")
|
20
20
|
assert_equal(["9", "0"], nibbler.buffer)
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def test_buffer_single_byte_in_array
|
24
24
|
nibbler = Nibbler.new
|
25
25
|
nibbler.parse([0x90])
|
26
26
|
assert_equal(["9", "0"], nibbler.buffer)
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def test_buffer_two_bytes
|
30
30
|
nibbler = Nibbler.new
|
31
31
|
nibbler.parse(0x90, 0x40)
|
32
|
-
assert_equal(["9", "0", "4", "0"], nibbler.buffer)
|
32
|
+
assert_equal(["9", "0", "4", "0"], nibbler.buffer)
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_buffer_two_bytes_str
|
36
36
|
nibbler = Nibbler.new
|
37
37
|
nibbler.parse("90", "40")
|
38
|
-
assert_equal(["9", "0", "4", "0"], nibbler.buffer)
|
38
|
+
assert_equal(["9", "0", "4", "0"], nibbler.buffer)
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_buffer_two_bytes_single_str
|
42
42
|
nibbler = Nibbler.new
|
43
43
|
nibbler.parse("9040")
|
44
|
-
assert_equal(["9", "0", "4", "0"], nibbler.buffer)
|
44
|
+
assert_equal(["9", "0", "4", "0"], nibbler.buffer)
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def test_buffer_two_bytes_mixed
|
48
48
|
nibbler = Nibbler.new
|
49
49
|
nibbler.parse("90", 0x40)
|
50
|
-
assert_equal(["9", "0", "4", "0"], nibbler.buffer)
|
51
|
-
end
|
50
|
+
assert_equal(["9", "0", "4", "0"], nibbler.buffer)
|
51
|
+
end
|
52
52
|
|
53
53
|
def test_buffer_nibble_and_byte_mixed
|
54
54
|
nibbler = Nibbler.new
|
55
55
|
nibbler.parse("9", 0x40)
|
56
|
-
assert_equal(["9", "4", "0"], nibbler.buffer)
|
57
|
-
end
|
58
|
-
|
56
|
+
assert_equal(["9", "4", "0"], nibbler.buffer)
|
57
|
+
end
|
58
|
+
|
59
59
|
def test_buffer_stepped
|
60
60
|
nibbler = Nibbler.new
|
61
61
|
nibbler.parse("9")
|
62
62
|
nibbler.parse(0x40)
|
63
|
-
assert_equal(["9", "4", "0"], nibbler.buffer)
|
63
|
+
assert_equal(["9", "4", "0"], nibbler.buffer)
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class Nibbler::ParserRejectedTest < Test
|
4
|
-
|
3
|
+
class Nibbler::ParserRejectedTest < Minitest::Test
|
4
|
+
|
5
5
|
def test_leading_chars
|
6
6
|
nibbler = Nibbler.new
|
7
7
|
msg = nibbler.parse("0", "9", "04", "040")
|
8
|
-
assert_equal(::MIDIMessage::NoteOn, msg.class)
|
9
|
-
assert_equal(["0"], nibbler.rejected)
|
8
|
+
assert_equal(::MIDIMessage::NoteOn, msg.class)
|
9
|
+
assert_equal(["0"], nibbler.rejected)
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_2_leading_chars
|
@@ -14,21 +14,21 @@ class Nibbler::ParserRejectedTest < Test::Unit::TestCase
|
|
14
14
|
msg = nibbler.parse("1", "0", "9", "04", "040")
|
15
15
|
assert_equal(["1", "0"], nibbler.rejected)
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def test_leading_string
|
19
19
|
nibbler = Nibbler.new
|
20
20
|
msg = nibbler.parse("10", "9", "04", "040")
|
21
21
|
assert_equal(::MIDIMessage::NoteOn, msg.class)
|
22
22
|
assert_equal(["1", "0"], nibbler.rejected)
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def test_long_leading_string
|
26
26
|
nibbler = Nibbler.new
|
27
27
|
msg = nibbler.parse("000001000010", "9", "04", "040")
|
28
28
|
assert_equal(::MIDIMessage::NoteOn, msg.class)
|
29
29
|
assert_equal("000001000010".split(//), nibbler.rejected)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def test_long_leading_string_overlap
|
33
33
|
nibbler = Nibbler.new
|
34
34
|
msg = nibbler.parse("000001000010090", "4", "040")
|
@@ -49,12 +49,12 @@ class Nibbler::ParserRejectedTest < Test::Unit::TestCase
|
|
49
49
|
assert_equal(::MIDIMessage::NoteOn, msg.class)
|
50
50
|
assert_equal(["6", "0", "3", "0"], nibbler.rejected)
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def test_3_leading_numbers
|
54
54
|
nibbler = Nibbler.new
|
55
55
|
msg = nibbler.parse(0x00, 0x30, "9", "04", "040")
|
56
56
|
assert_equal(::MIDIMessage::NoteOn, msg.class)
|
57
57
|
assert_equal(["0", "0", "3", "0"], nibbler.rejected)
|
58
|
-
end
|
59
|
-
|
58
|
+
end
|
59
|
+
|
60
60
|
end
|
data/test/parser_test.rb
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class Nibbler::ParserTest < Test
|
4
|
-
|
3
|
+
class Nibbler::ParserTest < Minitest::Test
|
4
|
+
|
5
5
|
def test_lookahead
|
6
6
|
parser = Nibbler::Parser.new
|
7
7
|
num = 6
|
8
8
|
parser.instance_variable_set("@buffer", ["9", "0", "4", "0", "5", "0"])
|
9
|
-
parser.send(:populate_current)
|
9
|
+
parser.send(:populate_current)
|
10
10
|
output = parser.send(:lookahead, num) { |nibble_2, bytes| [nibble_2, bytes] }
|
11
11
|
assert_equal([0,[0x90, 0x40, 0x50]], output[:message])
|
12
|
-
assert_equal(["9", "0", "4", "0", "5", "0"], output[:processed])
|
12
|
+
assert_equal(["9", "0", "4", "0", "5", "0"], output[:processed])
|
13
13
|
assert_equal([], parser.instance_variable_get("@current"))
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def test_lookahead_trailing
|
17
17
|
parser = Nibbler::Parser.new
|
18
18
|
num = 6
|
@@ -20,86 +20,86 @@ class Nibbler::ParserTest < Test::Unit::TestCase
|
|
20
20
|
parser.send(:populate_current)
|
21
21
|
output = parser.send(:lookahead, num) { |nibble_2, bytes| [nibble_2, bytes] }
|
22
22
|
assert_equal([0,[0x90, 0x40, 0x50]], output[:message])
|
23
|
-
assert_equal(["9", "0", "4", "0", "5", "0"], output[:processed])
|
23
|
+
assert_equal(["9", "0", "4", "0", "5", "0"], output[:processed])
|
24
24
|
assert_equal(["5", "0"], parser.instance_variable_get("@current"))
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def test_lookahead_too_short
|
28
28
|
parser = Nibbler::Parser.new
|
29
29
|
num = 6
|
30
30
|
parser.instance_variable_set("@buffer", ["9", "0", "4"])
|
31
31
|
parser.send(:populate_current)
|
32
|
-
output = parser.send(:lookahead, num) do |nibble_2, bytes|
|
32
|
+
output = parser.send(:lookahead, num) do |nibble_2, bytes|
|
33
33
|
{
|
34
34
|
:message => nibble_2,
|
35
|
-
:processed => bytes
|
35
|
+
:processed => bytes
|
36
36
|
}
|
37
37
|
end
|
38
38
|
|
39
|
-
assert_nil output
|
39
|
+
assert_nil output
|
40
40
|
assert_equal(["9", "0", "4"], parser.instance_variable_get("@current"))
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def test_lookahead_sysex
|
44
44
|
parser = Nibbler::Parser.new
|
45
45
|
parser.instance_variable_set("@buffer", "F04110421240007F0041F750".split(//))
|
46
46
|
parser.send(:populate_current)
|
47
47
|
output = parser.send(:lookahead_sysex) { |b| b }
|
48
48
|
assert_equal([0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7], output[:message])
|
49
|
-
assert_equal("F04110421240007F0041F7".split(//), output[:processed])
|
49
|
+
assert_equal("F04110421240007F0041F7".split(//), output[:processed])
|
50
50
|
assert_equal(["5", "0"], parser.instance_variable_get("@current"))
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def test_lookahead_sysex_too_short
|
54
54
|
parser = Nibbler::Parser.new
|
55
55
|
parser.instance_variable_set("@buffer", ["9", "0", "4"])
|
56
56
|
parser.send(:populate_current)
|
57
57
|
output = parser.send(:lookahead_sysex) { |b| b }
|
58
|
-
|
59
|
-
assert_nil output
|
58
|
+
|
59
|
+
assert_nil output
|
60
60
|
assert_equal(["9", "0", "4"], parser.instance_variable_get("@current"))
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def test_process
|
64
64
|
parser = Nibbler::Parser.new
|
65
65
|
short = ["9", "0", "4", "0", "5", "0", "5", "0"]
|
66
66
|
output = parser.send(:process, short)
|
67
|
-
|
67
|
+
|
68
68
|
assert_equal(::MIDIMessage::NoteOn, output[:messages].first.class)
|
69
69
|
assert_equal(["5", "0"], parser.buffer)
|
70
70
|
assert_equal(["9", "0", "4", "0", "5", "0"], output[:processed])
|
71
71
|
end
|
72
|
-
|
72
|
+
|
73
73
|
def test_process_running_status
|
74
74
|
parser = Nibbler::Parser.new
|
75
75
|
two_msgs = ["9", "0", "4", "0", "5", "0", "4", "0", "6", "0"]
|
76
76
|
output = parser.send(:process, two_msgs)
|
77
|
-
|
78
|
-
|
77
|
+
|
78
|
+
refute_nil output
|
79
79
|
assert_equal(::MIDIMessage::NoteOn, output[:messages][0].class)
|
80
80
|
#assert_equal(::MIDIMessage::NoteOn, output[:messages][1].class)
|
81
81
|
assert_equal([], parser.buffer)
|
82
82
|
assert_equal(["9", "0", "4", "0", "5", "0", "4", "0", "6", "0"], output[:processed])
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
def test_process_multiple_overlapping_calls
|
86
86
|
parser = Nibbler::Parser.new
|
87
87
|
short = ["9", "0", "4", "0", "5", "0", "9", "0"]
|
88
88
|
short2 = ["3", "0", "2", "0", "1", "0"]
|
89
|
-
|
89
|
+
|
90
90
|
output = parser.send(:process, short)
|
91
91
|
|
92
|
-
|
92
|
+
refute_nil output
|
93
93
|
assert_equal(::MIDIMessage::NoteOn, output[:messages].first.class)
|
94
94
|
assert_equal(["9", "0"], parser.buffer)
|
95
95
|
assert_equal(["9", "0", "4", "0", "5", "0"], output[:processed])
|
96
|
-
|
96
|
+
|
97
97
|
output2 = parser.send(:process, short2)
|
98
98
|
|
99
|
-
|
99
|
+
refute_nil output2
|
100
100
|
assert_equal(::MIDIMessage::NoteOn, output2[:messages].first.class)
|
101
101
|
assert_equal(["1", "0"], parser.buffer)
|
102
|
-
assert_equal(["9", "0", "3", "0", "2", "0"], output2[:processed])
|
102
|
+
assert_equal(["9", "0", "3", "0", "2", "0"], output2[:processed])
|
103
103
|
end
|
104
104
|
|
105
105
|
def test_nibbles_to_message_leading
|
@@ -112,7 +112,7 @@ class Nibbler::ParserTest < Test::Unit::TestCase
|
|
112
112
|
assert_nil output
|
113
113
|
assert_equal(["5", "0", "9", "0", "4", "0", "5", "0"], parser.buffer)
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
def test_nibbles_to_message_trailing
|
117
117
|
parser = Nibbler::Parser.new
|
118
118
|
short = ["9", "0", "4", "0", "5", "0", "5", "0"]
|
@@ -120,12 +120,12 @@ class Nibbler::ParserTest < Test::Unit::TestCase
|
|
120
120
|
parser.send(:populate_current)
|
121
121
|
output = parser.send(:nibbles_to_message)
|
122
122
|
|
123
|
-
|
123
|
+
refute_nil output
|
124
124
|
assert_equal(::MIDIMessage::NoteOn, output[:message].class)
|
125
125
|
assert_equal(["5", "0"], parser.instance_variable_get("@current"))
|
126
126
|
assert_equal(["9", "0", "4", "0", "5", "0"], output[:processed])
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
def test_nibbles_to_message
|
130
130
|
parser = Nibbler::Parser.new
|
131
131
|
short = ["9", "0", "4", "0", "5", "0", "5", "0"]
|
@@ -133,12 +133,12 @@ class Nibbler::ParserTest < Test::Unit::TestCase
|
|
133
133
|
parser.send(:populate_current)
|
134
134
|
output = parser.send(:nibbles_to_message)
|
135
135
|
|
136
|
-
|
136
|
+
refute_nil output
|
137
137
|
assert_equal(::MIDIMessage::NoteOn, output[:message].class)
|
138
138
|
assert_equal(["5", "0"], parser.instance_variable_get("@current"))
|
139
139
|
assert_equal(["9", "0", "4", "0", "5", "0"], output[:processed])
|
140
140
|
end
|
141
|
-
|
141
|
+
|
142
142
|
def test_nibbles_to_message_running_status
|
143
143
|
parser = Nibbler::Parser.new
|
144
144
|
short = ["9", "0", "4", "0", "5", "0"]
|
@@ -146,19 +146,19 @@ class Nibbler::ParserTest < Test::Unit::TestCase
|
|
146
146
|
parser.send(:populate_current)
|
147
147
|
output = parser.send(:nibbles_to_message)
|
148
148
|
|
149
|
-
|
149
|
+
refute_nil output
|
150
150
|
assert_equal(::MIDIMessage::NoteOn, output[:message].class)
|
151
|
-
|
151
|
+
|
152
152
|
running_status = ["5", "0", "6", "0"]
|
153
153
|
parser.instance_variable_set("@buffer", running_status)
|
154
154
|
parser.send(:populate_current)
|
155
155
|
output = parser.send(:nibbles_to_message)
|
156
156
|
|
157
|
-
|
157
|
+
refute_nil output
|
158
158
|
assert_equal(::MIDIMessage::NoteOn, output[:message].class)
|
159
159
|
assert_equal(["5", "0", "6", "0"], output[:processed])
|
160
160
|
end
|
161
|
-
|
161
|
+
|
162
162
|
def test_nibbles_to_message_sysex
|
163
163
|
parser = Nibbler::Parser.new
|
164
164
|
sysex = "F04110421240007F0041F750".split(//)
|
@@ -166,23 +166,18 @@ class Nibbler::ParserTest < Test::Unit::TestCase
|
|
166
166
|
parser.send(:populate_current)
|
167
167
|
output = parser.send(:nibbles_to_message)
|
168
168
|
|
169
|
-
|
169
|
+
refute_nil output
|
170
170
|
assert_equal(::MIDIMessage::SystemExclusive::Command, output[:message].class)
|
171
171
|
assert_equal(["5", "0"], parser.instance_variable_get("@current"))
|
172
172
|
assert_equal("F04110421240007F0041F7".split(//), output[:processed])
|
173
|
-
end
|
174
|
-
|
173
|
+
end
|
174
|
+
|
175
175
|
def test_message_library
|
176
|
-
parser =
|
177
|
-
assert_nothing_raised Exception do
|
178
|
-
parser = Nibbler::Parser.new(:message_lib => :midilib)
|
179
|
-
end
|
176
|
+
parser = Nibbler::Parser.new(:message_lib => :midilib)
|
180
177
|
assert_equal Nibbler::Midilib, parser.instance_variable_get("@message")
|
181
178
|
|
182
|
-
|
183
|
-
parser = Nibbler::Parser.new
|
184
|
-
end
|
179
|
+
parser = Nibbler::Parser.new
|
185
180
|
assert_equal Nibbler::MIDIMessage, parser.instance_variable_get("@message")
|
186
181
|
end
|
187
|
-
|
182
|
+
|
188
183
|
end
|
data/test/session_test.rb
CHANGED
@@ -1,135 +1,135 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class Nibbler::SessionTest < Test
|
4
|
-
|
3
|
+
class Nibbler::SessionTest < Minitest::Test
|
4
|
+
|
5
5
|
def test_varying_length_strings
|
6
6
|
session = Nibbler::Session.new
|
7
7
|
message = session.parse("9", "04", "040")
|
8
8
|
|
9
|
-
|
9
|
+
refute_nil message
|
10
10
|
assert_equal(MIDIMessage::NoteOn, message.class)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def test_note_off
|
14
14
|
session = Nibbler::Session.new
|
15
15
|
message = session.parse(0x80, 0x40, 0x40)
|
16
16
|
|
17
|
-
|
17
|
+
refute_nil message
|
18
18
|
assert_equal(MIDIMessage::NoteOff, message.class)
|
19
19
|
assert_equal(0, message.channel)
|
20
20
|
assert_equal(0x40, message.note)
|
21
|
-
assert_equal(0x40, message.velocity)
|
21
|
+
assert_equal(0x40, message.velocity)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def test_note_on
|
25
25
|
session = Nibbler::Session.new
|
26
26
|
message = session.parse(0x90, 0x40, 0x40)
|
27
27
|
|
28
|
-
|
28
|
+
refute_nil message
|
29
29
|
assert_equal(MIDIMessage::NoteOn, message.class)
|
30
30
|
assert_equal(0, message.channel)
|
31
31
|
assert_equal(0x40, message.note)
|
32
|
-
assert_equal(0x40, message.velocity)
|
33
|
-
end
|
34
|
-
|
32
|
+
assert_equal(0x40, message.velocity)
|
33
|
+
end
|
34
|
+
|
35
35
|
def test_timestamp
|
36
36
|
session = Nibbler::Session.new
|
37
37
|
stamp = Time.now.to_i
|
38
38
|
report = session.parse(0x90, 0x40, 0x40, :timestamp => stamp)
|
39
39
|
message = report[:messages]
|
40
40
|
|
41
|
-
|
41
|
+
refute_nil message
|
42
42
|
assert_equal(MIDIMessage::NoteOn, message.class)
|
43
43
|
assert_equal(0, message.channel)
|
44
44
|
assert_equal(0x40, message.note)
|
45
45
|
assert_equal(0x40, message.velocity)
|
46
|
-
assert_equal(stamp, report[:timestamp])
|
46
|
+
assert_equal(stamp, report[:timestamp])
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def test_polyphonic_aftertouch
|
50
50
|
session = Nibbler::Session.new
|
51
51
|
message = session.parse(0xA1, 0x40, 0x40)
|
52
52
|
|
53
|
-
|
53
|
+
refute_nil message
|
54
54
|
assert_equal(MIDIMessage::PolyphonicAftertouch, message.class)
|
55
55
|
assert_equal(1, message.channel)
|
56
56
|
assert_equal(0x40, message.note)
|
57
|
-
assert_equal(0x40, message.value)
|
58
|
-
end
|
59
|
-
|
57
|
+
assert_equal(0x40, message.value)
|
58
|
+
end
|
59
|
+
|
60
60
|
def test_control_change
|
61
61
|
session = Nibbler::Session.new
|
62
62
|
message = session.parse(0xB2, 0x20, 0x20)
|
63
63
|
|
64
|
-
|
64
|
+
refute_nil message
|
65
65
|
assert_equal(MIDIMessage::ControlChange, message.class)
|
66
66
|
assert_equal(message.channel, 2)
|
67
67
|
assert_equal(0x20, message.index)
|
68
|
-
assert_equal(0x20, message.value)
|
68
|
+
assert_equal(0x20, message.value)
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def test_program_change
|
72
72
|
session = Nibbler::Session.new
|
73
73
|
message = session.parse(0xC3, 0x40)
|
74
74
|
|
75
|
-
|
75
|
+
refute_nil message
|
76
76
|
assert_equal(MIDIMessage::ProgramChange, message.class)
|
77
77
|
assert_equal(3, message.channel)
|
78
|
-
assert_equal(0x40, message.program)
|
78
|
+
assert_equal(0x40, message.program)
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
def test_channel_aftertouch
|
82
82
|
session = Nibbler::Session.new
|
83
83
|
message = session.parse(0xD3, 0x50)
|
84
84
|
|
85
|
-
|
85
|
+
refute_nil message
|
86
86
|
assert_equal(MIDIMessage::ChannelAftertouch, message.class)
|
87
87
|
assert_equal(3, message.channel)
|
88
|
-
assert_equal(0x50, message.value)
|
89
|
-
end
|
90
|
-
|
88
|
+
assert_equal(0x50, message.value)
|
89
|
+
end
|
90
|
+
|
91
91
|
def test_pitch_bend
|
92
92
|
session = Nibbler::Session.new
|
93
93
|
message = session.parse(0xE0, 0x20, 0x00) # center
|
94
94
|
|
95
|
-
|
95
|
+
refute_nil message
|
96
96
|
assert_equal(MIDIMessage::PitchBend, message.class)
|
97
97
|
assert_equal(0, message.channel)
|
98
98
|
assert_equal(0x20, message.low)
|
99
|
-
assert_equal(0x00, message.high)
|
100
|
-
end
|
101
|
-
|
99
|
+
assert_equal(0x00, message.high)
|
100
|
+
end
|
101
|
+
|
102
102
|
def test_system_common_generic_3_bytes
|
103
103
|
session = Nibbler::Session.new
|
104
104
|
message = session.parse(0xF1, 0x50, 0xA0)
|
105
105
|
|
106
|
-
|
106
|
+
refute_nil message
|
107
107
|
assert_equal(MIDIMessage::SystemCommon, message.class)
|
108
108
|
assert_equal(1, message.status[1])
|
109
109
|
assert_equal(0x50, message.data[0])
|
110
|
-
assert_equal(0xA0, message.data[1])
|
111
|
-
end
|
110
|
+
assert_equal(0xA0, message.data[1])
|
111
|
+
end
|
112
112
|
|
113
113
|
def test_system_common_generic_2_bytes
|
114
114
|
session = Nibbler::Session.new
|
115
115
|
message = session.parse(0xF1, 0x50)
|
116
116
|
assert_equal(MIDIMessage::SystemCommon, message.class)
|
117
117
|
assert_equal(1, message.status[1])
|
118
|
-
assert_equal(0x50, message.data[0])
|
119
|
-
end
|
118
|
+
assert_equal(0x50, message.data[0])
|
119
|
+
end
|
120
120
|
|
121
121
|
def test_system_common_generic_1_byte
|
122
122
|
session = Nibbler::Session.new
|
123
123
|
message = session.parse(0xF1)
|
124
124
|
assert_equal(MIDIMessage::SystemCommon, message.class)
|
125
125
|
assert_equal(1, message.status[1])
|
126
|
-
end
|
127
|
-
|
126
|
+
end
|
127
|
+
|
128
128
|
def test_system_realtime
|
129
129
|
session = Nibbler::Session.new
|
130
130
|
message = session.parse(0xF8)
|
131
131
|
assert_equal(MIDIMessage::SystemRealtime, message.class)
|
132
132
|
assert_equal(8, message.id)
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
end
|
@@ -1,29 +1,29 @@
|
|
1
1
|
require "helper"
|
2
2
|
|
3
|
-
class Nibbler::TypeConversionTest < Test
|
4
|
-
|
5
|
-
def test_hex_chars_to_numeric_bytes
|
3
|
+
class Nibbler::TypeConversionTest < Minitest::Test
|
4
|
+
|
5
|
+
def test_hex_chars_to_numeric_bytes
|
6
6
|
nibbles = ["4", "5", "9", "3"]
|
7
7
|
bytes = Nibbler::TypeConversion.hex_chars_to_numeric_bytes(nibbles)
|
8
|
-
|
8
|
+
|
9
9
|
assert_equal(["4", "5", "9", "3"], nibbles)
|
10
|
-
assert_equal([0x45, 0x93], bytes)
|
10
|
+
assert_equal([0x45, 0x93], bytes)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def test_hex_str_to_hex_chars
|
14
14
|
str = "904050"
|
15
15
|
nibbles = Nibbler::TypeConversion.send(:hex_str_to_hex_chars, str)
|
16
|
-
|
16
|
+
|
17
17
|
assert_equal("904050", str)
|
18
|
-
assert_equal(["9", "0", "4", "0", "5", "0"], nibbles)
|
18
|
+
assert_equal(["9", "0", "4", "0", "5", "0"], nibbles)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def test_numeric_byte_to_hex_chars
|
22
22
|
num = 0x90
|
23
23
|
nibbles = Nibbler::TypeConversion.send(:numeric_byte_to_hex_chars, num)
|
24
|
-
|
24
|
+
|
25
25
|
assert_equal(0x90, num)
|
26
|
-
assert_equal(["9", "0"], nibbles)
|
27
|
-
end
|
28
|
-
|
26
|
+
assert_equal(["9", "0"], nibbles)
|
27
|
+
end
|
28
|
+
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midi-nibbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ari Russo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: midi-message
|