1
Fork 0

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.
main
Motiejus Jakštys 2022-02-18 17:38:22 +02:00 committed by Motiejus Jakštys
parent 1fe23aa1e5
commit eacfc08592
1 changed files with 3 additions and 3 deletions

View File

@ -1,7 +1,7 @@
const std = @import("std");
const PackedUserSize = @sizeOf(PackedUser);
const PackedUser = packed struct {
pub const PackedUserSize = @sizeOf(PackedUser);
pub const PackedUser = packed struct {
uid: u32,
gid: u32,
additional_gids_offset: u29,
@ -16,5 +16,5 @@ const PackedUser = packed struct {
const testing = std.testing;
test "PackedUser is byte-aligned" {
//try testing.expectEqual(PackedUserSize * 8, @bitSizeOf(PackedUser));
try testing.expectEqual(0, @rem(@bitSizeOf(PackedUser), 8));
}