The Testing Allocator Catches Leaks
Detect memory bugs automatically.
Memory Bugs Are Sneaky
A program can pass every value check yet still leak memory by forgetting to free it. Zig gives tests a tool to catch exactly that.
Meet testing.allocator
Inside a test you get a special allocator at std.testing.allocator. Use it anywhere your code needs to allocate heap memory.
const a = std.testing.allocator;All lessons in this course
- Writing test Blocks
- Assertions with std.testing
- The Testing Allocator Catches Leaks
- Running and Filtering Tests