import sys, re
sys.stdout.reconfigure(encoding='utf-8')

with open('tests/test_core.cpp', 'r', encoding='utf-8') as f:
    text = f.read()

funcs = re.findall(r'(\/\/[^\n]*\n)*void (Test[A-Za-z0-9_]+)\s*\(\)\s*\{', text)
for comments, name in funcs:
    c_clean = comments.strip() if comments else ""
    # find test print
    m_body = re.search(r'void ' + name + r'\s*\(\)\s*\{([\s\S]*?)(?=\nvoid Test|\nint main|\Z)', text)
    title = ""
    if m_body:
        m_title = re.search(r'std::cout << \"(\[Test \d+\][^\"]+)\"', m_body.group(1))
        if m_title:
            title = m_title.group(1)
    print(f"{name:45s} | {title} | {c_clean[:80]}")
