I have to cause bad_alloc for my unit test (basically, for 100% code coverage, there's no way i can change some functions). What should I do?
Here is my code example. I have to cause bad_alloc somewhere here.
bool insert(const Value& v) {
Value * new_value;
try {
new_value = new Value;
}
catch (std::bad_alloc& ba){
std::cerr << "bad_alloc caught: " << ba.what() << std::endl;
return false;
}
//...
//working with new_value
//...
return true;
};