Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added mocha tests

  • Loading branch information...
commit 6844d4f8537fb28c8f7e0260d9eaa69dc178a724 1 parent 64ef353
@tj authored
View
1  .gitignore
@@ -0,0 +1 @@
+node_modules
View
7 Makefile
@@ -0,0 +1,7 @@
+
+test:
+ @./node_modules/.bin/mocha \
+ --require should \
+ --reporter spec
+
+.PHONY: test
View
4 package.json
@@ -7,6 +7,10 @@
"main": "./lib/crc.js",
"scripts": {},
"directories" : {},
+ "devDependencies": {
+ "mocha": "*",
+ "should": "*"
+ },
"repository": {
"type": "git",
"url": "git://github.com/alexgorbatchev/node-crc.git"
View
9 test/crc.js
@@ -0,0 +1,9 @@
+#!/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);
+ })
+})
View
64 tests/crc_tests.js
@@ -1,64 +0,0 @@
-#!/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);
- }
-};
-
1  tests/nodeunit
@@ -1 +0,0 @@
-Subproject commit 8a31df2da23f57942a305ed9e2b92bf0db19d5f7
Please sign in to comment.
Something went wrong with that request. Please try again.