test_variable_alignment.zig (408B) - Raw
1 const std = @import("std"); 2 const builtin = @import("builtin"); 3 const expect = std.testing.expect; 4 5 test "variable alignment" { 6 var x: i32 = 1234; 7 const align_of_i32 = @alignOf(@TypeOf(x)); 8 try expect(@TypeOf(&x) == *i32); 9 try expect(*i32 == *align(align_of_i32) i32); 10 if (builtin.target.cpu.arch == .x86_64) { 11 try expect(@typeInfo(*i32).pointer.alignment == 4); 12 } 13 } 14 15 // test