silentbicycle/theft
Freeproperty-based testing for C: generate input to find obscure bugs, then reduce to minimal failing input
About silentbicycle/theft
Theft is a C library for property-based testing, inspired by QuickCheck. Instead of testing specific example inputs, it allows developers to assert general properties that should hold for any possible input. The library automatically generates random input, runs the property against it, and searches for counter-examples that cause the test to fail. When a failure is found, theft automatically simplifies the failing input to produce the minimal reproducible counter-example. It includes built-in implementations of the Mersenne Twister PRNG and FNV-1a hashing, and can optionally fork before running tests to handle crashes or timeouts. Theft depends only on C99 and a Unix-like environment, making it easy to vendor or integrate into existing projects.
Key Features
Pros & Cons
- Automatically finds edge cases that example-based testing might miss
- Simplifies failures to minimal inputs, aiding debugging
- Open source under the permissive ISC license
- Lightweight: only needs C99 and a POSIX-like system
- Can be vendored without coupling to build systems
- Optional forking isolates crashes and timeouts
- Limited to C language only
- Requires a Unix-like environment (not Windows without adaptations)
- Manual integration needed (no package manager distribution)
- Property definition can be complex for some use cases