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

Function test_specific_problematic_case

python/tests/test_proper_deletion.py:52–78  ·  view source on GitHub ↗

Test the specific case that was creating single-child parents

()

Source from the content-addressed store, hash-verified

50
51
52def test_specific_problematic_case():
53 """Test the specific case that was creating single-child parents"""
54 tree = BPlusTreeMap(capacity=4) # Minimum viable capacity
55
56 # Build a larger case to stress test the deletion logic
57 for i in range(16):
58 tree[i] = f"value_{i}"
59
60 print("Built tree with items 0-15")
61 assert check_invariants(tree), "Initial tree should be valid"
62
63 # Delete in a problematic order that stresses merge/redistribute logic
64 problematic_deletes = [1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 14]
65
66 for key in problematic_deletes:
67 print(f"\nDeleting {key}...")
68 del tree[key]
69
70 invariants_ok = check_invariants(tree)
71 print(f"Invariants OK: {invariants_ok}")
72
73 if not invariants_ok:
74 print("Structure after violation:")
75 _print_structure(tree.root, 0)
76 assert False, f"Invariants violated after deleting {key}"
77
78 print("✅ Problematic case now maintains invariants!")
79
80
81def test_merge_vs_redistribute():

Callers 1

Calls 3

BPlusTreeMapClass · 0.90
_print_structureFunction · 0.85
check_invariantsFunction · 0.70

Tested by

no test coverage detected