Slice 2 (Phase 1a) of the M9 Monterey retarget. Converts all pure Core suites (argv builders, CGATS/CUPS/profcheck/gamut-mesh parsers, colour math, file/artefact helpers, classifiers) to XCTestCase, and adds the shared assertAsyncThrows helper for the async-throws sites that Slice 3 will convert. Deferred to Slice 3 (kept on Swift Testing in mixed files): ProcessManagerTests, ArgyllRunner*Tests, ProcessRunSupportTests, store/UI suites, and the runner suites embedded in TargenTests / PrinttargTests / ProcessManagerTests. Also qualifies six bare `throw .case` expressions in CGATSParser with CGATSParseError — they only compiled under typed throws, which Slice 1 demoted to untyped `throws`; without this the ICCeryCore target fails to build and no test gate can run. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
96 lines
2.8 KiB
Swift
96 lines
2.8 KiB
Swift
import Foundation
|
|
import XCTest
|
|
@testable import ICCeryCore
|
|
|
|
final class DriftAlertTests: XCTestCase {
|
|
|
|
func testNotEnough() {
|
|
let records = [
|
|
record(avg: 4.0, at: 1000)
|
|
]
|
|
XCTAssertNil(DriftAlert.compute(from: records))
|
|
}
|
|
|
|
func testOneHourApart() {
|
|
let records = [
|
|
record(avg: 4.0, at: 1000),
|
|
record(avg: 5.0, at: 4600)
|
|
]
|
|
XCTAssertNotNil(DriftAlert.compute(from: records))
|
|
}
|
|
|
|
func testSameDayUnderHour() {
|
|
let records = [
|
|
record(avg: 4.0, at: 1000),
|
|
record(avg: 5.0, at: 2000)
|
|
]
|
|
XCTAssertNil(DriftAlert.compute(from: records))
|
|
}
|
|
|
|
func testDistinctDays() {
|
|
let day1 = record(avg: 4.0, at: 0)
|
|
let day2 = record(avg: 5.0, at: 86400 + 1000)
|
|
XCTAssertNotNil(DriftAlert.compute(from: [day1, day2]))
|
|
}
|
|
|
|
func testNonPoor() {
|
|
let records = [
|
|
record(avg: 1.0, at: 0),
|
|
record(avg: 1.5, at: 86400)
|
|
]
|
|
XCTAssertNil(DriftAlert.compute(from: records))
|
|
}
|
|
|
|
func testNonPoorBreaksRun() {
|
|
let records = [
|
|
record(avg: 4.0, at: 0), // poor
|
|
record(avg: 4.5, at: 86400), // poor, far apart
|
|
record(avg: 1.0, at: 90000), // good — breaks the run
|
|
record(avg: 4.0, at: 92000) // poor, recent but close to previous poor
|
|
]
|
|
XCTAssertNil(DriftAlert.compute(from: records))
|
|
}
|
|
|
|
func testOnlySuffixRun() {
|
|
let records = [
|
|
record(avg: 4.0, at: 0), // poor
|
|
record(avg: 4.5, at: 18000), // poor, > 1h from first
|
|
record(avg: 1.0, at: 20000), // good — breaks the run
|
|
record(avg: 4.0, at: 25000), // poor
|
|
record(avg: 4.5, at: 26000) // poor, < 1h and same day
|
|
]
|
|
XCTAssertNil(DriftAlert.compute(from: records))
|
|
}
|
|
|
|
func testSuffixRunAlerts() {
|
|
let records = [
|
|
record(avg: 1.0, at: 0), // good
|
|
record(avg: 4.0, at: 1000), // poor
|
|
record(avg: 4.5, at: 4600) // poor, 1h after previous
|
|
]
|
|
XCTAssertNotNil(DriftAlert.compute(from: records))
|
|
}
|
|
|
|
func testSingleFinalPoor() {
|
|
let records = [
|
|
record(avg: 1.0, at: 0),
|
|
record(avg: 4.0, at: 86400)
|
|
]
|
|
XCTAssertNil(DriftAlert.compute(from: records))
|
|
}
|
|
|
|
private func record(avg: Double, at offset: TimeInterval) -> VerificationRecord {
|
|
VerificationRecord(
|
|
id: "vr-\(Int(offset))",
|
|
profileName: "p",
|
|
printerName: "",
|
|
avgDE: avg,
|
|
maxDE: avg,
|
|
rmsDE: avg,
|
|
patchCount: 1,
|
|
status: VerificationStatus.from(avgDE: avg),
|
|
timestamp: Date(timeIntervalSince1970: offset)
|
|
)
|
|
}
|
|
}
|