From fd89ca2e9e043be5de92a259a32e8e75b6f34707 Mon Sep 17 00:00:00 2001 From: go-sakayori Date: Mon, 13 May 2024 10:22:47 +0900 Subject: [PATCH] test: behavior path obstacle avoidance (#6972) * write test for behavior avoidance Signed-off-by: Go Sakayori * style(pre-commit): autofix --------- Signed-off-by: Go Sakayori Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .../test/test_utils.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/planning/behavior_path_avoidance_module/test/test_utils.cpp b/planning/behavior_path_avoidance_module/test/test_utils.cpp index 95488daa69cf8..1a114eef9f7f7 100644 --- a/planning/behavior_path_avoidance_module/test/test_utils.cpp +++ b/planning/behavior_path_avoidance_module/test/test_utils.cpp @@ -21,6 +21,7 @@ using behavior_path_planner::ObjectData; using behavior_path_planner::utils::avoidance::isOnRight; using behavior_path_planner::utils::avoidance::isSameDirectionShift; +using behavior_path_planner::utils::avoidance::isShiftNecessary; TEST(BehaviorPathPlanningAvoidanceUtilsTest, shiftLengthDirectionTest) { @@ -37,3 +38,19 @@ TEST(BehaviorPathPlanningAvoidanceUtilsTest, shiftLengthDirectionTest) ASSERT_TRUE(isSameDirectionShift(isOnRight(left_obj), positive_shift_length)); ASSERT_FALSE(isSameDirectionShift(isOnRight(left_obj), negative_shift_length)); } + +TEST(BehaviorPathPlanningAvoidanceUtilsTest, shiftNecessaryTest) +{ + ObjectData right_obj; + right_obj.direction = route_handler::Direction::RIGHT; + const double negative_shift_length = -1.0; + const double positive_shift_length = 1.0; + + ASSERT_TRUE(isShiftNecessary(isOnRight(right_obj), positive_shift_length)); + ASSERT_FALSE(isShiftNecessary(isOnRight(right_obj), negative_shift_length)); + + ObjectData left_obj; + left_obj.direction = route_handler::Direction::LEFT; + ASSERT_TRUE(isShiftNecessary(isOnRight(left_obj), negative_shift_length)); + ASSERT_FALSE(isShiftNecessary(isOnRight(left_obj), positive_shift_length)); +}