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
-12
@@ -1,9 +1,5 @@
|
||||
-- model/off tests: OFF files written by trimesh and by the generator (COFF integer / float colours, RGB / RGBA, NOFF,
|
||||
-- STOFF, STCNOFF, face colours, colormap indices, comments, counts on the header line, CRLF, tabs, n-gons, a point
|
||||
-- cloud) against the values they were written from (positions cross-checked with trimesh); our encoder's output read
|
||||
-- back by trimesh, assimp and the generator's reader (verdicts from the fixture step); round trips (polygons,
|
||||
-- triangles, face colours, scenes); the contract, error codes and the fuzz no-throw pass. Fixtures:
|
||||
-- tools/fixtures/off.py.
|
||||
-- model/off tests: trimesh and generated OFF files against the values they were written from; trimesh / assimp read ours.
|
||||
-- Fixtures: tools/fixtures/off.py.
|
||||
local T = require("@tests/T")
|
||||
local Off = require("@rosetta/model/off")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -27,13 +23,11 @@ local function same(a: any, b: any): boolean
|
||||
return a.type == b.type and a.components == b.components and a.count == b.count and buffer.tostring(a.data) == buffer.tostring(b.data)
|
||||
end
|
||||
|
||||
-- 1. the contract
|
||||
t:eq(Off.name, "off", "name")
|
||||
t:eq(Off.category, "model", "category")
|
||||
t:check(table.find(Off.extensions, "off") ~= nil, "extensions")
|
||||
t:check(Off.caps.decode and Off.caps.encode, "caps")
|
||||
|
||||
-- 2. every fixture against the values it was written from; 3. round trips
|
||||
for _, c in Fx.cases do
|
||||
local label = c.name
|
||||
local scene, err = decode(c.data)
|
||||
@@ -70,7 +64,6 @@ for _, c in Fx.cases do
|
||||
end
|
||||
end
|
||||
t:eq(Off.sniff(Bytes.reader(buffer.fromstring(c.data))), 0.9, label .. ": sniff")
|
||||
-- polygons kept
|
||||
local poly = decode(c.data, { triangulate = false })
|
||||
local pp = poly.meshes[1].primitives[1]
|
||||
if c.faces > 0 and not c.allTri then
|
||||
@@ -106,7 +99,6 @@ for _, v in Fx.ours do
|
||||
end
|
||||
t:note("%d encodings read back by trimesh, assimp and the generator", #Fx.ours)
|
||||
|
||||
-- the encoder scenes: decode(encode()) gives the scene back (identity transforms)
|
||||
local function build(spec: any): Types.Scene
|
||||
local scene = Types.Scene.new()
|
||||
for i, m in spec.meshes do
|
||||
@@ -160,7 +152,6 @@ do
|
||||
t:check(string.find(cm, "STCNOFF\n# made here\n", 1, true) ~= nil, "comment option")
|
||||
end
|
||||
|
||||
-- 4. error codes
|
||||
do
|
||||
local function code(s: string, opts: any?): string?
|
||||
local _, e = decode(s, opts)
|
||||
@@ -193,7 +184,6 @@ do
|
||||
t:eq(Off.sniff(Bytes.reader(buffer.fromstring("solid x\n"))), 0, "sniff an STL")
|
||||
end
|
||||
|
||||
-- 5. fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Fx.cases do
|
||||
|
||||
Reference in new issue
Block a user