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

non-throwing CHECK #582

Closed
lightmare opened this issue Jan 30, 2016 · 2 comments
Closed

non-throwing CHECK #582

lightmare opened this issue Jan 30, 2016 · 2 comments

Comments

@lightmare
Copy link
Contributor

I'm looking for a variant of CHECK(expr) that doesn't abort if expr throws an exception.

For example:

TEST_CASE("string access")
{
    std::string s("foo");
    CHECK(s.at(3) == 'o'); // throws
    CHECK(s.at(2) == 'o'); // ok
    CHECK(s.at(1) == 'f'); // fails
}

With CHECK only the first (throwing) one is reported, because Catch::ResultDisposition::Normal is used here. What I'd like to see in the output is:

s.at(3) == 'o' FAILED with exception
s.at(1) == 'f' FAILED with 'o' == 'f'

I implemented that by copy&pasting INTERNAL_CATCH_TEST and using resultDisposition in the catch clause (ref). I'm not comfortable with the name, should be something like NORETHROW_CHECK or NOABORT_CHECK or perhaps default behaviour of CHECK?

@horenmar
Copy link
Member

Honestly, this seems like a bug in the internal macro, I can't see a reason not to continue on exception when CHECKing.

@horenmar
Copy link
Member

This is now in master, from 1848653.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants