-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
CHECK expression is hitting a static assert #621
Comments
What about just separating them: CHECK(mismatch_pair.first == expected_result.end());
CHECK(mismatch_pair.second == DeliveryWidget::s_widgetNames.begin()); It would have the same effect at run-time anyway. The expression is "too complex" because of the |
Had the same issue in my code with:REQUIRE( A ==B) && (C==D)) - reporting '..to complex'..Then additional parentheses and explicit '==true' condition worked for me :REQUIRE( true == ((A ==B) && (C==D)) )
What about just separating them:CHECK(mismatch_pair.first == expected_result.end()); |
I'm fine doing that. I'd just like to learn more about why that expression won't work in one |
Good point. I should add something to the docs about that. The reason for this limitation is that Catch decomposes the expression, then must reconstruct it so it can evaluate whether it was successful or not. While it is decomposed it can capture the values of the LHS and RHS of the expression for reporting purposes. If you introduce |
Maybe this could be solved with a new type of assertion macro (variable arguments):
Another thought is to create
Just some food for thought. |
@rcdaily The problem with the first one is that it would be too easy to use accidentally: CHECK(myfunc<int, int>() == 1); // Oops! |
Note you can always apply DeMorgan's Law to convert an OR to an AND so you can split it as mentioned above: Instead of: |
@tamboril, this doesn't work. According to https://github.com/catchorg/Catch2/blob/devel/docs/assertions.md, the correct resolution is to put the expression in parentheses: CHECK((a == 1 || b == 2)); |
Thanks for the (belated) update! |
Thank you so much for this. I wrapped mine and it worked. I have literally spent hours on this stupid issue. I tried using the equal function to compare objects and it didn't work and then I tried using '==' didn't work. Then I tried '&&' didn't work. I even tried making my own method for equals with override, which didn't work and it hurt my brain. |
I have the following piece of code in a test case:
The errors I get:
I tried wrapping the two binary expressions utilizing
==
in parenthesis, this did not help. What am I supposed to do here? There is nothing in the documentation regarding this.The text was updated successfully, but these errors were encountered: