First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
32
node_modules/mux.js/test/utils.bin.test.js
generated
vendored
Normal file
32
node_modules/mux.js/test/utils.bin.test.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
var
|
||||
QUnit = require('qunit'),
|
||||
toUnsigned = require('../lib/utils/bin').toUnsigned;
|
||||
|
||||
QUnit.module('Binary Utils');
|
||||
|
||||
QUnit.test('converts values to unsigned integers after bitwise operations', function(assert) {
|
||||
var bytes;
|
||||
|
||||
bytes = [0, 0, 124, 129];
|
||||
|
||||
assert.equal(toUnsigned(bytes[0] << 24 |
|
||||
bytes[1] << 16 |
|
||||
bytes[2] << 8 |
|
||||
bytes[3]),
|
||||
31873, 'positive signed result stays positive');
|
||||
|
||||
bytes = [150, 234, 221, 192];
|
||||
|
||||
// sanity check
|
||||
assert.equal(bytes[0] << 24 |
|
||||
bytes[1] << 16 |
|
||||
bytes[2] << 8 |
|
||||
bytes[3],
|
||||
-1762992704, 'bitwise operation produces negative signed result');
|
||||
|
||||
assert.equal(toUnsigned(bytes[0] << 24 |
|
||||
bytes[1] << 16 |
|
||||
bytes[2] << 8 |
|
||||
bytes[3]),
|
||||
2531974592, 'negative signed result becomes unsigned positive');
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue