zig/doc/langref/test_integer_pointer_conversion.zig

11 lines
253 B
Zig

const expect = @import("std").testing.expect;
test "@intFromPtr and @ptrFromInt" {
const ptr: *i32 = @ptrFromInt(0xdeadbee0);
const addr = @intFromPtr(ptr);
try expect(@TypeOf(addr) == usize);
try expect(addr == 0xdeadbee0);
}
// test