Instead of worrying about how to test the function in its current form, I would revise the function to work a little smarter, and instead test the redesigned version.
, , ( ) : , . , (std::cout), - , (, GUI, , ).
1) 2) .
std::string convert_int(int val) {
switch (val) {
case 1: return "1";
case 2: return "2";
default: return "Nix";
}
}
std::ostream &write_string(std::ostream &os, std::string const &s) {
return os << s;
}
() - , convert_int , , , .
, write_string - , , , . - convert_int , . write_string stringstream ostream - .str(), , ( ) , .