lundi 26 octobre 2020

Testing a function that prints outputs

I am trying to write a unit test for a function that prints some texts in C. I have tried everything possible but could not make it possible. I have seen similar questions, but mostly are written in C++. Suppose one of the functions I am trying to test is the following:

void verifyStudent(char string[10][40], int lines)
{
//some actions
printf("Is our Student");
//some other actions
printf("Not a student");
}

And the test as follows:

void test_student()
{
//all initializations

char *exp_output = "Not a student";

//HOW CAN I VERIFY THAT WHAT'S PRINTED IS SAME AS THE exp-output?
}

Aucun commentaire:

Enregistrer un commentaire