zig/test/behavior/misc.zig

37 lines
873 B
Zig
Raw Normal View History

const std = @import("std");
const expect = std.testing.expect;
const expectEqualSlices = std.testing.expectEqualSlices;
const expectEqualStrings = std.testing.expectEqualStrings;
const mem = std.mem;
const builtin = @import("builtin");
2017-01-05 16:57:48 +08:00
// can't really run this test but we can make sure it has no compile error
// and generates code
const vram = @intToPtr([*]volatile u8, 0x20000000)[0..0x8000];
export fn writeToVRam() void {
vram[0] = 'X';
}
2017-08-30 12:17:11 +08:00
const PackedStruct = packed struct {
a: u8,
b: u8,
};
const PackedUnion = packed union {
a: u8,
b: u32,
};
test "packed struct, enum, union parameters in extern function" {
testPackedStuff(&(PackedStruct{
.a = 1,
.b = 2,
}), &(PackedUnion{ .a = 1 }));
}
2021-06-20 09:10:22 +08:00
export fn testPackedStuff(a: *const PackedStruct, b: *const PackedUnion) void {
if (false) {
a;
b;
}
}