@centril I’d like to write a proptest that takes as input a
Vec<u8> and a
Vec<usize> such that the sum of the latter equals the length of the former. This is for testing that processing a blob of bytes in arbitrary chunks does not affect my algorithm. Any suggestions on how to create that?
hmm; well avoid filtering :slight_smile:
@Jake Goulding So if I understand the test correctly, I would generate the
vu: Vec<usize>, fetch the length, and then generate a random
Vec<u8> from that
hmm, do it backwards. Interesting.
Yeah because constructing a sum from a length seems... harder?
Tho possibly cheaper
Naively, constructing a sum from a length sounds like iteratively and randomly generating numbers that is within the interval of the length and then adding them up until the sum is zero
Maybe proptest has something for that but I don't remember ^^
yeah, it felt like an iterative/recursive concept to me: pick a random number 0..len, repeat until 0, but I couldn’t figure out how to bend the recursive functionality
I would do some searching in the docs to find what you want :D
or make a PR if you didn't find it
you mean an issue? Hard to PR if I don’t know what the code is :-)
Amusingly, this “write it backwards” advice was something I read recently in a protesting article. Too bad I didn’t connect the dots
thread 'same_results_as_c_for_64_bit_with_varying_chunks' panicked at 'capacity overflow', src/liballoc/raw_vec.rs:748:5
Stupid property-based testing… testing all the properties
Yea figure out the code first :D
Well, that was because I was creating a
Vec<u8> with a Very Large Capacity via the props
In case you are interested, this article calls this technique an “oracle generator”