c-reviewer / test /test_eval_code.py
ml-visoft's picture
The answer and the feedback to the answer are stored in persistent storage.
376953f
raw
history blame
1.05 kB
import pytest
import eval_code
TYPICAL_ANSWER = """[
{
"criteria": "DRY",
"explanation": "The memory allocation and initialization for ``p1``, ``p2``, and ``p3`` are repetitive. Consider creating a function like ``allocateAndInitializeMemory``."
},
{
"criteria": "SRP",
"explanation": "The ``main`` function handles memory allocation, initialization, and printing. You should separate these responsibilities into different functions like ``allocateMemory``, ``initializeData``, and ``printData``."
},
{
"criteria": "NAME",
"explanation": "``x1`` should be called ``title``, ``y1`` should be called ``author``, ``z1`` should be called ``year``, ``p1`` should be called ``titlePtr``, ``p2`` should be called ``authorPtr``, ``p3`` should be called ``yearPtr``."
}
]"""
def test_parse_chatgpt_answer():
ans = eval_code.parse_chatgpt_answer(TYPICAL_ANSWER)
assert ans is not None
assert len(ans) > 0
an_eval = ans[0]
assert "criteria" in an_eval.keys()
assert "explanation" in an_eval.keys()