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

test/to-bytes/nibbles.js   A

Complexity

Total Complexity 9
Complexity/F 1

Size

Lines of Code 40
Function Count 9

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 40
rs 10
wmc 9
mnd 0
bc 9
fnc 9
bpm 1
cpm 1
noi 0
1
2
var assert = require('assert');
3
4
describe('nibbles to bytes', function() {
5
    
6
    let byteData = require('../../index.js');
7
8
    // 4-bit / half byte byte signed
9
    it('should turn 2 4-bit signed int to 2 nibbles (0s)', function() {
10
        assert.deepEqual(byteData.toBytes([0, 0], 4, {"base": 10}),
11
            [0, 0]);
12
    });
13
    it('should turn 2 4-bit signed int to 2 bytes (-8, 7)', function() {
14
        assert.deepEqual(byteData.toBytes([-8, 7], 4, {"base": 10}),
15
            [8, 7]);
16
    });
17
    it('should turn 1 4-bit signed int to 1 nibble (-1)', function() {
18
        assert.deepEqual(byteData.toBytes([-1], 4, {"base": 10}),
19
            [15]);
20
    });
21
    it('should turn 1 4-bit signed int to 1 nibble (-1, 5)', function() {
22
        assert.deepEqual(byteData.toBytes([-1, 5], 4, {"base": 10}),
23
            [15, 5]);
24
    });
25
    it('should turn 1 4-bit signed int to 1 nibble hex (-1)', function() {
26
        assert.deepEqual(byteData.toBytes([-1], 4, {"base": 16}),
27
            ['f']);
28
    });
29
    it('should turn 1 4-bit signed int to 1 nibble hex (-8)', function() {
30
        assert.deepEqual(byteData.toBytes([-8], 4, {"base": 16}),
31
            ['8']);
32
    });
33
    it('should turn 1 4-bit signed int to 1 nibble hex (7)', function() {
34
        assert.deepEqual(byteData.toBytes([7], 4, {"base": 16}),
35
            ['7']);
36
    });
37
    it('should turn 1 4-bit signed int to 1 nibble bin (6)', function() {
38
        assert.deepEqual(byteData.toBytes([6], 4, {"base": 2}),
39
            ['0110']);
40
    });
41
});
42