Tests the floor and ceiling functions in the tree.
()
| 627 | |
| 628 | |
| 629 | def test_floor_ceil() -> bool: |
| 630 | """Tests the floor and ceiling functions in the tree.""" |
| 631 | tree = RedBlackTree(0) |
| 632 | tree.insert(-16) |
| 633 | tree.insert(16) |
| 634 | tree.insert(8) |
| 635 | tree.insert(24) |
| 636 | tree.insert(20) |
| 637 | tree.insert(22) |
| 638 | tuples = [(-20, None, -16), (-10, -16, 0), (8, 8, 8), (50, 24, None)] |
| 639 | for val, floor, ceil in tuples: |
| 640 | if tree.floor(val) != floor or tree.ceil(val) != ceil: |
| 641 | return False |
| 642 | return True |
| 643 | |
| 644 | |
| 645 | def test_min_max() -> bool: |