Krofna, Nice. I know that there is a way to make automate unit testing by using father process and make the main the child.
But I don't know how to do it !!
You could modify your program so it takes a command line parameter which specifes the values you would have entered. You could then drive your tests using a batch file (at least to start with).
If you have multiple inputs, you could read the input values from file (its path would be the command line parameter)
I used _popen to open the program I want to test with a program created just for testing.
This program is able to receive the output of cout and convert them to strings.
I used SendInput to input into cin.
I have a text file that contains the test input and the expected output.
The fault I have with this approach is that I have to input by emulating keyboard; it would be better if I could directly send strings into the cin. Also, I found that by emulating the keyboard, if I try to input two same consecutive characters, I can only output one of the characters unless I put a Sleep(15 ms) between the two characters.
If there's any other solutions others can think of or how to fix the problems above plz tell me :)