-
Notifications
You must be signed in to change notification settings - Fork 67
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
Add property-based testing #81
base: master
Are you sure you want to change the base?
Conversation
@DanielLiamAnderson Any thoughts on this PR? I'll keep working on polishing the code/documentation if you think this patch can potentially be merged. |
I'm not familiar with the RapidCheck library but this seems useful for sure. |
All tests in the base version should now have a PBT counterpart.
RapidCheck seems to be the only PBT/fuzzing library around for C++. It has not had any activities for 2 years: looks like the author has abandoned it. Fortunately, the library is feature-complete enough. I got some time to work on this more. The README now has some explanations on running these newly-added tests. I also added some more tests so that everything covered by One more bug is found: in
However, in practice, calling Looks like not all CI tests passed last time. I'll investigate this more once I have time. |
I switched from using addition to xor in some of the tests so that UBSAN wouldn't complain about integer overflow. A few parlay functions perform implicit type casts that change the signedness, so I changed them as well to make UBSAN happy. As for |
There's also a failed build due to the use of exceptions in |
Randomized testing seems to be planned in #63 but was never actually done. This is an attempt at it using the rapidcheck library.
3 crashes have been found so far. They are documented by
FIXME
s. They all happen when malformed inputs are supplied to the library. For example,find_end
segfaults if the first list is shorter than the second list due to a bad index access, though it is supposed to returnlist1.end()
.Most functions tested by
test_primitives.cpp
have been covered. More tests (and some documentation on running these tests) are forthcoming.