zig/test/behavior/translate_c_macros.zig
Andrew Kelley 4307436b99 move behavior tests from test/stage1/ to test/
And fix test cases to make them pass. This is in preparation for
starting to pass behavior tests with self-hosted.
2021-04-29 15:54:04 -07:00

23 lines
571 B
Zig

const expect = @import("std").testing.expect;
const expectEqual = @import("std").testing.expectEqual;
const h = @cImport(@cInclude("behavior/translate_c_macros.h"));
test "initializer list expression" {
expectEqual(h.Color{
.r = 200,
.g = 200,
.b = 200,
.a = 255,
}, h.LIGHTGRAY);
}
test "sizeof in macros" {
expectEqual(@as(c_int, @sizeOf(u32)), h.MY_SIZEOF(u32));
expectEqual(@as(c_int, @sizeOf(u32)), h.MY_SIZEOF2(u32));
}
test "reference to a struct type" {
expectEqual(@sizeOf(h.struct_Foo), h.SIZE_OF_FOO);
}