mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-18 22:16:02 +01:00
refactor(simulation): tidy the test mode code
The test manager is reached through simulation::test() instead of a global, the result cell is owned by a unique_ptr until the memory table takes it, the cell value is compared with a margin, strings are built with std::format and the --test settings moved to apply_test_mode_settings(). The driver's signal check is folded into UpdateSpeedPosition(), which updates a speed table entry and reports a signal at stop the head of the train just passed. The test.* keys are listed with the other settings at the start of the log.
This commit is contained in:
5
EU07.cpp
5
EU07.cpp
@@ -23,6 +23,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others
|
||||
#include "utilities/Globals.h"
|
||||
#include "utilities/Logs.h"
|
||||
#include <cstdlib>
|
||||
#include <format>
|
||||
#ifdef WITHDUMPGEN
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
@@ -150,7 +151,7 @@ int main(int argc, char *argv[])
|
||||
#ifdef _WIN32
|
||||
catch (std::runtime_error const &Error)
|
||||
{
|
||||
ErrorLog("Critical error: " + std::string(Error.what()));
|
||||
ErrorLog(std::format("Critical error: {}", Error.what()));
|
||||
// in test mode nobody is there to close the box, the exit code tells of the error
|
||||
if (false == Global.test.enabled)
|
||||
{
|
||||
@@ -167,5 +168,5 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
// skip destructors, there are ordering errors which causes segfaults
|
||||
// a test run (--test) says its result in the exit code
|
||||
std::_Exit(Global.test.enabled ? simulation::Test.exit_code() : 0);
|
||||
std::_Exit(Global.test.enabled ? simulation::test().exit_code() : 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user