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

Capturer destructor asserts due to bad expression parsing #1436

Closed
amensel opened this issue Nov 7, 2018 · 1 comment
Closed

Capturer destructor asserts due to bad expression parsing #1436

amensel opened this issue Nov 7, 2018 · 1 comment

Comments

@amensel
Copy link

amensel commented Nov 7, 2018

The following asserts:

TEST_CASE("Explodes")
{
    int a = 1;
    int b = 2;
    CAPTURE(a + b);
    REQUIRE(false);
}

The following does not:

TEST_CASE("Works")
{
    int a = 1;
    int b = 2;
    CAPTURE(a+b);
    REQUIRE(false);
}

The assertion that fires:
https://github.com/catchorg/Catch2/blame/1cdaa48a0b20e28ee32553070700b86557f9619d/include/internal/catch_message.cpp#L79

The issue appears to have been caused here: https://github.com/catchorg/Catch2/blame/1cdaa48a0b20e28ee32553070700b86557f9619d/include/internal/catch_message.cpp#L66

@vector-of-bool
Copy link

Looks like you'd want to only count , instead of all whitespace as an argument delimiter, and also only when , appears at the top level (not nested within [], {}, or ()). You can count the nesting depth of each bracket type in one variable since mismatching brackets would cause the compilation to fail anyway.

horenmar added a commit that referenced this issue Nov 19, 2018
The previous implemetation was just plain broken for most of
possible uses, the new one should work (even though it is ugly
as all hell, and should be improved ASAP).

Fixes #1436
horenmar added a commit that referenced this issue Nov 21, 2018
The previous implemetation was just plain broken for most of
possible uses, the new one should work (even though it is ugly
as all hell, and should be improved ASAP).

Fixes #1436
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