long string test (100% coverage)

This commit is contained in:
SheetJS 2014-06-20 22:25:47 -04:00
parent 1a8f8f3626
commit f9733b16be
4 changed files with 8 additions and 4 deletions

View File

@ -1,9 +1,11 @@
var m = "foobar"; for(var i = 0; i != 11; ++i) m+=m;
var bits = [
[ "foobar", -1628037227, 1 ],
[ "foo bar baz", -228401567, 1 ],
[ "foo bar baz٪", 984445192 ],
[ "foo bar baz٪☃", 140429620],
[ "foo bar baz٪☃🍣", 1531648243]
[ "foo bar baz٪☃🍣", 1531648243],
[ m, 40270464, 1 ]
];
if(typeof module !== "undefined") module.exports = bits;
/* vim: set ts=2: */

View File

@ -22,7 +22,7 @@ describe('crc32 bits', function() {
bits.forEach(function(i) {
var l = i[0].length;
var msg = i[0];
if(l > 20) i[0].substr(0,5) + "...(" + l + ")..." + i[0].substr(-5);
if(l > 20) msg = i[0].substr(0,5) + "...(" + l + ")..." + i[0].substr(-5);
it(msg, function() {
if(i[2] === 1) assert.equal(X.bstr(i[0]), i[1]|0);
assert.equal(X.str(i[0]), i[1]|0);

View File

@ -1,8 +1,10 @@
var m = "foobar"; for(var i = 0; i != 11; ++i) m+=m;
var bits = [
[ "foobar", -1628037227, 1 ],
[ "foo bar baz", -228401567, 1 ],
[ "foo bar baz٪", 984445192 ],
[ "foo bar baz٪☃", 140429620],
[ "foo bar baz٪☃🍣", 1531648243]
[ "foo bar baz٪☃🍣", 1531648243],
[ m, 40270464, 1 ]
];
if(typeof module !== "undefined") module.exports = bits;

View File

@ -22,7 +22,7 @@ describe('crc32 bits', function() {
bits.forEach(function(i) {
var l = i[0].length;
var msg = i[0];
if(l > 20) i[0].substr(0,5) + "...(" + l + ")..." + i[0].substr(-5);
if(l > 20) msg = i[0].substr(0,5) + "...(" + l + ")..." + i[0].substr(-5);
it(msg, function() {
if(i[2] === 1) assert.equal(X.bstr(i[0]), i[1]|0);
assert.equal(X.str(i[0]), i[1]|0);