ut
ut copied to clipboard
`throws` with message
It would be nice if ut permitted to check that an exception's message (.what()) matches some expected pattern, like with GoogleTest's ThrowsMessage matcher.
I was thinking about something along these lines:
// Add new throws_message function
"exception_message"_test = [] {
expect(throws_message([] { throw std::runtime_error("feature_request"); }, "feature_request"));
};
// Add an overload to the existing throws function
"exception_message"_test = [] {
expect(throws([] { throw std::runtime_error("feature_request"); }, "feature_request"));
};