Skip to content

Commit

Permalink
Move end to end tests to individual folders
Browse files Browse the repository at this point in the history
  • Loading branch information
cozmo committed Jun 28, 2018
1 parent 76e1174 commit 266eb0e
Show file tree
Hide file tree
Showing 506 changed files with 48,514 additions and 71 deletions.
1 change: 0 additions & 1 deletion src/extractor/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ function matricCompare(a: BitMatrix, b: BitMatrix) {
for (let x = 0; x < a.width; x++) {
for (let y = 0; y < a.height; y++) {
if (a.get(x, y) !== b.get(x, y)) {
console.log(x, y);
return false;
}
}
Expand Down
27 changes: 11 additions & 16 deletions tests/end-to-end-test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import * as fs from "fs-extra";
import * as path from "path";
import jsQR from "../src";
import tests from "../test-data";
import { loadPng } from "../tests/helpers";
import * as helpers from "./helpers";

describe("end to end", () => {
tests.forEach((t) => {
it(t.name, async () => {
const inputImage = await loadPng(t.inputPath);

const output = jsQR(inputImage.data, inputImage.width, inputImage.height);
expect(!!output).toBe(t.successful);
if (output) {
expect(output.chunks).toEqual(t.decoded.chunks);
expect(output.location.topLeftFinderPattern).toEqual(t.location.topLeft);
expect(output.location.topRightFinderPattern).toEqual(t.location.topRight);
expect(output.location.bottomLeftFinderPattern).toEqual(t.location.bottomLeft);
expect(output.location.bottomRightAlignmentPattern).toEqual(t.location.alignmentPattern);
}
describe("end to end", async () => {
const tests = fs.readdirSync(path.join("tests", "end-to-end")).filter((n) => !n.includes("."));
for (const t of tests) {
it(t, async () => {
const inputImage = await helpers.loadPng(path.join("tests", "end-to-end", t, "input.png"));
const expectedOutput = JSON.parse(await fs.readFile(path.join("tests", "end-to-end", t, "output.json"), "utf8"));
expect(jsQR(inputImage.data, inputImage.width, inputImage.height)).toEqual(expectedOutput);
});
});
}
});
File renamed without changes
155 changes: 155 additions & 0 deletions tests/end-to-end/0/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"binaryData": [
72,
97,
112,
112,
121,
32,
49,
115,
116,
32,
66,
105,
114,
116,
104,
100,
97,
121,
32,
71,
101,
101,
107,
85,
112,
32,
76,
101,
101,
100,
115,
33,
32,
104,
116,
116,
112,
58,
47,
47,
119,
119,
119,
46,
103,
101,
101,
107,
117,
112,
46,
111,
114,
103
],
"data": "Happy 1st Birthday GeekUp Leeds! http://www.geekup.org",
"chunks": [
{
"type": "byte",
"bytes": [
72,
97,
112,
112,
121,
32,
49,
115,
116,
32,
66,
105,
114,
116,
104,
100,
97,
121,
32,
71,
101,
101,
107,
85,
112,
32,
76,
101,
101,
100,
115,
33,
32,
104,
116,
116,
112,
58,
47,
47,
119,
119,
119,
46,
103,
101,
101,
107,
117,
112,
46,
111,
114,
103
],
"text": "Happy 1st Birthday GeekUp Leeds! http://www.geekup.org"
}
],
"location": {
"topRightCorner": {
"x": 85.6589952404445,
"y": 152.95701493173004
},
"topLeftCorner": {
"x": 198.49511301678757,
"y": 155.7757992624642
},
"bottomRightCorner": {
"x": 88.94963836398668,
"y": 39.94221579273518
},
"bottomLeftCorner": {
"x": 200.82807352747398,
"y": 45.02369025435685
},
"topRightFinderPattern": {
"x": 95.75,
"y": 143.5
},
"topLeftFinderPattern": {
"x": 189.25,
"y": 146
},
"bottomLeftFinderPattern": {
"x": 191.25,
"y": 54
},
"bottomRightAlignmentPattern": {
"x": 106.5,
"y": 58.5
}
}
}
File renamed without changes
103 changes: 103 additions & 0 deletions tests/end-to-end/1/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"binaryData": [
104,
116,
116,
112,
58,
47,
47,
97,
100,
115,
105,
116,
101,
115,
46,
99,
111,
109,
46,
97,
117,
47,
63,
69,
61,
50,
56,
48
],
"data": "http://adsites.com.au/?E=280",
"chunks": [
{
"type": "byte",
"bytes": [
104,
116,
116,
112,
58,
47,
47,
97,
100,
115,
105,
116,
101,
115,
46,
99,
111,
109,
46,
97,
117,
47,
63,
69,
61,
50,
56,
48
],
"text": "http://adsites.com.au/?E=280"
}
],
"location": {
"topRightCorner": {
"x": 113.42608710225241,
"y": 112.6525518412585
},
"topLeftCorner": {
"x": 68.61663289156108,
"y": 111.93099954299421
},
"bottomRightCorner": {
"x": 112.83506232554757,
"y": 157.67420240573884
},
"bottomLeftCorner": {
"x": 67.94799307253464,
"y": 157.47154305895137
},
"topRightFinderPattern": {
"x": 108,
"y": 118
},
"topLeftFinderPattern": {
"x": 74,
"y": 117.5
},
"bottomLeftFinderPattern": {
"x": 73.5,
"y": 152
},
"bottomRightAlignmentPattern": {
"x": 103,
"y": 147.5
}
}
}
File renamed without changes
87 changes: 87 additions & 0 deletions tests/end-to-end/10/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"binaryData": [
104,
116,
116,
112,
58,
47,
47,
103,
111,
111,
46,
98,
121,
47,
119,
107,
69,
116,
99,
111
],
"data": "http://goo.by/wkEtco",
"chunks": [
{
"type": "byte",
"bytes": [
104,
116,
116,
112,
58,
47,
47,
103,
111,
111,
46,
98,
121,
47,
119,
107,
69,
116,
99,
111
],
"text": "http://goo.by/wkEtco"
}
],
"location": {
"topRightCorner": {
"x": 154.85921217173825,
"y": 86.89078782826178
},
"topLeftCorner": {
"x": 66.39929838307573,
"y": 90.77826055986894
},
"bottomRightCorner": {
"x": 154.69686500102117,
"y": 167.88317788821564
},
"bottomLeftCorner": {
"x": 68.0534742570113,
"y": 173.69652574298868
},
"topRightFinderPattern": {
"x": 142.75,
"y": 99
},
"topLeftFinderPattern": {
"x": 79.25,
"y": 102
},
"bottomLeftFinderPattern": {
"x": 80.25,
"y": 161.5
},
"bottomRightAlignmentPattern": {
"x": 132.5,
"y": 148.5
}
}
}
File renamed without changes
Loading

0 comments on commit 266eb0e

Please sign in to comment.