From 211c84c85bdb7e5d8cf81947ef3f7dd34767087f Mon Sep 17 00:00:00 2001 From: bresch Date: Mon, 4 Jan 2021 11:18:17 +0100 Subject: [PATCH] Rng finder unit test: cover "un-stuck" logic --- test/test_SensorRangeFinder.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/test_SensorRangeFinder.cpp b/test/test_SensorRangeFinder.cpp index aaa8029bf6..901af5fd09 100644 --- a/test/test_SensorRangeFinder.cpp +++ b/test/test_SensorRangeFinder.cpp @@ -233,6 +233,19 @@ TEST_F(SensorRangeFinderTest, rangeStuck) // because the sensor is "stuck" EXPECT_FALSE(_range_finder.isDataHealthy()); EXPECT_FALSE(_range_finder.isHealthy()); + + // BUT WHEN: we continue to send samples but with changing distance + for (int i = 0; i < 2; i++) { + new_sample.rng += 1.f; + _range_finder.setSample(new_sample); + _range_finder.runChecks(new_sample.time_us, attitude); + new_sample.time_us += dt; + } + + // THEN: the data should be marked as healthy + // because the sensor is not "stuck" anymore + EXPECT_TRUE(_range_finder.isDataHealthy()); + EXPECT_TRUE(_range_finder.isHealthy()); } TEST_F(SensorRangeFinderTest, qualityHysteresis)