From e3fd1c833ce195eff7abf52999a299a16694aeaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sun, 6 Mar 2022 09:57:44 +0200 Subject: [PATCH] userGids unit test --- src/sections.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/sections.zig b/src/sections.zig index 015dced..183a22e 100644 --- a/src/sections.zig +++ b/src/sections.zig @@ -466,6 +466,22 @@ test "userGids" { var user_gids = try userGids(allocator, &corpus); defer user_gids.deinit(allocator); + + for (corpus.users) |user| { + const groups = corpus.username2groups.get(user.name); + const offset = user_gids.name2offset.get(user.name); + if (groups == null) { + try testing.expect(offset == null); + continue; + } + var vit = try compress.VarintSliceIterator(user_gids.blob[offset.?..]); + var it = compress.DeltaDecompressionIterator(&vit); + try testing.expectEqual(it.remaining(), groups.?.len); + var i: usize = 0; + while (try it.next()) |gid| : (i += 1) { + try testing.expectEqual(gid, groups.?[i].gid); + } + } } test "pack gids" {