I am trying to write a C++ unit test class. What I want to do is to run a given set of input test files on another class (simulator
class as in code below).
Assume, runTest
function as shown below calls my required class on each test file.
void runTest(vector<string> testFiles)
{
for(auto file : testFiles)
{
cout <<" Running test file:"<<file<<std::endl;
simulator simulatorObj(file);
simulatorObj.run();
}
}
Now there are some input test files where the simulator class can generate a Seg fault (due to a bug in simulator
class). Now I want to catch this seg-fault in my test class. Is there any way in which I can convert seg-fault signal to a C++ exception or something similar.
I tried using try catch block with generic exception but it didn't work. Also I am not able to think of any solution.
Please help.