forked from birchroad/node-jspack
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbool.test.js
More file actions
35 lines (27 loc) · 1021 Bytes
/
bool.test.js
File metadata and controls
35 lines (27 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require('should');
var buffer = require('buffer');
var bufferpack = require('..');
describe('Boolean', function() {
var values = [true, false, 42];
var format = '<?(first)?(second)b(third)';
var packed = bufferpack.pack(format, values);
describe('#pack()', function() {
it('should have packed size of 3', function() {
packed.length.should.equal(3);
});
it('should pack fine', function() {
(!!packed[0]).should.equal(values[0]);
(!!packed[1]).should.equal(values[1]);
packed[2].should.equal(values[2]);
});
});
describe('#unpack()', function() {
var unpacked = bufferpack.unpack(format, packed);
it('should return an object with correct values', function() {
unpacked.should.be.an.instanceOf(Object);
unpacked.first.should.equal(values[0]);
unpacked.second.should.equal(values[1]);
unpacked.third.should.equal(values[2]);
});
});
});