-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor style changes, cleanup and added test for heap
- Loading branch information
1 parent
ad53707
commit 1fa33a9
Showing
4 changed files
with
34 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pathfinding3d.core.grid import Grid | ||
from pathfinding3d.core.heap import SimpleHeap | ||
|
||
|
||
def test_heap(): | ||
grid = Grid(width=10, height=10, depth=10) | ||
start = grid.node(0, 0, 0) | ||
open_list = SimpleHeap(start, grid) | ||
|
||
# Test pop | ||
assert open_list.pop_node() == start | ||
assert len(open_list) == 0 | ||
|
||
# Test push | ||
open_list.push_node(grid.node(1, 1, 1)) | ||
open_list.push_node(grid.node(1, 1, 2)) | ||
open_list.push_node(grid.node(1, 1, 3)) | ||
|
||
# Test removal and pop | ||
assert len(open_list) == 3 | ||
open_list.remove_node(grid.node(1, 1, 2), 0) | ||
assert len(open_list) == 3 | ||
|
||
assert open_list.pop_node() == grid.node(1, 1, 1) | ||
assert open_list.pop_node() == grid.node(1, 1, 3) | ||
assert len(open_list) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters