Fix ConstraintMathTests: unwrap the optional new height
Some checks failed
CI / Build and test (ad-hoc signing) (push) Has been cancelled
Some checks failed
CI / Build and test (ad-hoc signing) (push) Has been cancelled
XCTAssertEqual with accuracy needs a non-optional value. Unwrap the CGFloat? result of ConstraintMath.newHeight with XCTUnwrap. All 31 tests pass with xcodebuild test.
This commit is contained in:
@@ -15,9 +15,9 @@ final class ConstraintMathTests: XCTestCase {
|
|||||||
|
|
||||||
// A window with the bottom below the limit gets a new height. The top stays
|
// A window with the bottom below the limit gets a new height. The top stays
|
||||||
// fixed. The top is maxY = 20 + 600 = 620. The new height is 620 - 30 = 590.
|
// fixed. The top is maxY = 20 + 600 = 620. The new height is 620 - 30 = 590.
|
||||||
func testWindowBottomBelowLimitReturnsNewHeight() {
|
func testWindowBottomBelowLimitReturnsNewHeight() throws {
|
||||||
let window = CGRect(x: 0, y: 20, width: 800, height: 600)
|
let window = CGRect(x: 0, y: 20, width: 800, height: 600)
|
||||||
let height = ConstraintMath.newHeight(windowCocoa: window, limitY: 30)
|
let height = try XCTUnwrap(ConstraintMath.newHeight(windowCocoa: window, limitY: 30))
|
||||||
XCTAssertEqual(height, 590, accuracy: 0.001)
|
XCTAssertEqual(height, 590, accuracy: 0.001)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,10 +44,10 @@ final class ConstraintMathTests: XCTestCase {
|
|||||||
// The window bottom (-900) is below the limit. The top is -300.
|
// The window bottom (-900) is below the limit. The top is -300.
|
||||||
// The top is not below (limitY - 100 = -870), so the service corrects the
|
// The top is not below (limitY - 100 = -870), so the service corrects the
|
||||||
// window. The new height is top - limitY = -300 - (-770) = 470.
|
// window. The new height is top - limitY = -300 - (-770) = 470.
|
||||||
func testWindowOnSecondScreenGetsNewHeight() {
|
func testWindowOnSecondScreenGetsNewHeight() throws {
|
||||||
let window = CGRect(x: 0, y: -900, width: 800, height: 600) // top = -300
|
let window = CGRect(x: 0, y: -900, width: 800, height: 600) // top = -300
|
||||||
XCTAssertFalse(ConstraintMath.isIntentionalMoveDown(windowTopCocoa: window.maxY, limitY: -770))
|
XCTAssertFalse(ConstraintMath.isIntentionalMoveDown(windowTopCocoa: window.maxY, limitY: -770))
|
||||||
let height = ConstraintMath.newHeight(windowCocoa: window, limitY: -770)
|
let height = try XCTUnwrap(ConstraintMath.newHeight(windowCocoa: window, limitY: -770))
|
||||||
XCTAssertEqual(height, 470, accuracy: 0.001)
|
XCTAssertEqual(height, 470, accuracy: 0.001)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user