diff --git a/tests/test_libxc_parser.py b/tests/test_libxc_parser.py new file mode 100644 index 0000000000000000000000000000000000000000..873cd7e22d4c1d54a04f2673b744b98c28d12008 --- /dev/null +++ b/tests/test_libxc_parser.py @@ -0,0 +1,37 @@ +from typing import Any +import pytest +from general_parser import Triple, get_libxc_settings +from libxc_c_parser import libxc_main, trampoline + + +def libxc_src() -> str: + main, _, src = get_libxc_settings() + return f"{main}/{src}" + + +def source_file(file_name: str) -> list[Triple]: + file_path = f"{libxc_src()}/{file_name}" + with open(file_path, "r", encoding="utf-8") as file: + _, _, posts = trampoline(libxc_main, file, "", []) + return posts + + +@pytest.mark.parametrize( + "file_name, expected", + [ + ( + "gga_x_pbe.c", + { + "post_id": 0, + "name": "XC_GGA_X_PBE", + "citations": ["&xc_ref_Perdew1996_3865", "&xc_ref_Perdew1997_1396"], + "initializer": "gga_x_pbe_init", + }, + ), + # Add more file_name and expected dicts for additional files + ], +) +def test_functional(file_name, expected): + functional_attr = source_file(file_name)[expected["post_id"]][1][1] + for key, value in expected.items(): + assert functional_attr[key] == value \ No newline at end of file