I think property based testing (PBT) is cool. I also wanted to try out Zig. Why not create a property based testing library in Zig?

This is what I spent a Saturday afternoon doing; learning Zig by working on a PBT library for the language. Now, calling it a library is a stretch. Currently, it can only test properties of integers, floats, and strings but its a start.

The entry point of the library is a falsify function. First, you dictate a property (predicate) you which to verify along with the appropriate type(s). Then, falsify will either return a case that breaks this property or that it found none. For example, one could test that the commutativity of integers holds via:

fn com(x: i32, y: i32) bool {
      return x * y == y * x;
}
try zigthesis.falsify(com,"Commutative");

Check out zigthesis for yourself!