* Add bower package.

* Fixed JSHint warnings.
* Add travis.
* Add coveralls.
This commit is contained in:
Chen Yi-Cyuan
2015-01-07 22:36:41 +08:00
parent 7a5649ff78
commit 629a972486
13 changed files with 188 additions and 102 deletions
-12
View File
@@ -1,12 +0,0 @@
(function(root) {
var assert = function (title, expect, actual) {
if(expect == actual)
console.log(title + ': true');
else
console.log(title + ': false', 'Except:' + expect, 'Actual: ' + actual);
};
if(typeof(module) != 'undefined')
global.assert = assert;
else if(root)
root.assert = assert;
})(this);
+12 -2
View File
@@ -3,10 +3,20 @@
<head>
<meta charset="UTF-8">
<title>MD2</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect.js/0.2.0/expect.min.js"></script>
<script src="../src/md2.js"></script>
<script src="debug.js"></script>
<script src="test.js"></script>
</head>
<body>
<div id="mocha"></div>
<script>
mocha.setup('bdd');
</script>
<script src="test.js"></script>
<script>
mocha.checkLeaks();
mocha.run();
</script>
</body>
</html>
+1 -1
View File
@@ -1,3 +1,3 @@
md2 = require('../src/md2.js');
require('./debug.js');
expect = require('expect.js');
require('./test.js');
+30 -5
View File
@@ -1,5 +1,30 @@
assert('md2 1', '8350e5a3e24c153df2275c9f80692773', md2(''));
assert('md2 2', '03d85a0d629d2c442e987525319fc471', md2('The quick brown fox jumps over the lazy dog'));
assert('md2 3', '71eaa7e440b611e41a6f0d97384b342a', md2('The quick brown fox jumps over the lazy dog.'));
assert('md2 4', '7af93c270b0ec392ca2f0d90a927cf8a', md2('中文'));
assert('md2 5', '628657f2dbd637b6b13500e8567a1c83', md2('aécio'));
describe('ascii', function() {
describe('less than 64 bytes', function() {
it('should be successful', function() {
expect(md2('')).to.be('8350e5a3e24c153df2275c9f80692773');
expect(md2('The quick brown fox jumps over the lazy dog')).to.be('03d85a0d629d2c442e987525319fc471');
expect(md2('The quick brown fox jumps over the lazy dog.')).to.be('71eaa7e440b611e41a6f0d97384b342a');
});
});
describe('more than 64 bytes', function() {
it('should be successful', function() {
expect(md2('The MD5 message-digest algorithm is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, typically expressed in text format as a 32 digit hexadecimal number. MD5 has been utilized in a wide variety of cryptographic applications, and is also commonly used to verify data integrity.')).to.be('3658f72434eecc8bdb99047f9710c263');
});
});
});
describe('UTF8', function() {
describe('less than 64 bytes', function() {
it('should be successful', function() {
expect(md2('中文')).to.be('7af93c270b0ec392ca2f0d90a927cf8a');
expect(md2('aécio')).to.be('628657f2dbd637b6b13500e8567a1c83');
});
});
describe('more than 64 bytes', function() {
it('should be successful', function() {
expect(md2('訊息摘要演算法第五版(英語:Message-Digest Algorithm 5,縮寫為MD5),是當前電腦領域用於確保資訊傳輸完整一致而廣泛使用的雜湊演算法之一(又譯雜湊演算法、摘要演算法等),主流程式語言普遍已有MD5的實作。')).to.be('4a0cf02bb374a56e9a9a17e426dee995');
});
});
});