From a5b282356b86a412634673de005e5f1c5eda09bc Mon Sep 17 00:00:00 2001 From: Luke Page Date: Thu, 6 Aug 2015 13:23:33 +0100 Subject: [PATCH] bg spec --- package.json | 1 + test/.gitignore | 1 + test/bg-ref.png | Bin 0 -> 119 bytes test/bg-spec.js | 39 +++++++++++++++++++++++++++++++++++++++ test/bg.js | 27 --------------------------- test/bg.png | Bin 93 -> 119 bytes test/run-compare.js | 2 +- 7 files changed, 42 insertions(+), 28 deletions(-) create mode 100644 test/.gitignore create mode 100644 test/bg-ref.png create mode 100644 test/bg-spec.js delete mode 100644 test/bg.js diff --git a/package.json b/package.json index 6ce6992..cafe120 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "url": "https://github.com/lukeapage/pngjs2/issues" }, "devDependencies": { + "buffer-equal": "0.0.1", "connect": "^3.4.0", "coveralls": "^2.11.3", "eslint": "^1.0.0", diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..f540178 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +bg.png diff --git a/test/bg-ref.png b/test/bg-ref.png new file mode 100644 index 0000000000000000000000000000000000000000..e4361e0e4dd6fa63c5f7111b9cd522d9674a18ba GIT binary patch literal 119 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4F?qT;hEy=Vk*d1{9rYq)XFVa?@@sQBl?Oe93snj`K+G4*efM Oy$qhNelF{r5}E*je> 1) ^ y < (png.height >> 1) ? 0xe5 : 0xff; + + png.data[idx] = col; + png.data[idx + 1] = col; + png.data[idx + 2] = col; + png.data[idx + 3] = 0xff; + } + } + + png.pack().pipe(fs.createWriteStream(__dirname + '/bg.png')) + .on("finish", function () { + + var out = fs.readFileSync(__dirname + '/bg.png'); + var ref = fs.readFileSync(__dirname + '/bg-ref.png'); + + t.ok(bufferEqual(out, ref), "compares with working file ok"); + + t.end(); + }); +}); diff --git a/test/bg.js b/test/bg.js deleted file mode 100644 index ad39243..0000000 --- a/test/bg.js +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env node - -var fs = require('fs'), - PNG = require('pngjs').PNG; - - -var png = new PNG({ - width: 10, - height: 10, - filterType: -1 -}); - - -for (var y = 0; y < png.height; y++) { - for (var x = 0; x < png.width; x++) { - var idx = (png.width * y + x) << 2; - - var col = x < (png.width >> 1) ^ y < (png.height >> 1) ? 0xe5 : 0xff; - - png.data[idx] = col; - png.data[idx + 1] = col; - png.data[idx + 2] = col; - png.data[idx + 3] = 0xff; - } -} - -png.pack().pipe(fs.createWriteStream(__dirname + '/bg.png')); diff --git a/test/bg.png b/test/bg.png index b030229db0a4edd335512da859381d192e92aec4..e4361e0e4dd6fa63c5f7111b9cd522d9674a18ba 100644 GIT binary patch delta 88 zcmazopP&-V5 rczSvTO}aF_B{%KH5*1ZV&zFpM>^P6~?$G}M)XU)M>gTe~DWM4f2bLpU delta 62 zcmXSqouFc=;_2cTQgJK!4?hb}#)F%i(_c98`0%(iF@~III{PpvD9HJeF~c1@&LeYc Rd-pH^fv2mV%Q~loCIAWI7%l(+ diff --git a/test/run-compare.js b/test/run-compare.js index b9a98de..fe4ef23 100644 --- a/test/run-compare.js +++ b/test/run-compare.js @@ -13,7 +13,7 @@ try { console.log("Comparing in PhantomJS"); childProcess.execFile(binPath, childArgs, function (err, stdout, stderr) { - + // handle results console.log("Comparison Test Results:"); console.log(stdout);