Skip to content

Commit

Permalink
Merge pull request #93 from endlessm/T35520-test-orphans
Browse files Browse the repository at this point in the history
test_category_factory: Free Block nodes
  • Loading branch information
wjt authored Jun 28, 2024
2 parents d60c3bd + 1f0d701 commit d2f305f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/test_category_factory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ extends GutTest
## Tests for CategoryFactory


func free_block_list(blocks: Array[Block]):
var block: Block = blocks.pop_back()
while block != null:
block.free()
block = blocks.pop_back()


func get_category_names(categories: Array[BlockCategory]) -> Array[String]:
var names: Array[String] = []
for category in categories:
Expand All @@ -11,12 +18,15 @@ func get_category_names(categories: Array[BlockCategory]) -> Array[String]:

func get_class_category_names(_class_name: String) -> Array[String]:
var blocks: Array[Block] = CategoryFactory.get_inherited_blocks(_class_name)
return get_category_names(CategoryFactory.get_categories(blocks))
var names: Array[String] = get_category_names(CategoryFactory.get_categories(blocks))
free_block_list(blocks)
return names


func test_general_category_names():
var blocks: Array[Block] = CategoryFactory.get_general_blocks()
var names: Array[String] = get_category_names(CategoryFactory.get_categories(blocks))
free_block_list(blocks)
assert_eq(
names,
[
Expand Down

0 comments on commit d2f305f

Please sign in to comment.