@@ -187,7 +187,17 @@ TEST(TestLaserDetector, TestPointsInFootprintOutsideRange) {
187187 EXPECT_EQ (output, expected_output);
188188}
189189
190- TEST (TestLaserDetector, TestObstacleDetection) {
190+ struct ObstacleDetectionParams {
191+ int points{};
192+ bool detection{};
193+ };
194+
195+ class TestObstacleDetection : public ::testing::TestWithParam<std::pair<int , bool >> {};
196+
197+ TEST_P (TestObstacleDetection, DetectObstacleThresholds) {
198+ // Get params
199+ const auto & [points, detection] = GetParam ();
200+
191201 // Define laser options
192202 const LaserOptions laser_options{
193203 -0.6 , // angle_min
@@ -203,19 +213,21 @@ TEST(TestLaserDetector, TestObstacleDetection) {
203213 const double roi_min_angle{-0.4 };
204214 const double roi_max_angle{0.6 };
205215
206- // Define input data (num points)
207- const int input_obstacle{7 };
208- const int input_non_obstacle{2 };
209-
210216 // Create dut
211217 LaserDetector dut (laser_options, footprint_radius, min_points, roi_min_angle, roi_max_angle);
212218
213- // Detect obstacle
214- EXPECT_TRUE (dut.detect_obstacle (input_obstacle));
215-
216- // Detect non-obstacle
217- EXPECT_FALSE (dut.detect_obstacle (input_non_obstacle));
219+ // Assert obstacle detection
220+ EXPECT_EQ (dut.detect_obstacle (points), detection);
218221}
219222
223+ INSTANTIATE_TEST_SUITE_P (ObstacleThresholdCases, TestObstacleDetection,
224+ ::testing::Values (
225+ // below threshold
226+ std::pair{2 , false },
227+ // exactly at min_points (boundary)
228+ std::pair{5 , true },
229+ // above threshold
230+ std::pair{7 , true }));
231+
220232} // namespace test
221233} // namespace module_2
0 commit comments