-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Midi1SysExChunkProcessor: Make sure to reset pending inputs.
This should fix #81 (comment)
- Loading branch information
1 parent
157f9be
commit 41e2eb6
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
ktmidi/src/commonTest/kotlin/dev/atsushieno/ktmidi/Midi1SysExChunkProcessorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.atsushieno.ktmidi | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertContentEquals | ||
import kotlin.test.assertFalse | ||
|
||
class Midi1SysExChunkProcessorTest { | ||
@Test | ||
fun process1() { | ||
val processor = Midi1SysExChunkProcessor() | ||
(1..3).forEach { | ||
val sysex = listOf(0xF0, | ||
// invalidate MUID example | ||
0x7E, 0x7F, 0x0D, 0x7E, 1, | ||
0x10, 0x10, 0x10, 0x10, 0x7F, 0x7F, 0x7F, 0x7F, 0x20, 0x20, 0x20, 0x20, | ||
0xF7).map { it.toByte() } | ||
val seq1 = processor.process(sysex.take(10)).flatMap { it } | ||
// The inputs are still stored. | ||
assertFalse(seq1.iterator().hasNext(), "round $it: #1") | ||
val seq2 = processor.process(sysex.drop(10)).flatMap { it } | ||
// the pending inputs are flushed now (and should not remain: https://github.com/atsushieno/ktmidi/issues/81#issuecomment-2253261161) | ||
assertContentEquals(sysex, seq2.toList(), "round $it: #2") | ||
} | ||
} | ||
} |