I am trying to test a function that outputs text to the standard
output, presumably using a cout call. I do not have access to the
source, but need to test the output. Is this possible?
I can technically create an executable that calls the function and then
using a command prompt call the exexutable using the > output.txt
redirector but I would prefer to do everything within the application
itself. Is there a way for force an output to screen to a file or
string without having access to the cout call itself? ( would be easy
to do if I could simply do outfile << myText but the output is coming
from a function in a DLL for example).
example:
OutputMethod() // Inaccessible code that can not be modified
{
std::cout << "This is some text" << std::endl;
}
int main() // My Code
{
...
Redirect stdout to a text file
...
OutputMethod(); // Call the method and have it output to a file
instead of the screen
...
Verify the output file to see it's contents
...
}
Thanks,
Adam