tests/model: comments: specs only
This commit is contained in:
1 parent
5f7f6005f6
commit
fe7566cbba
37 files changed
+72
-440
No files matched your search
+2
-14
@@ -1,8 +1,5 @@
|
||||
-- model/stl tests: files made by trimesh, assimp and by hand (binary starting with "solid", VisCAM / Magics colours,
|
||||
-- raw attribute words, odd ASCII, several solids, quads, no endsolid, trailing bytes) against trimesh's raw reader
|
||||
-- (CRC-32 of the f32 vertices / normals, area, bounds), our encoder's output read back by trimesh and assimp (verdicts
|
||||
-- from the fixture step), round trips of every encoding and option, the contract, error codes, the fuzz no-throw pass
|
||||
-- and a binary decode throughput note. Fixtures: tools/fixtures/stl.py.
|
||||
-- model/stl tests: trimesh, assimp and hand-made STL files against trimesh's raw reader; trimesh / assimp read ours.
|
||||
-- Fixtures: tools/fixtures/stl.py.
|
||||
local T = require("@tests/T")
|
||||
local Stl = require("@rosetta/model/stl")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -19,7 +16,6 @@ local function decode(data: any, opts: any?): (any, any)
|
||||
return Stl.decode(Bytes.reader(b), opts)
|
||||
end
|
||||
|
||||
-- every primitive's accessor `name` concatenated (nil when a primitive lacks it)
|
||||
local function concat(scene: any, name: string): buffer?
|
||||
local parts = {}
|
||||
for _, p in scene.meshes[1].primitives do
|
||||
@@ -32,13 +28,11 @@ local function concat(scene: any, name: string): buffer?
|
||||
return buffer.fromstring(table.concat(parts))
|
||||
end
|
||||
|
||||
-- 1. the contract
|
||||
t:eq(Stl.name, "stl", "name")
|
||||
t:eq(Stl.category, "model", "category")
|
||||
t:check(table.find(Stl.extensions, "stl") ~= nil, "extensions")
|
||||
t:check(Stl.caps.decode and Stl.caps.encode, "caps")
|
||||
|
||||
-- 2. every fixture against the reference
|
||||
for _, c in Fx.cases do
|
||||
local label = c.name
|
||||
local scene, err = decode(c.data)
|
||||
@@ -115,7 +109,6 @@ for _, c in Fx.cases do
|
||||
t:eq(prims[i].attributes.POSITION.count, c.solidFacets[i] * 3, label .. ": solid facets")
|
||||
end
|
||||
end
|
||||
-- inside a bigger buffer (the Reader's range)
|
||||
local big = buffer.create(#c.data + 11)
|
||||
buffer.writestring(big, 5, c.data)
|
||||
local s2 = Stl.decode(Bytes.reader(big, 5, #c.data))
|
||||
@@ -148,13 +141,11 @@ for _, c in Fx.cases do
|
||||
end
|
||||
t:note("%d files match trimesh / the generator", #Fx.cases)
|
||||
|
||||
-- 3. the reference tools read our output
|
||||
for _, v in Fx.ours do
|
||||
t:check(v.ok, "trimesh / assimp read our " .. v.name .. ": " .. v.detail)
|
||||
end
|
||||
t:note("%d encodings read back by trimesh and assimp", #Fx.ours)
|
||||
|
||||
-- round trips of the encoder scenes: world-space soup as the generator computed it, colour words, idempotence
|
||||
local function acc(s: string, ty: string, comps: number, count: number): Types.Accessor
|
||||
return Types.Scene.accessor(buffer.fromstring(s), ty, comps, count)
|
||||
end
|
||||
@@ -237,7 +228,6 @@ for _, spec in Scenes do
|
||||
t:check(buffer.tostring(again) == buffer.tostring(out :: buffer), label .. ": re-encode is identical")
|
||||
end
|
||||
end
|
||||
-- options: header, name, computed vs attribute normals
|
||||
do
|
||||
local scene = build(Scenes[1])
|
||||
local out = Stl.encode(scene, { header = "my header", ascii = false }) :: buffer
|
||||
@@ -258,7 +248,6 @@ do
|
||||
t:eq(buffer.len(Stl.encode(bare) :: buffer), 84 + 50 * 60, "a scene without nodes")
|
||||
end
|
||||
|
||||
-- 4. error codes
|
||||
do
|
||||
local cube = Fx.cases[1].data
|
||||
local _, e1 = decode(string.sub(cube, 1, 84 + 50 * 3 + 7))
|
||||
@@ -302,7 +291,6 @@ do
|
||||
t:eq(Stl.sniff(Bytes.reader(buffer.fromstring("ply\nformat ascii 1.0\n"))), 0, "sniff a PLY")
|
||||
end
|
||||
|
||||
-- 5. fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for i, c in Fx.cases do
|
||||
|
||||
Reference in new issue
Block a user