S
S
SouLWorker2020-05-26 22:31:46
C++ / C#
SouLWorker, 2020-05-26 22:31:46

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

1 answer(s)
R
res2001, 2020-05-27
@SouLWorker

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 question

Ask a Question

731 491 924 answers to any question