summaryrefslogtreecommitdiff
path: root/test/parallel/test-zlib-flush.js
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2014-12-17 20:30:04 +0700
committerFedor Indutny <fedor@indutny.com>2014-12-17 20:45:02 +0700
commit0e19476595729c850f07befea93e864822cd8459 (patch)
treea868c3dd1becd87b7b5ea9fd2b645dd61e68ae8c /test/parallel/test-zlib-flush.js
parent165b70f146e163b82a09bb869463708516c08cf6 (diff)
downloadnode-new-0e19476595729c850f07befea93e864822cd8459.tar.gz
test: split test in parallel/sequential
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> PR-URL: https://github.com/iojs/io.js/pull/172 Fix: iojs/io.js#139
Diffstat (limited to 'test/parallel/test-zlib-flush.js')
-rw-r--r--test/parallel/test-zlib-flush.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/parallel/test-zlib-flush.js b/test/parallel/test-zlib-flush.js
new file mode 100644
index 0000000000..0b189cecdd
--- /dev/null
+++ b/test/parallel/test-zlib-flush.js
@@ -0,0 +1,35 @@
+var common = require('../common.js');
+var assert = require('assert');
+var zlib = require('zlib');
+var path = require('path');
+var fs = require('fs');
+
+var file = fs.readFileSync(path.resolve(common.fixturesDir, 'person.jpg')),
+ chunkSize = 16,
+ opts = { level: 0 },
+ deflater = zlib.createDeflate(opts);
+
+var chunk = file.slice(0, chunkSize),
+ expectedNone = new Buffer([0x78, 0x01]),
+ blkhdr = new Buffer([0x00, 0x10, 0x00, 0xef, 0xff]),
+ adler32 = new Buffer([0x00, 0x00, 0x00, 0xff, 0xff]),
+ expectedFull = Buffer.concat([blkhdr, chunk, adler32]),
+ actualNone,
+ actualFull;
+
+deflater.write(chunk, function() {
+ deflater.flush(zlib.Z_NO_FLUSH, function() {
+ actualNone = deflater.read();
+ deflater.flush(function() {
+ var bufs = [], buf;
+ while (buf = deflater.read())
+ bufs.push(buf);
+ actualFull = Buffer.concat(bufs);
+ });
+ });
+});
+
+process.once('exit', function() {
+ assert.deepEqual(actualNone, expectedNone);
+ assert.deepEqual(actualFull, expectedFull);
+});