Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combined REQUIRE_THROWS_AS and REQUIRE_THROWS_WITH #818

Closed
joto opened this issue Feb 9, 2017 · 3 comments
Closed

Combined REQUIRE_THROWS_AS and REQUIRE_THROWS_WITH #818

joto opened this issue Feb 9, 2017 · 3 comments

Comments

@joto
Copy link

joto commented Feb 9, 2017

It would be nice to have a macro that combines REQUIRE_THROWS_AS and REQUIRE_THROWS_WITH allowing to check the exception type and message in one go.

@horenmar
Copy link
Member

horenmar commented Mar 8, 2017

There are more requests for this, so it might happen.

The question is, what the API should be like... the obvious option would be REQUIRE_THROWS_WITH_AS(expr, exception-type, matcher), but the name might not be a good idea and I am not sure whether the API couldn't be better if done differently.

@lightmare
Copy link
Contributor

You could add an optional third arg

REQUIRE_THROWS_AS(stuff(), std::runtime_error, "failed");

At first I was going to suggest changing the second arg from exception type to matcher, plus the ability to pass an exception object instead, as in REQUIRE_THROWS_AS(stuff(), std::runtime_error("failed")) (which would construct what()-equality matcher), but that would probably be both more difficult to implement pre-C++11 and break existing code.

horenmar added a commit that referenced this issue Jun 5, 2017
@horenmar
Copy link
Member

horenmar commented Jun 5, 2017

I am going to close this issue in favour of #641. See latest post there for an update.

@horenmar horenmar closed this as completed Jun 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants