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,11 +1,5 @@
|
||||
-- model/ldraw tests: hand-written LDraw files (a brick of primitives found through library paths, an MPD with
|
||||
-- embedded parts and sub-models, BFC CW / CCW / INVERTNEXT / NOCLIP / uncertified files, mirrored references, colours
|
||||
-- 16 / 24 / direct / local !COLOUR, optional lines, a missing part, a self-reference, bad lines, CRLF) and real library
|
||||
-- parts and models (3001, 3062b, 4073, 3626c, car.ldr, pyramid.ldr) against an independent expansion in the generator
|
||||
-- (world triangles per colour, double-sided faces, lines, area, signed volume of the one-sided faces, bounds, missing
|
||||
-- files) and LeoCAD's OBJ export (bounds, area); node / flattened / un-flipped scenes agree; mesh sharing; the
|
||||
-- built-in colour table against LDConfig.ldr; resolve; error codes; the fuzz no-throw pass. Fixtures:
|
||||
-- tools/fixtures/ldraw.py.
|
||||
-- model/ldraw tests: hand-written and real LDraw files against the generator's own expansion and LeoCAD's OBJ export.
|
||||
-- Fixtures: tools/fixtures/ldraw.py.
|
||||
local T = require("@tests/T")
|
||||
local Ldraw = require("@rosetta/model/ldraw")
|
||||
local MeshOps = require("@rosetta/ops/MeshOps")
|
||||
@@ -33,7 +27,6 @@ t:check(Ldraw.sniff(Bytes.reader(buffer.fromstring("0 FILE main.ldr\n1 16 0 0 0
|
||||
t:check(Ldraw.sniff(Bytes.reader(buffer.fromstring("0 x\n1 16 0 0 0 1 0 0 0 1 0 0 0 1 3001.dat\n"))) >= 0.8, "sniff LDR")
|
||||
t:eq(Ldraw.sniff(Bytes.reader(buffer.fromstring("solid cube\n facet normal 0 0 1\n"))), 0, "sniff other")
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ colour table
|
||||
do
|
||||
local tbl = Ldraw.colors()
|
||||
local bad = 0
|
||||
@@ -48,7 +41,6 @@ do
|
||||
t:check(over[4].rgb == 0x010203 and over[4].edge == 0 and over[4].name == "Mine", "ldconfig overrides")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ measuring
|
||||
type Stats = { triangles: number, lines: number, optional: number, ds: number, area: number, volume: number, colours: { [number]: number } }
|
||||
|
||||
local function det3(m: { number }): number
|
||||
@@ -120,7 +112,6 @@ local function compare(label: string, s: Stats, w: any)
|
||||
t:check(near(s.volume, w.volume, 1e-5), string.format("%s: signed volume %.6f / %.6f", label, s.volume, w.volume))
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ cases
|
||||
local samples = {}
|
||||
local lib: any = nil
|
||||
for _, c in Cases do
|
||||
@@ -172,12 +163,10 @@ for _, c in Cases do
|
||||
table.insert(steps, scene.nodes[ci].extras.ldraw.step)
|
||||
end
|
||||
t:eq(table.concat(steps, ","), "1,1,1,2", "two.ldr: steps")
|
||||
-- through resolve instead of files
|
||||
local viaResolve = assert(decode(c.data, { resolve = function(uri: string): any
|
||||
return c.files[uri]
|
||||
end }))
|
||||
t:eq(measure(viaResolve).triangles, w.triangles, "two.ldr: resolve")
|
||||
-- optional lines on request
|
||||
local withOpt = assert(decode(c.data, { files = c.files, optionalLines = true, lines = false }))
|
||||
local so = measure(withOpt)
|
||||
t:check(so.optional == w.optional and so.lines == 0, "two.ldr: optional lines only")
|
||||
@@ -202,7 +191,6 @@ for _, c in Cases do
|
||||
end
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ errors
|
||||
do
|
||||
local _, e = decode("")
|
||||
t:check(e and e.code == Err.CORRUPT, "empty: CORRUPT")
|
||||
@@ -214,7 +202,6 @@ do
|
||||
t:check(e and e.code == Err.LIMIT, "maxDepth: LIMIT")
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ fuzz
|
||||
t:fuzz("decode", function(b: buffer)
|
||||
local s = Ldraw.decode(Bytes.reader(b), { files = lib, optionalLines = true })
|
||||
if s then
|
||||
|
||||
Reference in new issue
Block a user