-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'swift-testing' into dev
- Loading branch information
Showing
13 changed files
with
204 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Testing | ||
@testable import SwiftSCAD | ||
|
||
struct Geometry3DTests { | ||
@Test func basic3D() { | ||
let geometry = Box([20, 20, 20]) | ||
.aligned(at: .center) | ||
.intersection { | ||
Sphere(diameter: 23) | ||
} | ||
.subtracting { | ||
Cylinder(diameter: 2, height: 30) | ||
.repeated(around: .x, in: 0°..<360°, count: 12) | ||
.distributed(at: [0°, 90°], around: .z) | ||
} | ||
|
||
#expect(geometry.code == scadFile("3dbasics")) | ||
} | ||
|
||
@Test func empty3D() { | ||
let geometry = Box([10, 20, 30]) | ||
.subtracting {} | ||
.adding {} | ||
|
||
#expect(geometry.code == scadFile("empty3d")) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import XCTest | ||
@testable import SwiftSCAD | ||
|
||
func scadFile(_ fileName: String) -> String { | ||
let url = Bundle.module.url(forResource: fileName, withExtension: "scad", subdirectory: "SCAD")! | ||
return try! String(contentsOf: url, encoding: .utf8).trimmingCharacters(in: .whitespacesAndNewlines) | ||
} | ||
|
||
extension Geometry2D { | ||
var code: String { | ||
usingDefaultFacets().codeFragment(in: .defaultEnvironment).scadCode | ||
} | ||
|
||
func triggerEvaluation() { | ||
_ = codeFragment(in: .defaultEnvironment) | ||
} | ||
|
||
var bounds: BoundingBox2D? { | ||
boundary(in: .defaultEnvironment).boundingBox | ||
} | ||
} | ||
|
||
extension Geometry3D { | ||
func readingOperation(_ action: @escaping (Environment.Operation) -> ()) -> any Geometry3D { | ||
readingEnvironment { geo, environment in | ||
action(environment.operation) | ||
return self | ||
} | ||
} | ||
|
||
var code: String { | ||
usingDefaultFacets().codeFragment(in: .defaultEnvironment).scadCode | ||
} | ||
|
||
var bounds: BoundingBox3D? { | ||
boundary(in: .defaultEnvironment).boundingBox | ||
} | ||
|
||
func triggerEvaluation() { | ||
_ = codeFragment(in: .defaultEnvironment) | ||
} | ||
} |
Oops, something went wrong.