zlib.test.js
1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const test = require('tap').test;
const zlibA = require('zlib');
const zlibB = require('..');
const crypto = require('crypto');
test('zlibA.deflate -> zlibB.inflate', function (t) {
const expect = crypto.randomBytes(1024);
zlibA.deflate(expect, function (err, cmpA) {
zlibB.inflate(cmpA, function (err, result) {
t.same(result, expect, 'should match');
t.end();
});
});
});
test('zlibB.deflate -> zlibA.inflate', function (t) {
const expect = crypto.randomBytes(1024);
zlibB.deflate(expect, function (err, cmpA) {
zlibA.inflate(cmpA, function (err, result) {
t.same(result, expect, 'should match');
t.end();
});
});
});
test('zlibB.deflate -> zlibA.inflate (string)', function (t) {
const expect = 'ohaihihihihihihihihihihihihihihihi';
zlibB.deflate(expect, function (err, cmpA) {
zlibA.inflate(cmpA, function (err, result) {
t.same(result.toString(), expect, 'should match');
t.end();
});
});
});
test('zlibA.gzip -> zlibB.gunzip', function (t) {
const expect = crypto.randomBytes(1024);
zlibA.gzip(expect, function (err, cmpA) {
zlibB.gunzip(cmpA, function (err, result) {
t.same(result, expect, 'should match');
t.end();
});
});
});
test('zlibB.gzip -> zlibA.gunzip', function (t) {
const expect = crypto.randomBytes(1024);
zlibB.gzip(expect, function (err, cmpA) {
zlibA.gunzip(cmpA, function (err, result) {
t.same(result, expect, 'should match');
t.end();
});
});
});
test('zlibB.gzip -> zlibA.gunzip', function (t) {
const expect = 'lololololoollolololoololololololololololololololololololololol';
zlibB.gzip(expect, function (err, cmpA) {
zlibA.gunzip(cmpA, function (err, result) {
t.same(result.toString(), expect, 'should match');
t.end();
});
});
});