Files
iccery-v2-mac/Tests/ICCeryCoreTests/PrintcalArgsTests.swift
gronodandDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> da602e2775 refactor(args): finish shared option helpers (#86)
Adopt ArgsBuilder helpers across the remaining argument generators while
preserving byte-identical argv and exact flag ordering:

- TargenArgs: optionUnlessApprox for -N/-V/-p, optionIfNonEmpty for -c,
  flag for -G, option for -A.
- PrinttargArgs: flag for -r, optionIfNonEmpty for -d and the dynamic
  -K/-I calibration value (CAL_ protection retained).
- PrintcalArgs: flag for -I/-z, optionIfNonEmpty for -a.
- ColprofArgs left explicit: FWA and "none" viewing-condition branches
  cannot be represented by the helpers without changing argv.

New ArgsBuilderTests cover nil/present/empty/whitespace/trim, epsilon
boundaries, POSIX formatting, and flag handling. Added whitespace-only
option cases for targen -c, printtarg -d/-K/-I, and printcal -a, plus
chartread row decode and unkeyed XYZ/Lab wire-encoding tests.

Refs #86

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-09-11 12:17:52 +01:00

83 lines
2.5 KiB
Swift

import Foundation
import Testing
@testable import ICCeryCore
@Suite("PrintcalArgs")
struct PrintcalArgsTests {
private let tmp = URL(fileURLWithPath: "/tmp/out.cal")
@Test("Default printcal argv")
func defaults() throws {
let config = PrintcalConfig(
ti3Basename: "CAL_demo",
outputURL: tmp
)
let args = try PrintcalArgs.build(config: config)
#expect(args == ["-v", "-e", "-o", "/tmp/out.cal", "CAL_demo"])
}
@Test("All options and channel limits")
func allOptions() throws {
let config = PrintcalConfig(
ti3Basename: "demo",
outputURL: tmp,
noInkLimit: true,
verify: true,
previousCalPath: "/tmp/old.cal",
totalInkLimit: 280,
channelLimits: [
PrintcalChannelLimit(channel: "C", percent: 95),
PrintcalChannelLimit(channel: "M", percent: 90)
]
)
let args = try PrintcalArgs.build(config: config)
#expect(args == [
"-v", "-e",
"-I", "-z",
"-a", "/tmp/old.cal",
"-m", "280.0",
"-xC", "95.0",
"-xM", "90.0",
"-o", "/tmp/out.cal",
"CAL_demo"
])
}
@Test("Whitespace-only previous calibration path emits no -a")
func whitespacePreviousCal() throws {
let config = PrintcalConfig(
ti3Basename: "demo",
outputURL: tmp,
previousCalPath: " \n\t "
)
let args = try PrintcalArgs.build(config: config)
#expect(!args.contains("-a"))
#expect(args == ["-v", "-e", "-o", "/tmp/out.cal", "CAL_demo"])
}
@Test("Previous calibration path is trimmed before emission")
func previousCalTrimmed() throws {
let config = PrintcalConfig(
ti3Basename: "demo",
outputURL: tmp,
previousCalPath: " /tmp/old.cal "
)
let args = try PrintcalArgs.build(config: config)
#expect(args[args.firstIndex(of: "-a")! + 1] == "/tmp/old.cal")
}
@Test("Rejects invalid per-channel limit")
func rejectsBadChannelLimit() {
let config = PrintcalConfig(
ti3Basename: "demo",
outputURL: tmp,
channelLimits: [PrintcalChannelLimit(channel: "K", percent: 150)]
)
#expect(throws: (any Error).self) {
_ = try PrintcalArgs.build(config: config)
}
}
}