commit 2545f44db0ce3e88dc9c59a9cbb18e67e02cc1e4 (tree)
parent 0456b2145de52bf0da3a18cfa3313ca42d7afd29
Author: vegecode <justin.b.alexander1@gmail.com>
Date: Sat, 4 Jul 2020 11:56:19 -0500
byteOffsetOf add fields to non-packet struct to maintain symmetry
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/test/stage1/behavior/sizeof_and_typeof.zig b/test/stage1/behavior/sizeof_and_typeof.zig
@@ -18,6 +18,8 @@ const A = struct {
e: u5,
f: u16,
g: u16,
+ h: u9,
+ i: u7,
};
const P = packed struct {
@@ -53,6 +55,8 @@ test "@byteOffsetOf" {
expect(@ptrToInt(&a.e) - @ptrToInt(&a) == @byteOffsetOf(A, "e"));
expect(@ptrToInt(&a.f) - @ptrToInt(&a) == @byteOffsetOf(A, "f"));
expect(@ptrToInt(&a.g) - @ptrToInt(&a) == @byteOffsetOf(A, "g"));
+ expect(@ptrToInt(&a.h) - @ptrToInt(&a) == @byteOffsetOf(A, "h"));
+ expect(@ptrToInt(&a.i) - @ptrToInt(&a) == @byteOffsetOf(A, "i"));
}
test "@byteOffsetOf packed struct, array length not power of 2 or multiple of native pointer width in bytes" {