Skip to content

Commit

Permalink
include more testing
Browse files Browse the repository at this point in the history
Signed-off-by: stevedan <stevedan.o.omodolor@gmail.com>
  • Loading branch information
stevedanomodolor committed Nov 19, 2024
1 parent 18ef671 commit a573dc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion nav2_smac_planner/src/a_star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void AStarAlgorithm<NodeT>::setGoal(
// we just have to check whether the x and y are the same because the dim3 is not used
// in the computation of the obstacle heuristic
if (!_search_info.cache_obstacle_heuristic ||
goals_coordinates != _goals_coordinates)
(goals_coordinates != _goals_coordinates))

Check warning on line 265 in nav2_smac_planner/src/a_star.cpp

View check run for this annotation

Codecov / codecov/patch

nav2_smac_planner/src/a_star.cpp#L265

Added line #L265 was not covered by tests
{
if (!_start) {
throw std::runtime_error("Start must be set before goal.");
Expand Down
12 changes: 10 additions & 2 deletions nav2_smac_planner/test/test_a_star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,17 @@ TEST(AStarTest, test_se2_single_pose_path)
};
// functional case testing
a_star.setCollisionChecker(checker.get());
nav2_smac_planner::NodeHybrid::CoordinateVector path;

// test with no goals set nor start
EXPECT_THROW(
a_star.createPath(
path, num_it, tolerance,
dummy_cancel_checker), std::runtime_error);

a_star.setStart(10u, 10u, 0u);
// Goal is one costmap cell away
a_star.setGoal(12u, 10u, 0u);
nav2_smac_planner::NodeHybrid::CoordinateVector path;
EXPECT_TRUE(a_star.createPath(path, num_it, tolerance, dummy_cancel_checker));

// Check that the path is length one
Expand Down Expand Up @@ -491,9 +498,10 @@ TEST(AStarTest, test_goal_heading_mode)
// UNKNOWN goal heading mode
a_star.setCollisionChecker(checker.get());
a_star.setStart(10u, 10u, 0u);

EXPECT_THROW(
a_star.setGoal(
80u, 80u, 40u,
80u, 80u, 10u,
nav2_smac_planner::GoalHeadingMode::UNKNOWN), std::runtime_error);
}

Expand Down

0 comments on commit a573dc3

Please sign in to comment.