Skip to content

Commit 9c42919

Browse files
committed
Adds tests for writing time tags.
1 parent e20ac34 commit 9c42919

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

tests/js/osc-tests.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
(function () {
22

3+
"use strict";
4+
35
QUnit.module("OSC Reader");
46

57
/*************
@@ -372,8 +374,8 @@
372374
* Time Tags *
373375
*************/
374376

375-
var testTimeTag = function (testSpec) {
376-
test("Time tag " + testSpec.name, function () {
377+
var testReadTimeTag = function (testSpec) {
378+
test("Read time tag " + testSpec.name, function () {
377379
var expected = testSpec.timeTag,
378380
dv = new DataView(testSpec.timeTagBytes.buffer);
379381

@@ -385,9 +387,18 @@
385387
});
386388
};
387389

390+
var testWriteTimeTag = function (testSpec) {
391+
test("Write time tag " + testSpec.name, function () {
392+
var expected = testSpec.timeTagBytes,
393+
actual = osc.writeTimeTag(testSpec.timeTag);
394+
395+
arrayEqual(actual, expected, "The raw time tag should have have been written correctly.");
396+
});
397+
}
398+
388399
var timeTagTestSpecs = [
389400
{
390-
name: "Seconds-only time tag",
401+
name: "with seconds only",
391402
// May 4, 2014 at 0:00:00 UTC.
392403
timeTagBytes: new Uint8Array([
393404
215, 15, 243, 112,
@@ -416,7 +427,8 @@
416427
var timeTagTests = function (testSpecs) {
417428
for (var i = 0; i < testSpecs.length; i++) {
418429
var testSpec = testSpecs[i];
419-
testTimeTag(testSpec);
430+
testReadTimeTag(testSpec);
431+
testWriteTimeTag(testSpec)
420432
}
421433
};
422434

0 commit comments

Comments
 (0)