18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-04 23:45:17 +01:00

Merge staging into feat/simulation-snapshot

One conflict in physics/vehicle.h: #547 added noteDerailment() where this branch added
struct snapshot_members; both are kept.
This commit is contained in:
jerrrrycho
2026-12-01 17:30:53 +01:00
80 changed files with 3404 additions and 233 deletions
+20
View File
@@ -55,6 +55,7 @@ std::string_view to_string(test_result const Result)
case timeout: return "timeout";
case standstill: return "standstill";
case error: return "error";
case derailment: return "derailment";
}
return "unknown";
}
@@ -157,4 +158,23 @@ std::optional<test_verdict> evaluate_frame(test_progress &Progress, test_frame c
return std::nullopt;
}
std::optional<test_verdict> evaluate_derailment(test_progress &Progress, bool const Tested, std::string_view const Description, test_limits const &Limits)
{
if (false == Tested)
return std::nullopt;
if (Limits.fail_on_derailment)
return test_verdict{test_result::derailment, std::string(Description)};
if (Progress.derailments++ == 0)
Progress.firstderailment = Description;
return std::nullopt;
}
std::string verdict_reason(test_verdict const &Verdict, test_progress const &Progress)
{
if (Verdict.result == test_result::derailment || Progress.derailments <= 0)
return Verdict.reason;
return std::format("{} [derailed: {}{}]", Verdict.reason, Progress.firstderailment,
Progress.derailments > 1 ? std::format(", and {} more", Progress.derailments - 1) : std::string());
}
} // namespace simulation