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

Function test_empty_tree

python/tests/test_c_extension_comprehensive.py:20–41  ·  view source on GitHub ↗

Test operations on empty tree.

()

Source from the content-addressed store, hash-verified

18
19
20def 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
44def test_single_item():

Callers

nothing calls this directly

Calls 2

keysMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected