Sha256: 33d26180011f77adbb6f57e823a4e81108abf6b1dd585b4c8958040054fa8d42

Contents?: true

Size: 1.13 KB

Versions: 69

Compression:

Stored size: 1.13 KB

Contents

var binary = require('../');
var test = require('tap').test;

test('bu', function (t) {
    t.plan(8);
    
    // note: can't store -12667700813876161 exactly in an ieee float
    
    var buf = new Buffer([
        44, // a == 44
        2, 43, // b == 555
        164, 213, 37, 37, // c == 2765432101
        29, 81, 180, 20, 155, 115, 203, 193, // d == 2112667700813876161
    ]);
    
    binary.parse(buf)
        .word8bu('a')
        .word16bu('b')
        .word32bu('c')
        .word64bu('d')
        .tap(function (vars) {
            t.same(vars.a, 44);
            t.same(vars.b, 555);
            t.same(vars.c, 2765432101);
            t.ok(
                Math.abs(vars.d - 2112667700813876161) < 1500
            );
        })
    ;
    
    // also check aliases here:
    binary.parse(buf)
        .word8be('a')
        .word16be('b')
        .word32be('c')
        .word64be('d')
        .tap(function (vars) {
            t.same(vars.a, 44);
            t.same(vars.b, 555);
            t.same(vars.c, 2765432101);
            t.ok(
                Math.abs(vars.d - 2112667700813876161) < 1500
            );
        })
    ;
});

Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/decompress-zip/node_modules/binary/test/bu.js