Skip to content

Commit eee4b87

Browse files
committed
Add tests
1 parent d1cce5e commit eee4b87

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

spec/session_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@
146146
end
147147
end
148148

149+
context 'when a sysex message' do
150+
let(:input) { [0xF0, 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7F, 0x00, 0x41, 0xF7, 0x50] }
151+
152+
it 'returns correct message' do
153+
expect(returned_messages.count).to eq(1)
154+
expect(returned_message).to_not be_nil
155+
expect(returned_message).to be_a(MIDIMessage::SystemExclusive)
156+
end
157+
end
158+
149159
context 'when a 3-byte system common message' do
150160
let(:input) { [0xF2, 0x50, 0x20] }
151161

spec/util_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,44 @@
33
require 'helper'
44

55
describe Nibbler::Util do
6+
describe '.status_bit' do
7+
let(:result) { Nibbler::Util.status_bit(input) }
8+
context 'when byte with first bit high' do
9+
let(:input) { 0x90 }
10+
11+
it 'returns 1' do
12+
expect(result).to eq(1)
13+
end
14+
end
15+
16+
context 'when byte with first bit low' do
17+
let(:input) { 0x40 }
18+
19+
it 'returns 0' do
20+
expect(result).to eq(0)
21+
end
22+
end
23+
end
24+
25+
describe '.status_byte?' do
26+
let(:result) { Nibbler::Util.status_byte?(input) }
27+
context 'when byte with first bit high' do
28+
let(:input) { 0x90 }
29+
30+
it 'returns true' do
31+
expect(result).to be(true)
32+
end
33+
end
34+
35+
context 'when byte with first bit low' do
36+
let(:input) { 0x40 }
37+
38+
it 'returns false' do
39+
expect(result).to be(false)
40+
end
41+
end
42+
end
43+
644
describe 'Conversion' do
745
describe '.strings_to_numeric_bytes' do
846
let(:output) { Nibbler::Util::Conversion.send(:strings_to_numeric_bytes, *input) }

0 commit comments

Comments
 (0)