Files
iccery-v2-mac/Tests/ICCeryCoreTests/ProfcheckParserTests.swift
gronodandDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> 150d094632 test(m9): convert pure core test suites from Swift Testing to XCTest
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>
2026-09-11 20:43:42 +01:00

66 lines
2.2 KiB
Swift

import Foundation
import XCTest
@testable import ICCeryCore
final class ProfcheckParserTests: XCTestCase {
func testJsonReport() {
let output = """
No of test patches = 52
{"event": "report", "peak_de2000": 2.41, "avg_de2000": 0.85, "rms": 1.02}
Profile check complete, errors(CIEDE2000): max. = 9.99, avg. = 9.99, RMS = 9.99
"""
let report = ProfcheckParser.parse(output)
XCTAssertEqual(report.isValid, true)
XCTAssertEqual(report.patchCount, 52)
XCTAssertEqual(report.avgDE, 0.85)
XCTAssertEqual(report.maxDE, 2.41)
XCTAssertEqual(report.rmsDE, 1.02)
XCTAssertEqual(report.status, .excellent)
}
func testLegacyText() {
let output = """
No of test patches = 120
Profile check complete, errors(CIEDE2000): max. = 3.50, avg. = 1.80, RMS = 0.95
"""
let report = ProfcheckParser.parse(output)
XCTAssertEqual(report.isValid, true)
XCTAssertEqual(report.patchCount, 120)
XCTAssertEqual(report.avgDE, 1.80)
XCTAssertEqual(report.maxDE, 3.50)
XCTAssertEqual(report.rmsDE, 0.95)
XCTAssertEqual(report.status, .good)
}
func testRegexFallback() {
let output = """
No of test patches = 10
avg = 4.25
max = 6.10
rms = 2.30
"""
let report = ProfcheckParser.parse(output)
XCTAssertEqual(report.isValid, true)
XCTAssertEqual(report.avgDE, 4.25)
XCTAssertEqual(report.maxDE, 6.10)
XCTAssertEqual(report.rmsDE, 2.30)
XCTAssertEqual(report.status, .poor)
}
func testUnparseable() {
let output = "some random text without metrics"
let report = ProfcheckParser.parse(output)
XCTAssertEqual(report.isValid, false)
XCTAssertNotNil(report.warning)
XCTAssertNil(report.avgDE)
}
func testStatusBands() {
XCTAssertEqual(VerificationStatus.from(avgDE: 0.5), .excellent)
XCTAssertEqual(VerificationStatus.from(avgDE: 1.5), .good)
XCTAssertEqual(VerificationStatus.from(avgDE: 2.5), .acceptable)
XCTAssertEqual(VerificationStatus.from(avgDE: 4.0), .poor)
}
}