I've never written a unit test or any test for my C++ programs. I know just that they are meant to testing if the function/program/unit does exactly what you think it does, but I have no idea how to write one.
Can anybody help me with a test for my example function?
void doMode(int i) {
int a = fromString<int>(Action[i][1]);
int b = fromString<int>(Action[i][2]);
std::cout << "Parameter:\t" << a << "\t" << b << "\t" << std::endl;
Sleep(200);
return;
}
I'm not asking for a framework. I just don't know where and how to start.
- What is the syntax I have to use?
- Is it different depending on which framework I use?
- Do I write tests for every function of my code and all the branches, or just the ones I think can be tricky?