diff --git a/Sources/Assimp/Assimp.swift b/Sources/Assimp/Assimp.swift index 90509e4..00f7b39 100644 --- a/Sources/Assimp/Assimp.swift +++ b/Sources/Assimp/Assimp.swift @@ -8,11 +8,11 @@ @_implementationOnly import CAssimp public enum Assimp { - static func canImportFileExtension(_ fileExtension: String) -> Bool { aiGetImporterDesc(fileExtension.lowercased()) != nil } + public static func canImportFileExtension(_ fileExtension: String) -> Bool { aiGetImporterDesc(fileExtension.lowercased()) != nil } - static func getImporterDescriptor(for fileExtension: String) -> AiImporterDesc? { AiImporterDesc(aiGetImporterDesc(fileExtension.lowercased())?.pointee) } + public static func getImporterDescriptor(for fileExtension: String) -> AiImporterDesc? { AiImporterDesc(aiGetImporterDesc(fileExtension.lowercased())?.pointee) } - static func importFormats() -> [AiImporterDesc] { + public static func importFormats() -> [AiImporterDesc] { let count = aiGetImportFormatCount() guard count > 0 else { @@ -23,11 +23,11 @@ public enum Assimp { .compactMap { AiImporterDesc(aiGetImportFormatDescription($0)?.pointee) } } - static func importFileExtensions() -> [String] { + public static func importFileExtensions() -> [String] { importFormats().flatMap(\.fileExtensions).sorted() } - static func exportFormats() -> [AiExporterDesc] { + public static func exportFormats() -> [AiExporterDesc] { let count = aiGetExportFormatCount() guard count > 0 else { @@ -38,7 +38,7 @@ public enum Assimp { .compactMap { AiExporterDesc(aiGetExportFormatDescription($0)?.pointee) } } - static func exportFileExtensions() -> [String] { + public static func exportFileExtensions() -> [String] { exportFormats().map(\.fileExtension).sorted() } } diff --git a/Tests/AssimpTests/AssimpTests.swift b/Tests/AssimpTests/AssimpTests.swift index 11f0234..a691cc6 100644 --- a/Tests/AssimpTests/AssimpTests.swift +++ b/Tests/AssimpTests/AssimpTests.swift @@ -1,31 +1,12 @@ import XCTest -@testable import Assimp -@_implementationOnly import CAssimp +import Assimp final class AssimpTests: XCTestCase { - func testVersion() { - XCTAssertEqual(aiGetVersionMajor(), 5) - XCTAssertNotNil(aiGetVersionMinor()) - XCTAssertNotNil(aiGetVersionRevision()) - } - func testFailingInitializer() { XCTAssertThrowsError(try AiScene(file: "")) } - func testVec3fFromAiVector3D() { - let vec3f = aiVector3D(x: 1.2, y: 3.4, z: 5.6).vector - XCTAssertEqual(vec3f, SIMD3(1.2, 3.4, 5.6)) - XCTAssertEqual(SIMD3(aiVector3D(x: 5.6, y: 3.4, z: 1.2)), SIMD3(5.6, 3.4, 1.2)) - } - - func testVec2fFromAiVector2D() { - let vec2f = aiVector2D(x: 1.2, y: 3.4).vector - XCTAssertEqual(vec2f, SIMD2(1.2, 3.4)) - XCTAssertEqual(SIMD2(aiVector2D(x: 5.6, y: 3.4)), SIMD2(5.6, 3.4)) - } - func testImportFormats() { XCTAssertTrue(Assimp.canImportFileExtension("obj")) XCTAssertTrue(Assimp.canImportFileExtension("dae")) diff --git a/Tests/AssimpTests/InternalTests.swift b/Tests/AssimpTests/InternalTests.swift new file mode 100644 index 0000000..61a15db --- /dev/null +++ b/Tests/AssimpTests/InternalTests.swift @@ -0,0 +1,23 @@ +import XCTest +@testable import Assimp +@_implementationOnly import CAssimp + +final class InternalTests: XCTestCase { + func testVersion() { + XCTAssertEqual(aiGetVersionMajor(), 5) + XCTAssertNotNil(aiGetVersionMinor()) + XCTAssertNotNil(aiGetVersionRevision()) + } + + func testVec3fFromAiVector3D() { + let vec3f = aiVector3D(x: 1.2, y: 3.4, z: 5.6).vector + XCTAssertEqual(vec3f, SIMD3(1.2, 3.4, 5.6)) + XCTAssertEqual(SIMD3(aiVector3D(x: 5.6, y: 3.4, z: 1.2)), SIMD3(5.6, 3.4, 1.2)) + } + + func testVec2fFromAiVector2D() { + let vec2f = aiVector2D(x: 1.2, y: 3.4).vector + XCTAssertEqual(vec2f, SIMD2(1.2, 3.4)) + XCTAssertEqual(SIMD2(aiVector2D(x: 5.6, y: 3.4)), SIMD2(5.6, 3.4)) + } +}