MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / test_branch_node_split

Method test_branch_node_split

python/tests/test_bplus_tree.py:540–556  ·  view source on GitHub ↗

Test splitting a branch node

(self)

Source from the content-addressed store, hash-verified

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
559class TestSiblingRedistribution:

Callers

nothing calls this directly

Calls 3

splitMethod · 0.95
BranchNodeClass · 0.90
LeafNodeClass · 0.90

Tested by

no test coverage detected