3 ms·
It looks like Arbitrary will sample integers from an uniform distribution. For property based testing you often would like to have a bias towards "interesting"
by tveita 4y ago
It looks like Arbitrary will sample integers from an uniform distribution. For property based testing you often would like to have a bias towards "interesting" values that might trigger special cases, like -1, 0 and 1.
E.g. if you had "max_speed_kph: Option<u64>", your tests might never check what happens if max_speed_kph is 0.
- pfdietz 4y agoOne also may bias values to be similar (or equal) to other recently generated values. This was a trick used in the compiler tester yarpgen, where it was useful in testing optimization of bitwise operators on integers. https://github.com/intel/yarpgen https://github.com/intel/yarpgen https://github.com/intel/yarpgen/blob/main/papers/yarpgen-ooplsa-2020.pdf https://github.com/intel/yarpgen/blob/main/papers/yarpgen-oo... (see "Policies for constants", page 196:8.)