I have a function that reads user input from std::cin, and I want to write a unittest that inserts some strings into std::cin, such that later extraction from std::cin will
Instead of screwing around with cin, you can have your program accept a general std::istream&. When running normally, just pass it cin. During a unit test, pass it an I/O stream of your own creation.