18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 23:17:56 +01:00
Files
maszyna/tests/unit/test_ai_hints.cpp
T
Hirek 5879c228dc refactor(physics): what the rest of the simulator only reads of a vehicle is private to it
53 fields of physics::Vehicle that only the vehicle itself writes, and the rest
of the simulator reads, are private, with a query each, named as the field was
(Vmax(), TotalMass(), Ft(), nrot(), NAxles(), PhysicActivation(), ...): the
compiler now keeps the cab, the AI, the scenery, the renderer and the tests from
changing what the definition gives or the physics works out. The fields were
picked by what is never written outside the class, of plain types, with no
other member of the same name to confuse; inside the class they keep their
meaning under camelCase names. The one place outside that cleared a flag of
the AI through a reference does it through ClearAIFlag().

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:17:56 +01:00

32 lines
1.0 KiB
C++

#include "stdafx.h"
#include "doctest.h"
#include "vehicle.h"
using test::definition;
using test::vehicle;
// the hints for the AI driver from the AI section of the .fiz
TEST_CASE("ai hints: without the AI section the pantographs follow the built-in logic") {
vehicle wagon{definition::load("wagon")};
CHECK(wagon->AIHintPantstate() == 0);
CHECK(wagon->AIHintShuntPantstate() == 0);
CHECK(wagon->AIHintPantUpIfIdle);
}
TEST_CASE("ai hints: the suggested pantograph setup for shunting is read apart from the one for train mode") {
// eu07/maszyna#461: so the ET41 doesn't shunt with all of its four pantographs up
vehicle shunting{definition::load("wagon").set("AI", "Pantstate", 1).set("AI", "ShuntPantstate", 2)};
CHECK(shunting->AIHintPantstate() == 1);
CHECK(shunting->AIHintShuntPantstate() == 2);
}
TEST_CASE("ai hints: a .fiz with the setup for train mode only has none for shunting") {
vehicle train{definition::load("wagon").set("AI", "Pantstate", 3)};
CHECK(train->AIHintPantstate() == 3);
CHECK(train->AIHintShuntPantstate() == 0);
}