MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_array_generation

Function test_array_generation

benchmarks/test_array_benchmark_simple.py:41–74  ·  view source on GitHub ↗

Test array data generation.

()

Source from the content-addressed store, hash-verified

39 os.remove(temp_db)
40
41def test_array_generation():
42 """Test array data generation."""
43 print("\n🧪 Testing array data generation...")
44
45 runner = ArrayBenchmarkRunner(iterations=3, port=15505)
46
47 try:
48 # Test different array sizes
49 for size in [5, 10, 20]:
50 arrays = runner.generate_test_arrays(size)
51
52 # Verify all array types are present
53 expected_keys = {"int_array", "bigint_array", "text_array", "float_array", "bool_array"}
54 if not expected_keys.issubset(arrays.keys()):
55 raise ValueError(f"Missing array types: {expected_keys - arrays.keys()}")
56
57 # Verify array sizes
58 for key, array in arrays.items():
59 if len(array) != size:
60 raise ValueError(f"{key} has wrong size: {len(array)} != {size}")
61
62 # Verify JSON serialization works
63 for key, array in arrays.items():
64 json_str = json.dumps(array)
65 restored = json.loads(json_str)
66 if restored != array:
67 raise ValueError(f"{key} JSON serialization failed")
68
69 print("✅ Array generation test passed!")
70 return True
71
72 except Exception as e:
73 print(f"❌ Array generation test failed: {e}")
74 return False
75
76def main():
77 """Run all tests."""

Callers 1

mainFunction · 0.85

Calls 3

generate_test_arraysMethod · 0.95
keysMethod · 0.80

Tested by

no test coverage detected