Hello,
I'm using C++Test from Parasoft for unit testing C++ code. I came across the following problem. I have a function similar to the next one (pseudocode):
bool LoadFileToMem(const std::string& rStrFileName)
{
if( openfile(rStrFileName) == successfull )
{
if( get_file_size() == successfull )
{
if( read_entire_file_to_buffer() == successfull )
{
return true;
}
return false;
}
return false;
}
return false;
}
My questions in this case are:
Should I use stubs for file system functions? Or should I include specific sample test files for running the unit tests?
In my case std::fstream class is used for file input.
Has anyone better suggestions? (Best if done in C++Test but not mandatory)
Thank you,
Iulian