Skip to content

Commit

Permalink
fix tab spaces and alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
adrums86 committed Jan 24, 2023
1 parent 92a9243 commit 8bfc3ce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions lib/utils/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ var uint8ToCString = function(data) {
// Add nullChar
retString += curChar;
return retString;
};
};

module.exports = { uint8ToCString };
module.exports = { uint8ToCString };
46 changes: 23 additions & 23 deletions test/mp4-emsg.test.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
'use strict';

var QUnit = require('qunit'),
emsg = require('../lib/mp4/emsg'),
generateEmsgBoxData = require('./utils/mp4-helpers').generateEmsgBoxData,
messageData = new Uint8Array([0x64, 0x61, 0x74, 0x61]); // data;
emsg = require('../lib/mp4/emsg'),
generateEmsgBoxData = require('./utils/mp4-helpers').generateEmsgBoxData,
messageData = new Uint8Array([0x64, 0x61, 0x74, 0x61]); // data;

QUnit.module('EMSG Parsing');

QUnit.test('Can parse a v0 emsg box', function(assert) {
var boxData = generateEmsgBoxData(0, messageData);
var parsedBox = emsg.parseEmsgBox(boxData);
var boxData = generateEmsgBoxData(0, messageData);
var parsedBox = emsg.parseEmsgBox(boxData);

assert.equal(parsedBox.scheme_id_uri, 'urn:foo:bar:2023\0', 'v0 box has expected scheme_id_uri');
assert.equal(parsedBox.value, 'foo.bar.value\0', 'v0 box has expected value');
assert.equal(parsedBox.timescale, 100, 'v0 box has expected timescale');
assert.equal(parsedBox.presentation_time, undefined, 'v0 box has expected presentation_time');
assert.equal(parsedBox.presentation_time_delta, 1000, 'v0 box has expected presentation_time_delta');
assert.equal(parsedBox.event_duration, 0, 'v0 box has expected event_duration');
assert.equal(parsedBox.id, 1, 'v0 box has expected id');
assert.deepEqual(parsedBox.message_data, messageData, 'v0 box has expected data');
assert.equal(parsedBox.scheme_id_uri, 'urn:foo:bar:2023\0', 'v0 box has expected scheme_id_uri');
assert.equal(parsedBox.value, 'foo.bar.value\0', 'v0 box has expected value');
assert.equal(parsedBox.timescale, 100, 'v0 box has expected timescale');
assert.equal(parsedBox.presentation_time, undefined, 'v0 box has expected presentation_time');
assert.equal(parsedBox.presentation_time_delta, 1000, 'v0 box has expected presentation_time_delta');
assert.equal(parsedBox.event_duration, 0, 'v0 box has expected event_duration');
assert.equal(parsedBox.id, 1, 'v0 box has expected id');
assert.deepEqual(parsedBox.message_data, messageData, 'v0 box has expected data');

});

QUnit.test('Can parse a v1 emsg box', function(assert) {
var boxData = generateEmsgBoxData(1, messageData);
var parsedBox = emsg.parseEmsgBox(boxData);
var boxData = generateEmsgBoxData(1, messageData);
var parsedBox = emsg.parseEmsgBox(boxData);

assert.equal(parsedBox.scheme_id_uri, 'urn:foo:bar:2023\0', 'v1 box has expected scheme_id_uri');
assert.equal(parsedBox.value, 'foo.bar.value\0', 'v1 box has expected value');
assert.equal(parsedBox.timescale, 100, 'v1 box has expected timescale');
assert.equal(parsedBox.presentation_time, 10000, 'v1 box has expected presentation_time');
assert.equal(parsedBox.presentation_time_delta, undefined, 'v1 box has expected presentation_time_delta');
assert.equal(parsedBox.event_duration, 1, 'v1 box has expected event_duration');
assert.equal(parsedBox.id, 2, 'v1 box has expected id');
assert.deepEqual(parsedBox.message_data, messageData, 'v1 box has expected data');
assert.equal(parsedBox.scheme_id_uri, 'urn:foo:bar:2023\0', 'v1 box has expected scheme_id_uri');
assert.equal(parsedBox.value, 'foo.bar.value\0', 'v1 box has expected value');
assert.equal(parsedBox.timescale, 100, 'v1 box has expected timescale');
assert.equal(parsedBox.presentation_time, 10000, 'v1 box has expected presentation_time');
assert.equal(parsedBox.presentation_time_delta, undefined, 'v1 box has expected presentation_time_delta');
assert.equal(parsedBox.event_duration, 1, 'v1 box has expected event_duration');
assert.equal(parsedBox.id, 2, 'v1 box has expected id');
assert.deepEqual(parsedBox.message_data, messageData, 'v1 box has expected data');
});
16 changes: 8 additions & 8 deletions test/utils.string.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ var
QUnit.module('String Utils');

QUnit.test('Converts a uint8 array into a C string from start of array until first null char', function(assert) {
var uint8String = new Uint8Array([0x66, 0x6F, 0x6F, 0x2E, 0x62, 0x61, 0x72, 0x2E, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00,
0x76, 0x61, 0x6C, 0x75, 0x65, 0x2E, 0x62, 0x61, 0x72, 0x00]); // foo.bar.value\0value.bar\0
var firstString = string.uint8ToCString(uint8String);
assert.equal(firstString, 'foo.bar.value\0', 'converts uint8 data to a c string');
assert.equal(firstString.length, 14, 'string has the correct length');
var secondString = string.uint8ToCString(uint8String.subarray(14));
assert.equal(secondString, 'value.bar\0', 'converts uint8 data to a c string');
assert.equal(secondString.length, 10, 'string has the correct length');
var uint8String = new Uint8Array([0x66, 0x6F, 0x6F, 0x2E, 0x62, 0x61, 0x72, 0x2E, 0x76, 0x61, 0x6C, 0x75, 0x65, 0x00,
0x76, 0x61, 0x6C, 0x75, 0x65, 0x2E, 0x62, 0x61, 0x72, 0x00]); // foo.bar.value\0value.bar\0
var firstString = string.uint8ToCString(uint8String);
assert.equal(firstString, 'foo.bar.value\0', 'converts uint8 data to a c string');
assert.equal(firstString.length, 14, 'string has the correct length');
var secondString = string.uint8ToCString(uint8String.subarray(14));
assert.equal(secondString, 'value.bar\0', 'converts uint8 data to a c string');
assert.equal(secondString.length, 10, 'string has the correct length');
});

0 comments on commit 8bfc3ce

Please sign in to comment.