Skip to content

Commit 7a80dc8

Browse files
committed
test(transform-io): additional node tests
1 parent 02a3e57 commit 7a80dc8

File tree

5 files changed

+78
-18
lines changed

5 files changed

+78
-18
lines changed
Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,33 @@
1-
import path from 'path'
2-
import fs from 'fs'
1+
import path from "path";
2+
import fs from "fs";
33

4-
export const testInputPath = path.resolve('..', 'test', 'data', 'input')
5-
export const testBaselinePath = path.resolve('..', 'test', 'data', 'baseline')
6-
export const testOutputPath = path.resolve('..', 'test', 'output', 'typescript')
7-
fs.mkdirSync(testOutputPath, { recursive: true })
4+
export const testInputPath = path.resolve("..", "test", "data", "input");
5+
export const testBaselinePath = path.resolve("..", "test", "data", "baseline");
6+
export const testOutputPath = path.resolve(
7+
"..",
8+
"test",
9+
"output",
10+
"typescript"
11+
);
12+
fs.mkdirSync(testOutputPath, { recursive: true });
13+
14+
export function verifyTestLinearTransform(t, transformList) {
15+
t.is(transformList.length, 1);
16+
const transform = transformList[0];
17+
t.is(transform.transformType.transformParameterization, "Affine");
18+
t.is(transform.transformType.parametersValueType, "float64");
19+
t.is(transform.transformType.inputDimension, 3);
20+
t.is(transform.transformType.outputDimension, 3);
21+
t.is(transform.numberOfParameters, 12);
22+
t.is(transform.numberOfFixedParameters, 3);
23+
t.deepEqual(transform.fixedParameters, new Float64Array([0, 0, 0]));
24+
t.deepEqual(
25+
transform.parameters,
26+
new Float64Array([
27+
0.65631490118447, 0.5806583745824385, -0.4817536741017158,
28+
-0.7407986817430222, 0.37486398378429736, -0.5573995934598175,
29+
-0.14306664045479867, 0.7227121458012518, 0.676179776908723,
30+
-65.99999999999997, 69.00000000000004, 32.000000000000036,
31+
])
32+
);
33+
}
Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import test from 'ava'
2-
import path from 'path'
1+
import test from "ava";
2+
import path from "path";
33

4-
import { hdf5ReadTransformNode } from '../../dist/index-node.js'
4+
import { hdf5ReadTransformNode } from "../../dist/index-node.js";
55

6-
import { testInputPath } from './common.js'
6+
import { testInputPath, verifyTestLinearTransform } from "./common.js";
77

8-
const testInputFilePath = path.join(testInputPath, 'LinearTransform.h5')
8+
const testInputFilePath = path.join(testInputPath, "LinearTransform.h5");
99

10-
test('Test reading a HDF5 file', async t => {
11-
const { couldRead, transform } = await hdf5ReadTransformNode(testInputFilePath)
12-
t.true(couldRead)
13-
console.log(transform)
14-
})
10+
test("Test reading a HDF5 file", async (t) => {
11+
const { couldRead, transform } = await hdf5ReadTransformNode(
12+
testInputFilePath
13+
);
14+
t.true(couldRead);
15+
verifyTestLinearTransform(t, transform);
16+
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import test from "ava";
2+
import path from "path";
3+
4+
import { wasmReadTransformNode } from "../../dist/index-node.js";
5+
6+
import { testInputPath, verifyTestLinearTransform } from "./common.js";
7+
8+
const testInputFilePath = path.join(testInputPath, "LinearTransform.iwt.cbor");
9+
10+
test("Test reading a .iwt.cbor file", async (t) => {
11+
const { couldRead, transform } = await wasmReadTransformNode(
12+
testInputFilePath
13+
);
14+
t.true(couldRead);
15+
verifyTestLinearTransform(t, transform);
16+
});

packages/transform-io/typescript/test/node/mat-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from "path";
33

44
import { matReadTransformNode } from "../../dist/index-node.js";
55

6-
import { testInputPath } from "./common.js";
6+
import { testInputPath, verifyTestLinearTransform } from "./common.js";
77

88
const testInputFilePath = path.join(testInputPath, "LinearTransform.mat");
99

@@ -12,5 +12,5 @@ test("Test reading a .mat file", async (t) => {
1212
testInputFilePath
1313
);
1414
t.true(couldRead);
15-
console.log(transform);
15+
verifyTestLinearTransform(t, transform);
1616
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import test from "ava";
2+
import path from "path";
3+
4+
import { txtReadTransformNode } from "../../dist/index-node.js";
5+
6+
import { testInputPath, verifyTestLinearTransform } from "./common.js";
7+
8+
const testInputFilePath = path.join(testInputPath, "LinearTransform.txt");
9+
10+
test("Test reading a Insight Legacy TXT transform file", async (t) => {
11+
const { couldRead, transform } = await txtReadTransformNode(
12+
testInputFilePath
13+
);
14+
t.true(couldRead);
15+
verifyTestLinearTransform(t, transform);
16+
});

0 commit comments

Comments
 (0)