test_pointer_to_non-byte_aligned_field.zig (300B) - Raw
1 const std = @import("std"); 2 const expect = std.testing.expect; 3 4 const BitField = packed struct { 5 a: u3, 6 b: u3, 7 c: u2, 8 }; 9 10 var foo = BitField{ 11 .a = 1, 12 .b = 2, 13 .c = 3, 14 }; 15 16 test "pointer to non-byte-aligned field" { 17 const ptr = &foo.b; 18 try expect(ptr.* == 2); 19 } 20 21 // test