-
Notifications
You must be signed in to change notification settings - Fork 38
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
Implement randomised round-trip testing #453
Comments
quickcheck does not support generating random arrays: BurntSushi/quickcheck#226 BurntSushi/quickcheck#103 BurntSushi/quickcheck#92 proptest does not support structs with more than 10 members (?): proptest-rs/proptest#197 |
We want to have randomised round-trip testing. An instance of a struct is generated randomly, then serialised, parsed and the result should be equivalent to the original structure. Existing crates for this seem not to support our use case. See [0] for details. Thus, this commit starts work on our own implementation of this. It begins by adding a GenerateRandom to x11rb-protocol that allows to create a random instance of a type based on a fastrand random number generator. This commit also implements this trait for primitive types. Numbers are limited to at most 4 since they could be sizes and we have nesting. For example, if a list contains another list which contains another list, with a limit of 4 we can already end up with 4*4*4 = 64 items. To avoid generating huge instances, this low limit is used. [0]: #453 Signed-off-by: Uli Schlachter <psychon@znc.in>
I gave this another try in the branch
The second test is given me lots of problems, but the first one also does not work.
|
Something like proptest or quickcheck could be used to generate random instances of "something". This random instance could then be serialised and parsed again. If "something" implements
PartialEq
, one could then check that "everything" worked okay.See #452 (comment) and #184 (which is about fuzzing, which is arguably quite close to this)
The text was updated successfully, but these errors were encountered: