mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 03:04:52 +01:00
15 lines
427 B
Zig
15 lines
427 B
Zig
const std = @import("std");
|
|
const builtin = @import("builtin");
|
|
const expectEqual = std.testing.expectEqual;
|
|
|
|
test "variable alignment" {
|
|
var x: i32 = 1234;
|
|
const align_of_i32 = @alignOf(@TypeOf(x));
|
|
try expectEqual(*i32, @TypeOf(&x));
|
|
try expectEqual(*align(align_of_i32) i32, *i32);
|
|
if (builtin.target.cpu.arch == .x86_64) {
|
|
try expectEqual(4, @typeInfo(*i32).pointer.alignment);
|
|
}
|
|
}
|
|
|
|
// test
|