mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
parent
508294e9be
commit
9d3363fee9
1 changed files with 10 additions and 0 deletions
|
|
@ -640,3 +640,13 @@ test "store undefined to packed result location" {
|
||||||
var s = packed struct { x: u4, y: u4 }{ .x = x, .y = if (x > 0) x else undefined };
|
var s = packed struct { x: u4, y: u4 }{ .x = x, .y = if (x > 0) x else undefined };
|
||||||
try expectEqual(x, s.x);
|
try expectEqual(x, s.x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "bitcast back and forth" {
|
||||||
|
// Originally reported at https://github.com/ziglang/zig/issues/9914
|
||||||
|
const S = packed struct { one: u6, two: u1 };
|
||||||
|
const s = S{ .one = 0b110101, .two = 0b1 };
|
||||||
|
const u: u7 = @bitCast(s);
|
||||||
|
const s2: S = @bitCast(u);
|
||||||
|
try expect(s.one == s2.one);
|
||||||
|
try expect(s.two == s2.two);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue