Test with string keys to ensure comparison works correctly.
()
| 222 | |
| 223 | |
| 224 | def test_string_keys(): |
| 225 | """Test with string keys to ensure comparison works correctly.""" |
| 226 | print("Testing string keys...") |
| 227 | tree = bplustree_c.BPlusTree(capacity=4) |
| 228 | |
| 229 | string_keys = ["apple", "banana", "cherry", "date", "elderberry", "fig", "grape"] |
| 230 | for key in string_keys: |
| 231 | tree[key] = len(key) |
| 232 | |
| 233 | # Verify all string keys |
| 234 | for key in string_keys: |
| 235 | value = tree[key] |
| 236 | expected = len(key) |
| 237 | assert value == expected, f"tree['{key}'] should be {expected}, got {value}" |
| 238 | |
| 239 | # Check sorted order |
| 240 | keys = list(tree.keys()) |
| 241 | expected_keys = sorted(string_keys) |
| 242 | assert ( |
| 243 | keys == expected_keys |
| 244 | ), f"String keys not in sorted order. Expected {expected_keys}, got {keys}" |
| 245 | |
| 246 | print("✓ String key tests passed") |
| 247 | |
| 248 | |
| 249 | def test_mixed_types(): |