Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
jazz-soft committed Mar 14, 2024
1 parent ff13952 commit a366648
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions javascript/JZZ.js
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,15 @@
var b = typeof lsb == 'undefined' ? '??' : __hex(lsb);
return 'NRPN ' + a + ' ' + b;
}
function _m2_str(a) {
var i;
var s = '';
for (i = 0; i < a.length; i++) {
if (!a[i]) break;
s += String.fromCharCode(a[i]);
}
return JZZ.lib.fromUTF8(s);
}
function _read_ctxt(msg) {
var mmm, kk, tt, st, n, a, s;
var gr = 'x';
Expand Down Expand Up @@ -2800,6 +2809,7 @@
if (!this._cc[kk]) this._cc[kk] = {};
a = msg.slice(4);
if (st == 0) {
msg.label(_m2_str(a));
this._cc[kk].tx = undefined;
}
else if (st == 1) {
Expand All @@ -2811,6 +2821,7 @@
else if (st == 3) {
if (this._cc[kk].tx) {
a = this._cc[kk].tx.concat(a);
msg.label(_m2_str(a));
this._cc[kk].tx = undefined;
}
}
Expand Down
9 changes: 9 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,15 @@ describe('JZZ.Context', function() {
ctxt._receive(msg);
assert.equal(msg.toString(), 'f0 7f 7f 04 7f 7f 7f f7');
});
it('text', function() {
var ctxt = JZZ.Context();
var msg = JZZ.MIDI2.umpText(1, 'π„ž');
ctxt._receive(msg[0]);
assert.equal(msg[0].toString(), 'd1100200 eda0b4ed b49e0000 00000000 -- Text (π„ž)');
msg = JZZ.MIDI2.umpCText(2, 3, 'π„ž');
ctxt._receive(msg[0]);
assert.equal(msg[0].toString(), 'd2030200 eda0b4ed b49e0000 00000000 -- Text (π„ž)');
});
it('noop', function() {
var ctxt = JZZ.Context();
var msg = JZZ.MIDI2.noop();
Expand Down

0 comments on commit a366648

Please sign in to comment.