Test splitting a branch node
(self)
| 538 | assert branch.find_child_index(35) == 3 # >= 30 |
| 539 | |
| 540 | def test_branch_node_split(self): |
| 541 | """Test splitting a branch node""" |
| 542 | branch = BranchNode(capacity=4) |
| 543 | branch.keys = [10, 20, 30, 40] |
| 544 | |
| 545 | # Create dummy children (one more than keys) |
| 546 | branch.children = [LeafNode(4) for _ in range(5)] |
| 547 | |
| 548 | # Split the branch |
| 549 | new_branch, separator = branch.split() |
| 550 | |
| 551 | # Check the split results |
| 552 | assert separator == 30 # Middle key should be promoted (keys[2]) |
| 553 | assert branch.keys == [10, 20] # Left half |
| 554 | assert new_branch.keys == [40] # Right half (excluding promoted key) |
| 555 | assert len(branch.children) == 3 # mid + 1 = 3 |
| 556 | assert len(new_branch.children) == 2 # 5 - 3 = 2 |
| 557 | |
| 558 | |
| 559 | class TestSiblingRedistribution: |
nothing calls this directly
no test coverage detected