Assignment 3: Output cells unit test

Assignment 3: Output cells unit test

by Karththigan Pushparaj -
Number of replies: 2

In outputcells_t.cpp, the function does not return anything and the final output (of the step number, system state, and fraction_alive) are printed out to the console as the final line is

    std::println(" {:.6}", alive_fraction);


I'm wondering how to go about writing unit tests for this function; are we expected to save the output_cells() stddout to a txt file and then in the unit tests, read from these files, and compare to an expected output?

Or can we modify output_cells to do std::print() instead of std::println() like so:

    std::print(out, " {:.6}", alive_fraction);

Thank you!

EDIT: Noticed that making the change to std::print() makes everything print out as one large line...