crc.js
1.47 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env ./nodeunit/bin/nodeunit
var crc = require('../lib/crc');
describe('crc8()', function(){
it('should work with strings', function(){
crc.crc8('hello world').should.equal(64);
})
it('should work with Buffers', function(){
crc.buffer.crc8(new Buffer('hello world')).should.equal(64);
})
})
describe('crc16()', function(){
it('should work with strings', function(){
crc.crc16('hello world').should.equal(15332);
})
it('should work with Buffers', function(){
crc.buffer.crc16(new Buffer('hello world')).should.equal(15332);
})
})
describe('crc32()', function(){
it('should work with strings', function(){
crc.crc32('hello world').should.equal(222957957);
})
it('should work with Buffers', function(){
crc.buffer.crc32(new Buffer('hello world')).should.equal(222957957);
})
})
describe('crcArc()', function(){
it('should work with strings', function(){
crc.crcArc('hello world').should.equal(14785);
})
})
describe('fcs16()', function(){
it('should work with strings', function(){
crc.fcs16('hello world').should.equal(44550);
})
})
describe('hex8()', function(){
it('should work with strings', function(){
crc.hex8(64).should.equal('40');
})
})
describe('hex16()', function(){
it('should work with strings', function(){
crc.hex16(15332).should.equal('3BE4');
})
})
describe('hex32()', function(){
it('should work with strings', function(){
crc.hex32(222957957).should.equal('0D4A1185');
})
})