forked from madrobby/bitarray.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
30 lines (27 loc) · 864 Bytes
/
test.js
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
var assert = require('better-assert');
var BitArray = require('./');
describe('a bit array of length 200', function () {
var ba = BitArray(200);
it('lets you set a value to 1', function () {
ba.set(100, 1);
assert(ba.get(100) === 1);
});
it('lets you set that value back to 0', function () {
ba.set(100, 0);
assert(ba.get(100) === 0);
});
});
describe('a bit array of length 20', function () {
it('lets you set lots of values independently', function () {
var ba = BitArray(20);
[1,3,5,9,11,13,15].forEach(function(i){ ba.set(i, 1) });
assert(ba.toString() === '01010100010101010000');
});
});
describe('a bit array with a default of 1', function () {
it('lets you set a bit to 0', function () {
var ba = BitArray(33,1);
ba.set(0, 0)
assert(ba.toString() == '011111111111111111111111111111111');
});
});