zig/doc/langref/test_allowzero.zig

12 lines
297 B
Zig
Raw Normal View History

const std = @import("std");
const expect = std.testing.expect;
test "allowzero" {
var zero: usize = 0; // var to make to runtime-known
_ = &zero; // suppress 'var is never mutated' error
const ptr: *allowzero i32 = @ptrFromInt(zero);
try expect(@intFromPtr(ptr) == 0);
}
// test