18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-15 16:24:10 +01:00

test: reach the mover by reference in the brake handle lambdas (Sonar S2259)

The lambdas of the St113 EP brake and the MHZ buttons tests called the mover through test::vehicle::operator->(), which the analyser takes as possibly null; they capture a reference from mover() instead.
This commit is contained in:
jerrrrycho
2026-11-08 19:30:46 +01:00
parent 200d3ae73b
commit 7ba478aea9

View File

@@ -131,9 +131,10 @@ TEST_CASE("brake handles: the overload and the high pressure buttons of the MHZ
real.record(trace);
REQUIRE(real->Handle != nullptr);
auto &handle{*real->Handle};
auto const at{[&trace, &real](std::string const &Event, double Position, double Seconds) {
auto &mover{real.mover()};
auto const at{[&trace, &real, &mover](std::string const &Event, double Position, double Seconds) {
trace.mark(Event);
real->BrakeLevelSet(Position);
mover.BrakeLevelSet(Position);
test::drive(test::driving(real), {}, Seconds);
}};
at("running", handle.GetPos(bh_RP), 60.0);
@@ -196,8 +197,9 @@ TEST_CASE("brake handles: the positions of the Knorr St113 EP brake") {
auto &cab{unit[0]};
REQUIRE(cab->Handle != nullptr);
auto &handle{*cab->Handle};
auto const ep_at{[&unit, &cab, &handle](double Position) {
cab->BrakeLevelSet(Position);
auto &mover{cab.mover()};
auto const ep_at{[&unit, &mover, &handle](double Position) {
mover.BrakeLevelSet(Position);
unit.run(0.1);
return handle.GetEP();
}};