-
-
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
REQUIRE_THROWS_AS doesn't work with constructor #798
Comments
Try calling the constructor directly, without declaring a variable: The underlying problem is that to fix a |
I came here looking for an existing bugreport about this behavior change. We're of course OK with changing our test suite to follow this upstream change, but I want to check with you that this change is intentional. The older Catch doesn't work with the new syntax. |
@jktjkt Unless there is significant feedback against, we plan to keep it, so we don't trigger warnings when used like
Can you be more specific about this? I tried compiling and running this against Catch 1.6.1 using clang 3.8 and it seems to compile and work fine. #define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include <typeinfo>
struct foo {
foo(){ throw std::bad_cast(); }
foo(int i){ throw 1; }
};
TEST_CASE("ASD") {
CHECK_THROWS_AS(foo(), std::bad_cast);
CHECK_THROWS_AS(foo(3), int);
}
|
Previously we were on 1.5.9. I don't have a minimal example, sorry, this is a hand-sanitized snippet from our internal CI run (GCC 6.2.1 on CentOS 7, devtoolset 6). Getting rid of the variable identifier resulted in this:
This is roughly how that class looks like (again, hand-sanitized): typedef std::shared_ptr<PacketStream> StreamPtr;
class MyClass {
public:
MyClass(StreamPtr serial);
// ...
}; Don't waste much time on this, I guess -- the change was very cheap anyway. I just wanted to provide some feedback that yeah, it was noticed :). |
Works for me. |
Calling |
I've upgraded to v.1.7.0 and tests that used to run are now breaking.
Steps to reproduce
This test used to run and now doesn't:
And I get the error:
Extra information
The text was updated successfully, but these errors were encountered: