Tests the three different tree chaining functions.
()
| 671 | |
| 672 | |
| 673 | def test_tree_chaining() -> bool: |
| 674 | """Tests the three different tree chaining functions.""" |
| 675 | tree = RedBlackTree(0) |
| 676 | tree = tree.insert(-16).insert(16).insert(8).insert(24).insert(20).insert(22) |
| 677 | if list(tree.inorder_traverse()) != [-16, 0, 8, 16, 20, 22, 24]: |
| 678 | return False |
| 679 | if list(tree.preorder_traverse()) != [0, -16, 16, 8, 22, 20, 24]: |
| 680 | return False |
| 681 | return list(tree.postorder_traverse()) == [-16, 8, 20, 24, 22, 16, 0] |
| 682 | |
| 683 | |
| 684 | def print_results(msg: str, passes: bool) -> None: |
no test coverage detected