blob: 8d64d492239e04e2e6daa918679ae0a6deca0441 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
const std = @import("std");
const builtin = @import("builtin");
test "@sizeOf reified union zero-size payload fields" {
comptime {
try std.testing.expect(0 == @sizeOf(@Type(@typeInfo(union {}))));
try std.testing.expect(0 == @sizeOf(@Type(@typeInfo(union { a: void }))));
if (builtin.mode == .Debug or builtin.mode == .ReleaseSafe) {
try std.testing.expect(1 == @sizeOf(@Type(@typeInfo(union { a: void, b: void }))));
try std.testing.expect(1 == @sizeOf(@Type(@typeInfo(union { a: void, b: void, c: void }))));
} else {
try std.testing.expect(0 == @sizeOf(@Type(@typeInfo(union { a: void, b: void }))));
try std.testing.expect(0 == @sizeOf(@Type(@typeInfo(union { a: void, b: void, c: void }))));
}
}
}
|