Skip to content

Commit

Permalink
Address test deprecations, pin to tap version that works with Node 21
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad committed Jan 21, 2024
1 parent 8b4281a commit 0a76020
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"type": "commonjs",
"dependencies": {},
"devDependencies": {
"tap": "~13.1.11"
"tap": "~11.1.5"
},
"optionalDependencies": {},
"engines": {
Expand Down
24 changes: 12 additions & 12 deletions tests/crc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@ const crc32 = require('..');
const test = require('tap').test;

test('simple crc32 is no problem', function (t) {
var input = new Buffer('hey sup bros');
var expected = new Buffer([0x47, 0xfa, 0x55, 0x70]);
var input = Buffer.from('hey sup bros');
var expected = Buffer.from([0x47, 0xfa, 0x55, 0x70]);
t.same(crc32(input), expected);
t.end();
});

test('another simple one', function (t) {
var input = new Buffer('IEND');
var expected = new Buffer([0xae, 0x42, 0x60, 0x82]);
var input = Buffer.from('IEND');
var expected = Buffer.from([0xae, 0x42, 0x60, 0x82]);
t.same(crc32(input), expected);
t.end();
});

test('slightly more complex', function (t) {
var input = new Buffer([0x00, 0x00, 0x00]);
var expected = new Buffer([0xff, 0x41, 0xd9, 0x12]);
var input = Buffer.from([0x00, 0x00, 0x00]);
var expected = Buffer.from([0xff, 0x41, 0xd9, 0x12]);
t.same(crc32(input), expected);
t.end();
});

test('complex crc32 gets calculated like a champ', function (t) {
var input = new Buffer('शीर्षक');
var expected = new Buffer([0x17, 0xb8, 0xaf, 0xf1]);
var input = Buffer.from('शीर्षक');
var expected = Buffer.from([0x17, 0xb8, 0xaf, 0xf1]);
t.same(crc32(input), expected);
t.end();
});

test('casts to buffer if necessary', function (t) {
var input = 'शीर्षक';
var expected = new Buffer([0x17, 0xb8, 0xaf, 0xf1]);
var expected = Buffer.from([0x17, 0xb8, 0xaf, 0xf1]);
t.same(crc32(input), expected);
t.end();
});
Expand All @@ -52,8 +52,8 @@ test('can do unsigned', function (t) {


test('simple crc32 in append mode', function (t) {
var input = [new Buffer('hey'), new Buffer(' '), new Buffer('sup'), new Buffer(' '), new Buffer('bros')];
var expected = new Buffer([0x47, 0xfa, 0x55, 0x70]);
var input = [Buffer.from('hey'), Buffer.from(' '), Buffer.from('sup'), Buffer.from(' '), Buffer.from('bros')];
var expected = Buffer.from([0x47, 0xfa, 0x55, 0x70]);
for (var crc = 0, i = 0; i < input.length; i++) {
crc = crc32(input[i], crc);
}
Expand All @@ -78,7 +78,7 @@ test('can do signed in append mode', function (t) {

test('make sure crc32 can accept integers as first arg ', function (t) {
try {
t.same(crc32(0), new Buffer([0x00, 0x00, 0x00, 0x00]));
t.same(crc32(0), Buffer.from([0x00, 0x00, 0x00, 0x00]));
} catch (e) {
t.fail("should be able to accept integer");
} finally {
Expand Down

0 comments on commit 0a76020

Please sign in to comment.