From 7ba478aea96bc52d59e3610fa077115b329966ec Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sun, 8 Nov 2026 19:30:46 +0100 Subject: [PATCH] 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. --- tests/unit/test_brake_handles.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_brake_handles.cpp b/tests/unit/test_brake_handles.cpp index 1490e43d..eeecac75 100644 --- a/tests/unit/test_brake_handles.cpp +++ b/tests/unit/test_brake_handles.cpp @@ -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(); }};