Test basic C extension functionality.
()
| 30 | |
| 31 | |
| 32 | def test_c_extension_basic(): |
| 33 | """Test basic C extension functionality.""" |
| 34 | if not HAS_C_EXTENSION: |
| 35 | print("Skipping C extension tests - not available") |
| 36 | return |
| 37 | |
| 38 | print("Testing C Extension Basic Functionality") |
| 39 | print("=" * 50) |
| 40 | |
| 41 | # Test creation |
| 42 | tree = bplustree_c.BPlusTree(capacity=32) |
| 43 | print(f"Created tree with capacity 32") |
| 44 | |
| 45 | # Test insertion |
| 46 | for i in range(100): |
| 47 | tree[i] = i * 2 |
| 48 | |
| 49 | print(f"Inserted 100 items, tree length: {len(tree)}") |
| 50 | |
| 51 | # Test lookups |
| 52 | for i in range(0, 100, 10): |
| 53 | assert tree[i] == i * 2, f"Lookup failed for key {i}" |
| 54 | |
| 55 | print("Lookups verified") |
| 56 | |
| 57 | # Test iteration |
| 58 | keys = list(tree.keys()) |
| 59 | assert len(keys) == 100, f"Expected 100 keys, got {len(keys)}" |
| 60 | assert keys == list(range(100)), "Keys not in correct order" |
| 61 | |
| 62 | print("Iteration verified") |
| 63 | |
| 64 | # Test items |
| 65 | items = list(tree.items()) |
| 66 | assert len(items) == 100, f"Expected 100 items, got {len(items)}" |
| 67 | for i, (k, v) in enumerate(items): |
| 68 | assert k == i and v == i * 2, f"Item {i} incorrect: {k}, {v}" |
| 69 | |
| 70 | print("Items iteration verified") |
| 71 | print("✓ C extension basic functionality works correctly") |
| 72 | |
| 73 | |
| 74 | def test_c_extension_performance(): |
no test coverage detected