forked from alexgorbatchev/crc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Gorbatchev
authored and
Alex Gorbatchev
committed
Dec 7, 2010
1 parent
64682c5
commit 45acafa
Showing
4 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
[submodule "tests/nodeunit"] | |||
path = tests/nodeunit | |||
url = git://github.com/caolan/nodeunit.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,64 @@ | |||
#!/usr/bin/env ./nodeunit/bin/nodeunit | |||
|
|||
var crc = require('../lib/crc'); | |||
|
|||
var fixture = { | |||
'crc8': [ | |||
['hello world', 64] | |||
], | |||
|
|||
'crc16': [ | |||
['hello world', 15332] | |||
], | |||
|
|||
'crc32': [ | |||
['hello world', 222957957] | |||
], | |||
|
|||
'crcArc': [ | |||
['hello world', 14785] | |||
], | |||
|
|||
'fcs16': [ | |||
['hello world', 44550] | |||
], | |||
|
|||
'hex8': [ | |||
[64, '40'] | |||
], | |||
|
|||
'hex16': [ | |||
[15332, '3BE4'] | |||
], | |||
|
|||
'hex32': [ | |||
[222957957, '0D4A1185'] | |||
] | |||
}; | |||
|
|||
var suite = module.exports['crc'] = {}; | |||
|
|||
for(var func in fixture) | |||
{ | |||
var list = fixture[func]; | |||
|
|||
for(var i = 0; i < list.length; i++) | |||
{ | |||
var input = list[i][0], | |||
output = list[i][1], | |||
name = [ func, input, output ].join(' - ') | |||
; | |||
|
|||
suite[name] = (function(func, input, output) | |||
{ | |||
|
|||
return function(assert) | |||
{ | |||
assert.deepEqual(crc[func](input), output); | |||
assert.done(); | |||
}; | |||
|
|||
})(func, input, output); | |||
} | |||
}; | |||
|
Submodule nodeunit
added at
8a31df