mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 21:07:06 +01:00
f65411a668
The speed along the couplers, the location, the offsets from the track axis,
the accelerations, the distance counter and the distance moved since the last
check, the flat of the wheels and the truck hunting, the distance of the
derailment check, whether the vehicle is inside a consist and in the coupler
model, the analog demand of the integrated controller and the flow of the pipe
stabiliser are private to physics::Vehicle. TDynamicObject places and moves the
vehicle, the scenery puts road vehicles on their way and the contacts push them
through the operations (SetV(), SetLoc(), SetOffsetTrackH(), ...), and the
jolts of the track are ShakeVertically() and ShakeHorizontally(), the same
additions as before.
No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
#include "golden.h"
|
|
#include "vehicle.h"
|
|
|
|
// the invariants every golden trace checks (invariants.h) catch a vehicle in a state the simulation must
|
|
// never reach, once each, naming the time and the last event
|
|
|
|
using test::definition;
|
|
using test::vehicle;
|
|
|
|
TEST_CASE("invariants: a vehicle in an impossible state, reported once with its time and the last event") {
|
|
vehicle eu07{definition::fiz("4e_v1/4e")};
|
|
test::trace trace{"invariants/self test", test::channels::brakes()};
|
|
trace.sample(0.0, eu07.physics());
|
|
CHECK(trace.violations().empty());
|
|
|
|
trace.mark("overfilled");
|
|
eu07->brakes.cylinderPressure = 50.0;
|
|
trace.sample(0.01, eu07.physics());
|
|
trace.sample(0.02, eu07.physics());
|
|
REQUIRE(trace.violations().size() == 1);
|
|
auto const &violation{trace.violations().front()};
|
|
CHECK(violation.find("brake cylinders") != std::string::npos);
|
|
CHECK(violation.find("at 0.010 s") != std::string::npos);
|
|
CHECK(violation.find("after \"overfilled\"") != std::string::npos);
|
|
CHECK(violation.find("BrakePress=50") != std::string::npos);
|
|
|
|
eu07->brakes.cylinderPressure = 0.0;
|
|
eu07->SetV(std::nan(""));
|
|
trace.sample(0.03, eu07.physics());
|
|
CHECK(trace.violations().size() > 1);
|
|
CHECK(trace.violations()[1].find("every value a number") != std::string::npos);
|
|
}
|