Passed
Branch master (9a7ed1)
by Rafael S.
01:20
created

test/to-bytes/40-bit.js   A

Complexity

Total Complexity 6
Complexity/F 1

Size

Lines of Code 28
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 28
rs 10
wmc 6
mnd 0
bc 6
fnc 6
bpm 1
cpm 1
noi 0
1
2
var assert = require('assert');
3
4
describe('40-bit to bytes', function() {
5
    
6
    let byteData = require('../../index.js');
7
8
    // 40 bit
9
    it('should turn 5 bytes (hex) to 1 signed 40-bit int  (max range)', function() {
10
        assert.deepEqual(byteData.toBytes([549755813887], 40, {"base": 16}),
11
            ["ff","ff","ff","ff","7f"]);
12
    });
13
    it('should turn 5 bytes (hex) to 1 signed 40-bit int  (949752813887)', function() {
14
        assert.deepEqual(byteData.toBytes([949752813887], 40, {"base": 16}),
15
            ["3f", "d9", "ad", "21", "dd"]);
16
    });  
17
    it('should turn 1 signed 40-bit int to 5 bytes (hex) (max range)', function() {
18
        assert.deepEqual(byteData.toBytes([-549755813888], 40, {"base": 16}),
19
            ["00","00","00","00","80"]);
20
    });
21
    it('should turn 1 unsigned 40-bit int to 5 bytes (hex) (max range)', function() {
22
        assert.deepEqual(byteData.toBytes([1099511627775], 40, {"base": 16}),
23
            ["ff","ff","ff","ff","ff"]);
24
    });
25
    it('should turn 1 unsigned 40-bit int to 5 bytes (max range)', function() {
26
        assert.deepEqual(byteData.toBytes([1099511627775], 40, {"base": 10}),
27
            [255,255,255,255,255]);
28
    });
29
});
30