1 unstable release

0.1.0 Nov 28, 2021

#7 in #upper-bound

Download history 24/week @ 2024-07-22 33/week @ 2024-07-29 22/week @ 2024-08-05 17/week @ 2024-08-12 43/week @ 2024-08-19 34/week @ 2024-08-26 15/week @ 2024-09-02 44/week @ 2024-09-09 45/week @ 2024-09-16 74/week @ 2024-09-23 55/week @ 2024-09-30 59/week @ 2024-10-07 220/week @ 2024-10-14 76/week @ 2024-10-21 49/week @ 2024-10-28 83/week @ 2024-11-04

433 downloads per month
Used in arbitrary

MIT/Apache

10KB
156 lines

Exhaustigen

This is a tiny (but delightful!) utility library for exhaustive testing.

It is based (directly) on the idea and code in the following blog post:

https://matklad.github.io//2021/11/07/generate-all-the-things.html

TL;DR: the idea is to write a test that is similar to the sort of test one writes against a PRNG -- an imperative test that just asks some "generator" to create scalars, booleans, data vectors, random shuffles, etc. -- but to use a special generator that has some interesting features:

  • It has a concept of being "done", so you can put it in a do-while loop
  • Every call to it requires an inclusive upper bound, which should be small
  • It tracks its progress through the sequence of bounds
  • It lazily extends the sequence of bounds as it's asked for more data

By threading such a generator through such an imperative test, and putting the body of that test in a do-while loop, you can write straightforward code with elaborate value-dependent nesting structure -- eg. generate value K in 0..N and then value J in 0..K and so forth -- and it will automatically record and enumerate the space of sequences meaningful to the code, re-running until it has exhausted all possible paths/values.

License

MIT + ASL2.0, with permission from Aleksey.

No runtime deps