30 lines
760 B
Python
30 lines
760 B
Python
import textwrap
|
|
import dbuf_tests
|
|
|
|
def gen_test_struct(test_fn_name: str, name: str, expected_output: str) -> str:
|
|
return textwrap.dedent(f"""
|
|
(guf_test) {{
|
|
.test_fn = {test_fn_name}, .name = "{name}",
|
|
.expected_output = "{expected_output}",
|
|
.output = NULL,
|
|
.passed = false,
|
|
.runtime_ms = 0,
|
|
}}""")
|
|
|
|
def gen_res_str(buf):
|
|
res = ""
|
|
for elem in buf:
|
|
res += str(elem) + ","
|
|
res = res[:-1]
|
|
return res
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_array_definition = "static const guf_test dbuf_tests[] = {"
|
|
for test_fn in dbuf_tests.all_tests():
|
|
test_array_definition += textwrap.indent(test_fn() + ",", " ")
|
|
|
|
test_array_definition += "\n};"
|
|
|
|
print(test_array_definition)
|