fix PackedUser test
It is 120 bits long. @sizeOf returns 128, because, I guess, it tries to word-align it (not byte-align it). We are OK with non-word-aligned user struct, since it will have an arbitrary []u8 slice right after it with the string data. However, byte-alignment is important.
This commit is contained in:
parent
1fe23aa1e5
commit
eacfc08592
@ -1,7 +1,7 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
const PackedUserSize = @sizeOf(PackedUser);
|
pub const PackedUserSize = @sizeOf(PackedUser);
|
||||||
const PackedUser = packed struct {
|
pub const PackedUser = packed struct {
|
||||||
uid: u32,
|
uid: u32,
|
||||||
gid: u32,
|
gid: u32,
|
||||||
additional_gids_offset: u29,
|
additional_gids_offset: u29,
|
||||||
@ -16,5 +16,5 @@ const PackedUser = packed struct {
|
|||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
|
|
||||||
test "PackedUser is byte-aligned" {
|
test "PackedUser is byte-aligned" {
|
||||||
//try testing.expectEqual(PackedUserSize * 8, @bitSizeOf(PackedUser));
|
try testing.expectEqual(0, @rem(@bitSizeOf(PackedUser), 8));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user