-
Notifications
You must be signed in to change notification settings - Fork 37
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
Compile Error: AssertThat(LastException<std::runtime_error>().what(), Is().Containing("fail")); #68
Comments
A |
Okay thanks for your, somewhat brusque, reply but it's an example from the Snowhouse Usage section https://github.com/joakimkarlsson/snowhouse#assertions Making Assertions on the Thrown ExceptionsAssertThrows(std::logic_error, myObject.a_method(42));
AssertThat(LastException<std::logic_error>().what(), Is().Containing("logic failure")); So, given your expertise, perhaps you would be willing to advise how my test code can be corrected? |
Yes, that looks suspiciously like the snowhouse example. Could you run the make file for bandit itself and see what happens? One of the tests in snowhouse performs what you're attempting. https://github.com/joakimkarlsson/snowhouse/blob/master/example/exceptions_tests.cpp#L47 This is run as part of bandit's test suite as well. |
Well, |
Why is it in the example then? |
std::string(LastException<std::runtime_error>().what()).find("fail") != std::string::npos |
I tried your code and got the same result. I got it to work by using |
Many thanks using |
That's a bug. I'll have to take a look at it later. Thanks for reporting! |
Pleasure thanks for your prompt responses and fix 👍 |
The problem is fixed in banditcpp/snowhouse@65668a3 and will be available here as soon as there is an update of the snowhouse submodule. The problem was caused by a missing conversion from |
Trying Bandit/Snowhouse for the first time so this could be my fault? I'm using Qt Creator + Clang but...
Test code
Compile Error
.../bandit/assertion_frameworks/snowhouse/snowhouse/constraints/containsconstraint.h:22: error: member reference base type 'const char *const' is not a structure or union
return std::find(container.begin(), container.end(), expected) != container.end();
~~~~~~~~~^~~~~~
.../bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h:18: expanded from macro 'AssertThat'
SNOWHOUSE_ASSERT_THAT((p1), (p2), ::snowhouse::DefaultFailureHandler);
^
.../bandit/assertion_frameworks/snowhouse/snowhouse/assertmacro.h:13: expanded from macro 'SNOWHOUSE_ASSERT_THAT'
::snowhouse::ConfigurableAssert<FAILURE_HANDLER>::That((p1), (p2), FILE, LINE);
^
The text was updated successfully, but these errors were encountered: