Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stlastar.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class AStarSearch {
// routine once the search ends
void FreeUnusedNodes() {
for (auto n : m_NodeMap) {
if (!n->child) {
if (n != m_Start && !n->child) {
FreeNode(n);
}
}
Expand Down
21 changes: 21 additions & 0 deletions tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,25 @@ TEST_CASE("Reopen Node From Closed List When Cheaper Path Found") {
astar.EnsureMemoryFreed();
}

TEST_CASE("Start Node Equals Goal Node") {
AStarSearch<MapSearchNode> astar;
MapSearchNode start(1, 1);
MapSearchNode goal(1, 1);

astar.SetStartAndGoalStates(start, goal);

unsigned int state = astar.SearchStep();
CHECK(state == AStarSearch<MapSearchNode>::SEARCH_STATE_SUCCEEDED);

MapSearchNode* solStart = astar.GetSolutionStart();
REQUIRE(solStart != nullptr);
CHECK(solStart->x == 1);
CHECK(solStart->y == 1);
CHECK(astar.GetSolutionNext() == nullptr);
CHECK(astar.GetSolutionCost() == 0.0f);

astar.FreeSolutionNodes();
astar.EnsureMemoryFreed();
}


Loading