Test operations on empty tree.
()
| 18 | |
| 19 | |
| 20 | def test_empty_tree(): |
| 21 | """Test operations on empty tree.""" |
| 22 | print("Testing empty tree...") |
| 23 | tree = bplustree_c.BPlusTree(capacity=4) |
| 24 | |
| 25 | assert len(tree) == 0, f"Empty tree should have length 0, got {len(tree)}" |
| 26 | |
| 27 | # Test KeyError on empty tree |
| 28 | try: |
| 29 | _ = tree[1] |
| 30 | assert False, "Should raise KeyError on empty tree" |
| 31 | except KeyError: |
| 32 | pass |
| 33 | |
| 34 | # Test empty iteration |
| 35 | keys = list(tree.keys()) |
| 36 | assert keys == [], f"Empty tree keys should be [], got {keys}" |
| 37 | |
| 38 | items = list(tree.items()) |
| 39 | assert items == [], f"Empty tree items should be [], got {items}" |
| 40 | |
| 41 | print("✓ Empty tree tests passed") |
| 42 | |
| 43 | |
| 44 | def test_single_item(): |