1
Fork 0

userGids unit test

This commit is contained in:
Motiejus Jakštys 2022-03-06 09:57:44 +02:00 committed by Motiejus Jakštys
parent efd3cfc367
commit e3fd1c833c
1 changed files with 16 additions and 0 deletions

View File

@ -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" {