Questions tagged [proptest]

Proptest is a Rust library for property-based testing. It is inspired by hypothesis; in particular its value generating strategy and shrinking.

Documentation:

6 questions
3
votes
0 answers

How can I run proptest from a particular seed, analogous to @reproduce_failure("") in hypothesis?

On case of test failure hypothesis suggests to add decorator @reproduce_faliure("") to easily reproduce and debug a particular failure. This is very convenient for the usual pipeline Test -> Fix failure with debugger -> Look for the next…
Dimitrius
  • 564
  • 6
  • 21
3
votes
1 answer

How can I keep the transformation of arbitrary proptest values out of the test case body?

I want to thoroughly test an implementation of the intersection of two BTreeSets. I can write: use self::proptest::prelude::*; proptest! { #[test] fn intersect_this(s1: BTreeSet, s2: BTreeSet) { // ... } } But this has…
Stein
  • 1,558
  • 23
  • 30
0
votes
1 answer

How to create JSON object strategy according to a schema with rust proptest?

I'd like to create a JSON strategy using rust proptest library. However, I do not want to create an arbitrary JSON. I'd like to create it according to a schema (more specifically, OpenAPI schema). This means that keys of the JSON are known and I do…
matusf
  • 469
  • 1
  • 8
  • 20
0
votes
1 answer

Proptest: Strategy to generate vectors of vectors

I want to generate DAGs with proptest. The algorithm that I pick would be this. I've written the plain algorithm below -- but I need help transforming this to a proptest strategy. What would a strategy need to look like that did the same as the…
Unapiedra
  • 15,037
  • 12
  • 64
  • 93
-1
votes
1 answer

How do I create a Strategy that generates a value in a given range in proptest?

I want to create a Strategy that generates u32 values less than 1000000 efficiently and uniformly. The only two ways that I know to do this are to use any::() and then do one of the following: use prop_filter to filter out values greater than…
nimble_ninja
  • 323
  • 1
  • 13
-1
votes
1 answer

How to handle passing a mutably borrowed struct to function closure?

I am using the proptest crate to run some property tests in a no_std environment. proptest's default test_runner::TestRunner::run() implementation takes some input (as a Strategy or ValueTree object defined in proptest) and a function closure as…