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
-15
@@ -1,9 +1,5 @@
|
||||
-- model/ply tests: files written by plyfile (ascii / binary LE / BE, every property type and spelling, odd orders,
|
||||
-- n-gons up to 300 vertices, face properties and lists, extra elements, comments, point clouds) and by assimp, against
|
||||
-- plyfile's reading mapped to the Scene conventions (CRC-32 of every attribute, the indices triangulated or as
|
||||
-- polygons, face data, raw elements); our encoder's output read back by plyfile and assimp (verdicts from the fixture
|
||||
-- step); round trips in every encoding (fixtures and generated scenes, polygons and points); the contract, error
|
||||
-- codes, the fuzz no-throw pass and a binary decode throughput note. Fixtures: tools/fixtures/ply.py.
|
||||
-- model/ply tests: plyfile and assimp files against plyfile's reading (CRC-32 per attribute); plyfile / assimp read ours.
|
||||
-- Fixtures: tools/fixtures/ply.py.
|
||||
local T = require("@tests/T")
|
||||
local Ply = require("@rosetta/model/ply")
|
||||
local Bytes = require("@rosetta/core/Bytes")
|
||||
@@ -22,13 +18,11 @@ end
|
||||
|
||||
local ENCODINGS = { "ascii", "binary_little_endian", "binary_big_endian" }
|
||||
|
||||
-- 1. the contract
|
||||
t:eq(Ply.name, "ply", "name")
|
||||
t:eq(Ply.category, "model", "category")
|
||||
t:check(table.find(Ply.extensions, "ply") ~= nil, "extensions")
|
||||
t:check(Ply.caps.decode and Ply.caps.encode, "caps")
|
||||
|
||||
-- a decoded scene against a reference case (triangulated)
|
||||
local function verify(scene: any, c: any, label: string)
|
||||
t:check(scene.kind == "scene" and #scene.meshes == 1 and #scene.meshes[1].primitives == 1, label .. ": one primitive")
|
||||
local p = scene.meshes[1].primitives[1]
|
||||
@@ -101,7 +95,6 @@ local function verify(scene: any, c: any, label: string)
|
||||
end
|
||||
end
|
||||
|
||||
-- 2. every fixture against plyfile; 3. round trips of every fixture in every encoding
|
||||
for _, c in Fx.cases do
|
||||
local label = c.name
|
||||
local scene, err = decode(c.data)
|
||||
@@ -116,7 +109,6 @@ for _, c in Fx.cases do
|
||||
buffer.writestring(big, 4, c.data)
|
||||
local s2 = Ply.decode(Bytes.reader(big, 4, #c.data))
|
||||
t:check(s2 and Crc32.of(s2.meshes[1].primitives[1].attributes.POSITION.data) == c.attrs.POSITION.crc, label .. ": decode from a sub-range")
|
||||
-- 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
|
||||
@@ -144,7 +136,6 @@ for _, c in Fx.cases do
|
||||
end
|
||||
end
|
||||
verify(back, cc, label .. " -> " .. enc)
|
||||
-- polygons in, polygons out
|
||||
local pout = Ply.encode(poly, { format = enc }) :: buffer
|
||||
local pback = decode(pout, { triangulate = false })
|
||||
verify(decode(pout), c, label .. " -> " .. enc .. " (polygons)")
|
||||
@@ -169,7 +160,6 @@ for _, v in Fx.ours do
|
||||
end
|
||||
t:note("%d encodings read back by plyfile and assimp", #Fx.ours)
|
||||
|
||||
-- the encoder scenes: decode(encode()) against the properties computed by the generator
|
||||
local function build(spec: any): Types.Scene
|
||||
local scene = Types.Scene.new()
|
||||
for i, m in spec.meshes do
|
||||
@@ -263,7 +253,6 @@ for _, spec in Scenes do
|
||||
end
|
||||
end
|
||||
|
||||
-- options and meta: comments, extra elements written back, faceAttributes of a triangulated mesh
|
||||
do
|
||||
local scene = build(Scenes[1])
|
||||
scene.meta.ply = { comments = { "first" }, objInfo = { "info line" } }
|
||||
@@ -282,7 +271,6 @@ do
|
||||
t:eq(decode(Ply.encode(bare) :: buffer).meta.source.vertices, 20, "a scene without nodes")
|
||||
end
|
||||
|
||||
-- 4. error codes
|
||||
do
|
||||
local function code(s: string, opts: any?): string?
|
||||
local _, e = decode(s, opts)
|
||||
@@ -323,7 +311,6 @@ do
|
||||
t:check(a2 and a2.code == Err.ARG, "no POSITION: " .. tostring(a2))
|
||||
end
|
||||
|
||||
-- 5. fuzz
|
||||
do
|
||||
local samples = {}
|
||||
for _, c in Fx.cases do
|
||||
|
||||
Reference in new issue
Block a user