Skip to content

Commit

Permalink
test improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
hfutrell committed May 24, 2019
1 parent 6f795aa commit b34c0d1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 6 additions & 1 deletion BezierKit/BezierKitTests/BoundingBoxTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class BoundingBoxTests: XCTestCase {
XCTAssertFalse(e.overlaps(infiniteBox))
XCTAssertFalse(e.overlaps(nanBox))

XCTAssertFalse(infiniteBox.isEmpty)
XCTAssertFalse(zeroBox.isEmpty)
XCTAssertFalse(sampleBox.isEmpty)
XCTAssertTrue(BoundingBox.empty.isEmpty)
XCTAssertTrue(BoundingBox(min: CGPoint(x: 5, y: 3), max: CGPoint(x: 4, y: 4)).isEmpty)
}

func testLowerAndUpperBounds() {
Expand All @@ -53,7 +58,7 @@ class BoundingBoxTests: XCTestCase {
XCTAssertEqual(box.lowerBoundOfDistance(to: p2), 0.0) // fully inside
XCTAssertEqual(box.lowerBoundOfDistance(to: p3), 1.0) // outside (straight horizontally)
XCTAssertEqual(box.lowerBoundOfDistance(to: p4), 2.0) // outside (straight vertically)
XCTAssertEqual(box.lowerBoundOfDistance(to: p5), 5.0) // outside (nearest bottom left corner)
XCTAssertEqual(box.lowerBoundOfDistance(to: p5), 5.0) // outside (nearest bottom left corner)

XCTAssertEqual(box.upperBoundOfDistance(to: p1), sqrt(2.0))
XCTAssertEqual(box.upperBoundOfDistance(to: p2), sqrt(2.5))
Expand Down
1 change: 1 addition & 0 deletions BezierKit/BezierKitTests/FlatnessTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class FlatnessTests: XCTestCase {
p3: CGPoint(x: 2, y: 4))
func testLineSegment() {
XCTAssertEqual(line.flatness, 0)
XCTAssertEqual(line.flatnessSquared, 0)
}

func testQuadraticBezierCurve() {
Expand Down
3 changes: 0 additions & 3 deletions BezierKit/Library/AugmentedGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ internal class PathLinkedListRepresentation {
}

private func createListFor(component: PathComponent) -> [Vertex] {
guard component.elementCount > 0 else {
return []
}
assert(component.startingPoint == component.endingPoint, "this method assumes component is closed!")
var elements: [Vertex] = [] // elements[i] is the first vertex of curves[i]
let firstPoint: CGPoint = component.startingPoint
Expand Down

0 comments on commit b34c0d1

Please sign in to comment.