Harden planning test suite with realistic fixtures and output sanity checks
Adds messy/realistic data factories to TestFixtures, new PlannerOutputSanityTests, and updates all scenario planner tests with improved coverage and assertions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -278,15 +278,14 @@ struct TravelIntegrity_EngineGateTests {
|
||||
let engine = TripPlanningEngine()
|
||||
let result = engine.planItineraries(request: request)
|
||||
|
||||
if case .success(let options) = result {
|
||||
for (i, option) in options.enumerated() {
|
||||
#expect(option.isValid,
|
||||
"Option \(i) has \(option.stops.count) stops but \(option.travelSegments.count) segments — INVALID")
|
||||
// Double-check the math
|
||||
if option.stops.count > 1 {
|
||||
#expect(option.travelSegments.count == option.stops.count - 1,
|
||||
"Option \(i): \(option.stops.count) stops must have \(option.stops.count - 1) segments, got \(option.travelSegments.count)")
|
||||
}
|
||||
guard case .success(let options) = result else { Issue.record("Expected .success, got \(result)"); return }
|
||||
for (i, option) in options.enumerated() {
|
||||
#expect(option.isValid,
|
||||
"Option \(i) has \(option.stops.count) stops but \(option.travelSegments.count) segments — INVALID")
|
||||
// Double-check the math
|
||||
if option.stops.count > 1 {
|
||||
#expect(option.travelSegments.count == option.stops.count - 1,
|
||||
"Option \(i): \(option.stops.count) stops must have \(option.stops.count - 1) segments, got \(option.travelSegments.count)")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -624,19 +623,18 @@ struct TravelIntegrity_EdgeCaseTests {
|
||||
let engine = TripPlanningEngine()
|
||||
let result = engine.planItineraries(request: request)
|
||||
|
||||
if case .success(let options) = result {
|
||||
for option in options {
|
||||
for i in 0..<option.travelSegments.count {
|
||||
let segment = option.travelSegments[i]
|
||||
let fromStop = option.stops[i]
|
||||
let toStop = option.stops[i + 1]
|
||||
guard case .success(let options) = result else { Issue.record("Expected .success, got \(result)"); return }
|
||||
for option in options {
|
||||
for i in 0..<option.travelSegments.count {
|
||||
let segment = option.travelSegments[i]
|
||||
let fromStop = option.stops[i]
|
||||
let toStop = option.stops[i + 1]
|
||||
|
||||
// Segment endpoints should match stop cities
|
||||
#expect(segment.fromLocation.name == fromStop.city,
|
||||
"Segment \(i) from '\(segment.fromLocation.name)' should match stop '\(fromStop.city)'")
|
||||
#expect(segment.toLocation.name == toStop.city,
|
||||
"Segment \(i) to '\(segment.toLocation.name)' should match stop '\(toStop.city)'")
|
||||
}
|
||||
// Segment endpoints should match stop cities
|
||||
#expect(segment.fromLocation.name == fromStop.city,
|
||||
"Segment \(i) from '\(segment.fromLocation.name)' should match stop '\(fromStop.city)'")
|
||||
#expect(segment.toLocation.name == toStop.city,
|
||||
"Segment \(i) to '\(segment.toLocation.name)' should match stop '\(toStop.city)'")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user