ut icon indicating copy to clipboard operation
ut copied to clipboard

`throws` with message

Open Tachi107 opened this issue 3 years ago • 0 comments

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"));
};

Tachi107 avatar Jun 02 '22 18:06 Tachi107