Trying to be a good kid. Writing tests as I code. Testing the edge cases. "Hey, this should throw, does Qt have a test for that?" Yeah, its QVERIFY_EXCEPTION_THROWN
. Great, let's use that!
void suspisiousFunctionCallThrows()
{
// Define badInput and otherParam;
QVERIFY_EXCEPTION_THROWN(suspicisouFunction(badInput,otherParam), std::runtime_error);
}
It doesn't compile. Why not? Commas again, of course.
And it is conceptually easy to fix: you just create some blind wrapper than make the offending call without taking multiple argument.
void suspiciousFunctionCallThrows()
{
// Define badInput and otherParam;
std::function f = [&]{
suspiciousFunction(badInput,otherParam);
}
QVERIFY_EXCEPTION_THROWN(f(), std::runtime_error);
}
Not exactly a featured stop on the "Look at our transparent tests" tour, is it?
No comments:
Post a Comment