Answer the question
In order to leave comments, you need to log in
Is it possible to write a unit test under a void function?
When writing a program in C++, I used void functions all the time.
Is it possible to test them in this case, and if so, how?
I was just reading about unit tests on the Internet, but everywhere people used int or double, and it became interesting whether it was possible to write under void.
Answer the question
In order to leave comments, you need to log in
If the function does not return anything, then it either changes the values of its arguments passed by reference (pointer) or global variables, or outputs something to the console/window/port/socket/etc, otherwise it is useless.
Check any output that the function generates.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question