Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test code that writes to stdout?

Tags:

People also ask

What does test code mean?

Related Definitions Test Code means randomly generated numeric combinations that serve as a personalised security feature used for the purposes of identification of a Customer in the framework of communication between the Bank and the Customer by fax or by e-mail.


How to write a test in CUnit for a function that prints to stdout, to verify its output?

Example function to test:

void print()
{
    printf("Hello world");
}

Its unit test should somehow verify that "Hello world" was printed to the console:

void test_print()
{
    // how to assert?
}

How should I go about it?