Test the insert() and delete() method of the tree, verifying the insertion and removal of elements, and the balancing of the tree.
()
| 605 | |
| 606 | |
| 607 | def test_insert_delete() -> bool: |
| 608 | """Test the insert() and delete() method of the tree, verifying the |
| 609 | insertion and removal of elements, and the balancing of the tree. |
| 610 | """ |
| 611 | tree = RedBlackTree(0) |
| 612 | tree = tree.insert(-12) |
| 613 | tree = tree.insert(8) |
| 614 | tree = tree.insert(-8) |
| 615 | tree = tree.insert(15) |
| 616 | tree = tree.insert(4) |
| 617 | tree = tree.insert(12) |
| 618 | tree = tree.insert(10) |
| 619 | tree = tree.insert(9) |
| 620 | tree = tree.insert(11) |
| 621 | tree = tree.remove(15) |
| 622 | tree = tree.remove(-12) |
| 623 | tree = tree.remove(9) |
| 624 | if not tree.check_color_properties(): |
| 625 | return False |
| 626 | return list(tree.inorder_traverse()) == [-8, 0, 4, 8, 10, 11, 12] |
| 627 | |
| 628 | |
| 629 | def test_floor_ceil() -> bool: |
no test coverage detected