zig/doc/langref/test_assertion_failure.zig

12 lines
236 B
Zig

// This is how std.debug.assert is implemented
fn assert(ok: bool) void {
if (!ok) unreachable; // assertion failure
}
// This test will fail because we hit unreachable.
test "this will fail" {
assert(false);
}
// test_error=