Skip to content

Commit b786dfd

Browse files
committed
test(mesh-io): add write-point-set-node-test
1 parent 4bdae4d commit b786dfd

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import test from 'ava'
2+
import path from 'path'
3+
4+
import { readPointSetNode, writePointSetNode } from '../../dist/index-node.js'
5+
import { IntTypes, FloatTypes, PixelTypes } from 'itk-wasm'
6+
7+
import { testInputPath, testOutputPath } from './common.js'
8+
9+
const testInputFilePath = path.resolve(testInputPath, "box-points.obj");
10+
const testOutputFilePath = path.resolve(
11+
testOutputPath,
12+
"write-point-set-test-box.obj",
13+
);
14+
15+
const verifyPointSet = (t, pointSet) => {
16+
t.is(pointSet.pointSetType.dimension, 3);
17+
t.is(pointSet.pointSetType.pointComponentType, FloatTypes.Float32);
18+
t.is(pointSet.pointSetType.pointPixelType, PixelTypes.Vector);
19+
t.is(pointSet.numberOfPoints, 8);
20+
t.is(pointSet.numberOfPointPixels, 0);
21+
};
22+
23+
test('writePointSetNode writes a file path on the local filesystem', async (t) => {
24+
const pointSet = await readPointSetNode(testInputFilePath)
25+
verifyPointSet(t, pointSet)
26+
27+
const useCompression = false
28+
const binaryFileType = false
29+
await writePointSetNode(pointSet, testOutputFilePath, { useCompression, binaryFileType })
30+
31+
const pointSetBack = await readPointSetNode(testOutputFilePath)
32+
verifyPointSet(t, pointSetBack)
33+
})

0 commit comments

Comments
 (0)