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

test/to-bytes/crumbs.js   A

Complexity

Total Complexity 18
Complexity/F 1

Size

Lines of Code 78
Function Count 18

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 78
rs 10
wmc 18
mnd 0
bc 18
fnc 18
bpm 1
cpm 1
noi 0
1
2
var assert = require('assert');
3
4
describe('crumbs to bytes', function() {   
5
    let byteData = require('../../index.js');
6
7
    // 2-bit
8
    it('should turn 2 2-bit unsigned int to 2 crumb (0s)', function() {
9
        assert.deepEqual(byteData.toBytes([0], 2),
10
            [0]);
11
    });
12
    it('should turn 2 2-bit unsigned int to 2 crumb (0s)', function() {
13
        assert.deepEqual(byteData.toBytes([1], 2, {"base": 10}),
14
            [1]);
15
    });
16
    it('should turn 2 2-bit unsigned int to 2 crumb (0s)', function() {
17
        assert.deepEqual(byteData.toBytes([2], 2, {"base": 10}),
18
            [2]);
19
    });
20
    it('should turn 2 2-bit unsigned int to 2 crumb (0s)', function() {
21
        assert.deepEqual(byteData.toBytes([3], 2, {"base": 10}),
22
            [3]);
23
    });
24
25
    it('should turn 2 2-bit unsigned int to 2 crumb (0s)', function() {
26
        assert.deepEqual(byteData.toBytes([0], 2, {"base": 2}),
27
            ['00']);
28
    });
29
    it('should turn 2 2-bit unsigned int to 2 crumb (0s)', function() {
30
        assert.deepEqual(byteData.toBytes([1], 2, {"base": 2}),
31
            ['01']);
32
    });
33
    it('should turn 2 2-bit unsigned int to 2 crumb (0s)', function() {
34
        assert.deepEqual(byteData.toBytes([2], 2, {"base": 2}),
35
            ['10']);
36
    });
37
    it('should turn 2 2-bit unsigned int to 2 crumb (0s)', function() {
38
        assert.deepEqual(byteData.toBytes([3], 2, {"base": 2}),
39
            ['11']);
40
    });
41
42
    it('should turn 2 2-bit signed int to 2 crumb (0s)', function() {
43
        assert.deepEqual(byteData.toBytes([-2], 2, {"base": 2}),
44
            ['10']);
45
    });
46
    it('should turn 2 2-bit signed int to 2 crumb (0s)', function() {
47
        assert.deepEqual(byteData.toBytes([-1], 2, {"base": 2}),
48
            ['11']);
49
    });
50
    it('should turn 2 2-bit signed int to 2 crumb (0s)', function() {
51
        assert.deepEqual(byteData.toBytes([0], 2, {"base": 2}),
52
            ['00']);
53
    });
54
    it('should turn 2 2-bit signed int to 2 crumb (0s)', function() {
55
        assert.deepEqual(byteData.toBytes([1], 2, {"base": 2}),
56
            ['01']);
57
    });
58
59
    it('should turn 2 2-bit signed int to 2 bytes (-2)', function() {
60
        assert.deepEqual(byteData.toBytes([-2], 2, {"base": 10}),
61
            [2]);
62
    });
63
    it('should turn 1 2-bit signed int to 1 crumb (-1)', function() {
64
        assert.deepEqual(byteData.toBytes([-1], 2, {"base": 10}),
65
            [3]);
66
    });
67
    it('should turn 1 2-bit signed int to 1 crumb hex (-1)', function() {
68
        assert.deepEqual(byteData.toBytes([-1], 2, {"base": 16}),
69
            ['03']);
70
    });
71
    it('should turn 1 2-bit unsigned int to 1 crumb hex (2)', function() {
72
        assert.deepEqual(byteData.toBytes([2], 2, {"base": 16}),
73
            ['02']);
74
    });
75
    it('should turn 1 2-bit unsigned int to 1 crumb bin (1)', function() {
76
        assert.deepEqual(byteData.toBytes([1], 2, {"base": 2}),
77
            ['01']);
78
    });
79
});
80