codegen / assets /train /deepcoder_primeintellect /deepcoder_primeintellect_031f8b479e2e6326 /test_solution.py
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| cases = [{'input': '4\n2 1 2 1\n', 'output': '4'}, {'input': '5\n0 -1 -1 -1 -1\n', 'output': '4'}, {'input': '2\n10 8\n', 'output': '2'}, {'input': '5\n-14 -2 0 -19 -12\n', 'output': '47'}, {'input': '6\n-15 2 -19 20 0 9\n', 'output': '65'}, {'input': '3\n17 4 -1\n', 'output': '22'}, {'input': '4\n20 3 -15 7\n', 'output': '45'}, {'input': '1\n11\n', 'output': '11'}, {'input': '1\n-10\n', 'output': '-10'}, {'input': '7\n-8 9 0 -10 -20 -8 3\n', 'output': '58'}, {'input': '9\n2 4 -4 15 1 11 15 -7 -20\n', 'output': '79'}, {'input': '10\n-20 0 3 -5 -18 15 -3 -9 -7 9\n', 'output': '89'}, {'input': '8\n-1 5 -19 4 -12 20 1 -12\n', 'output': '74'}, {'input': '1\n-1000000000\n', 'output': '-1000000000'}, {'input': '3\n-1 -2 -3\n', 'output': '4'}, {'input': '3\n-1 -1 -1\n', 'output': '1'}, {'input': '2\n-9 -3\n', 'output': '6'}, {'input': '5\n-1 -1 -1 -1 -1\n', 'output': '3'}, {'input': '2\n-1 -1\n', 'output': '0'}, {'input': '5\n-7 -1 -1 -1 -1\n', 'output': '9'}] | |
| solution = Path(__file__).with_name("solution.py") | |
| for index, case in enumerate(cases): | |
| proc = subprocess.run( | |
| [sys.executable, str(solution)], | |
| input=case["input"], | |
| text=True, | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.PIPE, | |
| timeout=10, | |
| ) | |
| if proc.returncode != 0: | |
| raise AssertionError(f"case {index} exited {proc.returncode}: {proc.stderr}") | |
| got = proc.stdout.strip() | |
| expected = case["output"].strip() | |
| if got.split() != expected.split(): | |
| raise AssertionError( | |
| f"case {index} output mismatch\nexpected={expected!r}\ngot={got!r}\nstderr={proc.stderr}" | |
| ) | |
| print('deepcoder_primeintellect_io') | |