silentbicycle/theft logo

silentbicycle/theft

Free

property-based testing for C: generate input to find obscure bugs, then reduce to minimal failing input

FreeFree tier
Type
Open Source

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

Property-based testing in C with automatic input generation
Shrinking: reduces failing inputs to minimal counter-examples
Forking support to handle crashes and timeouts during testing
No external dependencies beyond C99 and Unix-like environment
Includes Mersenne Twister PRNG and FNV-1a hashing implementations
Easy to vendor into existing projects without build system coupling

Pros & Cons

Pros
  • 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
Cons
  • 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

Best For

Finding obscure bugs in C programs through randomized inputTesting functions with a wide range of inputs to verify general propertiesMinimizing failure cases for easier debuggingValidating data structures, parsers, and algorithms in C