Test finding correct child index
(self)
| 520 | assert len(branch) == 0 |
| 521 | |
| 522 | def test_find_child_index(self): |
| 523 | """Test finding correct child index""" |
| 524 | branch = BranchNode(capacity=4) |
| 525 | branch.keys = [10, 20, 30] |
| 526 | |
| 527 | # Create dummy leaf nodes as children |
| 528 | for i in range(4): |
| 529 | branch.children.append(LeafNode(capacity=4)) |
| 530 | |
| 531 | # Test finding child indices |
| 532 | assert branch.find_child_index(5) == 0 # < 10 |
| 533 | assert branch.find_child_index(10) == 1 # >= 10, < 20 |
| 534 | assert branch.find_child_index(15) == 1 # >= 10, < 20 |
| 535 | assert branch.find_child_index(20) == 2 # >= 20, < 30 |
| 536 | assert branch.find_child_index(25) == 2 # >= 20, < 30 |
| 537 | assert branch.find_child_index(30) == 3 # >= 30 |
| 538 | assert branch.find_child_index(35) == 3 # >= 30 |
| 539 | |
| 540 | def test_branch_node_split(self): |
| 541 | """Test splitting a branch node""" |
nothing calls this directly
no test coverage detected