* Split core lib into multiple files * Refactor data encoding methods * Refactor data masking process * Improve qr code generation process * Increase minimum required node version to 0.10 * Add linter * Add tests and tests coverage * Update travis config to fix compilation issues * Add examples folder * Add missing license tag in package.json * Update build script and add sourcemap support * Publish only strictly needed files on npm * Update readme
24 lines
720 B
JavaScript
24 lines
720 B
JavaScript
var test = require('tap').test
|
|
var BitMatrix = require('core/bit-matrix')
|
|
|
|
test('Bit Matrix', function (t) {
|
|
t.throw(function () { BitMatrix(0) }, 'Should throw if size is 0')
|
|
t.throw(function () { BitMatrix(-1) }, 'Should throw if size less than 0')
|
|
|
|
var bm = new BitMatrix(2)
|
|
|
|
t.equal(bm.size, 2, 'Should have correct size')
|
|
t.equal(bm.data.length, 4, 'Should correctly set buffer size')
|
|
|
|
bm.set(0, 1, true, true)
|
|
t.ok(bm.get(0, 1), 'Should correctly set bit to true')
|
|
t.ok(bm.isReserved(0, 1), 'Should correctly set bit as reserved')
|
|
|
|
bm.xor(0, 1, 1)
|
|
t.ok(!bm.get(0, 1), 'Should correctly xor bit')
|
|
|
|
bm.set(0, 1, false)
|
|
t.notOk(bm.get(0, 1), 'Should correctly set bit to false')
|
|
|
|
t.end()
|
|
})
|