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

test/from-bytes/8-bit.js   A

Complexity

Total Complexity 7
Complexity/F 1

Size

Lines of Code 38
Function Count 7

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 38
rs 10
wmc 7
mnd 0
bc 7
fnc 7
bpm 1
cpm 1
noi 0
1
2
var assert = require('assert');
3
4
describe('8-bit from bytes', function() {
5
    
6
    let byteData = require('../../index.js');
7
8
    it('should turn 1 byte to a 8-bit uInt', function() {
9
        assert.deepEqual(byteData.fromBytes(
10
            [0,0], 8),
11
            [0,0]);
12
    });
13
14
    it('should turn 1 hex byte to a 8-bit uInt (max range)', function() {
15
        assert.deepEqual(byteData.fromBytes(
16
            ["0","ff"], 8, {"base": 16}),
17
            [0, 255]);
18
    });
19
    it('should turn 1 hex byte to a 8-bit int (max range)', function() {
20
        assert.deepEqual(byteData.fromBytes(
21
            ["ff","7f"], 8, {"base": 16, "signed": true}),
22
            [-1, 127]);
23
    });
24
    it('should turn 1 hex byte to a 8-bit int (max range)', function() {
25
        assert.deepEqual(byteData.fromBytes(
26
            ["80","7f"], 8, {"base": 16, "signed": true}),
27
            [-128, 127]);
28
    });
29
    it('should turn 1 bin byte to a 8-bit uInt (max range)', function() {
30
        assert.deepEqual(byteData.fromBytes(
31
            ["00000000","11111111"], 8, {"base": 2, "signed": false}),
32
            [0, 255]);
33
    });
34
    it('should turn 1 bin byte to a 8-bit int (max range)', function() {
35
        assert.deepEqual(byteData.fromBytes(
36
            ["10000000","01111111"], 8, {"base": 2, "signed": true}),
37
            [-128, 127]);
38
    });
39
});
40