| ... | ... | @@ -640,3 +640,13 @@ test "store undefined to packed result location" { |
| 640 | 640 | var s = packed struct { x: u4, y: u4 }{ .x = x, .y = if (x > 0) x else undefined }; |
| 641 | 641 | try expectEqual(x, s.x); |
| 642 | 642 | } |
| 643 | |
| 644 | test "bitcast back and forth" { |
| 645 | // Originally reported at https://github.com/ziglang/zig/issues/9914 |
| 646 | const S = packed struct { one: u6, two: u1 }; |
| 647 | const s = S{ .one = 0b110101, .two = 0b1 }; |
| 648 | const u: u7 = @bitCast(s); |
| 649 | const s2: S = @bitCast(u); |
| 650 | try expect(s.one == s2.one); |
| 651 | try expect(s.two == s2.two); |
| 652 | } |