|
|
@@ -12,6 +12,9 @@ class CalibrationsTests: XCTestCase, Injectable {
|
|
|
}
|
|
|
|
|
|
func testCreateSimpleCalibration() {
|
|
|
+ // restore state so each test is independent
|
|
|
+ calibrationService.removeAllCalibrations()
|
|
|
+
|
|
|
let calibration = Calibration(x: 100.0, y: 102.0)
|
|
|
calibrationService.addCalibration(calibration)
|
|
|
|
|
|
@@ -25,29 +28,22 @@ class CalibrationsTests: XCTestCase, Injectable {
|
|
|
}
|
|
|
|
|
|
func testCreateMultipleCalibration() {
|
|
|
+ // restore state so each test is independent
|
|
|
+ calibrationService.removeAllCalibrations()
|
|
|
+
|
|
|
let calibration = Calibration(x: 100.0, y: 120)
|
|
|
calibrationService.addCalibration(calibration)
|
|
|
|
|
|
let calibration2 = Calibration(x: 120.0, y: 130.0)
|
|
|
calibrationService.addCalibration(calibration2)
|
|
|
- // The original 4 XCTAsserts() below fail on the initial run,
|
|
|
- // but will work on subsequent runs.
|
|
|
- // Should fix this stuff to not be stateful so that the
|
|
|
- // same results are obtained on each run.
|
|
|
- // Temporary fix comment out original and use XCTAssertEqual
|
|
|
- // which allows an accuracy parameter
|
|
|
- // XCTAssertTrue(calibrationService.slope == 0.8)
|
|
|
- // XCTAssertTrue(calibrationService.intercept == 37)
|
|
|
- // XCTAssertTrue(calibrationService.calibrate(value: 80) == 101)
|
|
|
-
|
|
|
- XCTAssertEqual(calibrationService.slope, 0.95, accuracy: 0.0001)
|
|
|
- XCTAssertEqual(calibrationService.intercept, 16, accuracy: 0.0001)
|
|
|
- XCTAssertEqual(calibrationService.calibrate(value: 80), 92, accuracy: 0.0001)
|
|
|
+
|
|
|
+ XCTAssertEqual(calibrationService.slope, 0.8, accuracy: 0.0001)
|
|
|
+ XCTAssertEqual(calibrationService.intercept, 37, accuracy: 0.0001)
|
|
|
+ XCTAssertEqual(calibrationService.calibrate(value: 80), 101, accuracy: 0.0001)
|
|
|
|
|
|
calibrationService.removeLast()
|
|
|
|
|
|
- // XCTAssertTrue(calibrationService.calibrations.count == 1)
|
|
|
- XCTAssertEqual(calibrationService.calibrations.count, 2)
|
|
|
+ XCTAssertTrue(calibrationService.calibrations.count == 1)
|
|
|
|
|
|
calibrationService.removeAllCalibrations()
|
|
|
XCTAssertTrue(calibrationService.calibrations.isEmpty)
|