Repository Public License
1// ORIX Convert — Packages/EngineModel3D/Tests/EngineModel3DTests/MatrixTests.swift2// Description: Converts a real fixture through every declared path of the 3D engine and validates the output3// (core generic checks + the engine's independent re-read: triangles, positions, bounding box).4// Author: Simon-Pierre Boucher — contact@spboucher.ai5import Foundation6import Testing7import ConvertCore8@testable import EngineModel3D910@Suite("Every declared path converts and validates")11struct MatrixTests {12 static let engine = Model3DEngine()13 static let pathIDs: [String] = Model3DCatalog.allPaths().map(\.id)1415 @Test("declared paths", arguments: pathIDs)16 func declaredPath(id: String) async throws {17 let path = try #require(Self.engine.paths.first { $0.id == id })18 let directory = Fixtures.directory("matrix")19 defer { try? FileManager.default.removeItem(at: directory) }20 let sourceDirectory = directory.appendingPathComponent("in", isDirectory: true), work = directory.appendingPathComponent("work", isDirectory: true)21 try FileManager.default.createDirectory(at: sourceDirectory, withIntermediateDirectories: true)22 try FileManager.default.createDirectory(at: work, withIntermediateDirectories: true)23 let source = try Fixtures.source(path.source, in: sourceDirectory)24 // Sources without a unit or an up axis are given one, as a user would, so that every destination is exact.25 var options: [String: OptionValue] = [:]26 if [.obj, .stl, .ply].contains(path.source) { options["unit.source"] = .string("m"); options["axis.source"] = .string("y") }27 let (output, _, request) = try await Self.engine.run(source.url, from: path.source, to: path.destination, operation: path.operation, options: options, work: work)2829 #expect(output.facts["triangles"] == "\(source.triangles)", "\(id): \(output.facts["triangles"] ?? "nil") triangles written, fixture has \(source.triangles)")30 let generic = OutputValidator.validate(output, destinationFormat: path.destination, workDirectory: work)31 for check in generic { #expect(check.passed, "\(id) generic \(check.name): \(check.detail)") }32 let checks = try await Self.engine.validate(output, request: request, source: nil)33 #expect(checks.contains { $0.name.hasPrefix("model.triangles") })34 #expect(checks.contains { $0.name.hasPrefix("model.positions") })35 for check in checks { #expect(check.passed, "\(id) \(check.name): \(check.detail)") }36 }3738 @Test func pathCountAndShape() {39 let paths = Self.engine.paths40 #expect(Set(paths.map(\.id)).count == paths.count)41 for path in paths {42 #expect(path.engine == "model3d")43 #expect(!path.limitations.isEmpty)44 #expect((path.operation != nil) == (path.source == path.destination))45 if path.source == .fbx { #expect(path.status == .experimental) } else { #expect(path.status == .supported) }46 }47 #expect(!paths.contains { $0.destination == .fbx })48 }49}50