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

[Feature Request] Assertion macro that works inside both RC and non-RC GTest tests. #164

Open
jeremysalwen opened this issue Sep 13, 2017 · 3 comments

Comments

@jeremysalwen
Copy link

Right now, inside RapidCheck tests, it is necessary to assert using RC_ASSERT, and inside GTest tests it is necessary to use EXPECT_EQ and whatnot.

However, I would like to write utility functions that work in both contexts, to combine the power of property testing with standard corner-case testing. If I use EXPECT_EQ, then that breaks the RapidCheck tests, and if I use RC_ASSERT, then the GTest tests won't tell me the line number or the error that occurred:

unknown file: failure
Unknown c++ exception thrown in the test body.

Ideally there would be a way to know if the current scope was inside or outside a RapidCheck test. Then there could be a macro RCGT_ASSERT(), which calls RC_ASSERT if it's inside a RapidCheck test, and calls the GTest assert if it's outside of a RapidCheck test.

@emil-e
Copy link
Owner

emil-e commented Sep 14, 2017

rc::detail::ImplicitParam<CurrentPropertyContext>::value() != rc::detail::CurrentPropertyContext::defaultValue() will be true if you are in a property. I would welcome a pull request for at least a function that can be used for checking this.

@jeremysalwen
Copy link
Author

@emil-e I'll take a look at it. I would want to also generate the same debugging message that RC_ASSERT does inside of a RapidCheck test. Could you point me in the right direction for how to extract that message from the exception that RC_ASSERT throws?

@emil-e
Copy link
Owner

emil-e commented Sep 17, 2017

Sure. You want to catch CaseResult which you can see at

description contains the message.

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