Assertions with std.testing
expect, expectEqual, and friends.
The testing Namespace
Zig's assertion helpers live in std.testing. Pull it into a short name so each check reads cleanly inside your test blocks.
const testing = std.testing;expect for Booleans
The simplest helper is expect. It takes one boolean and fails the test when that condition is false.
try testing.expect(value > 0);All lessons in this course
- Writing test Blocks
- Assertions with std.testing
- The Testing Allocator Catches Leaks
- Running and Filtering Tests