ugly: make getgrnam test pass

This commit is contained in:
Motiejus Jakštys 2022-04-18 06:53:06 +03:00 committed by Motiejus Jakštys
parent 63acece1a4
commit c1e20db0bd

View File

@ -9,6 +9,7 @@ const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const AutoHashMap = std.AutoHashMap;
const BoundedArray = std.BoundedArray;
const ArenaAllocator = std.heap.ArenaAllocator;
const Corpus = @import("Corpus.zig");
const pad = @import("padding.zig");
@ -257,6 +258,7 @@ fn groupMemberNames(
arr.len = num_members;
var buf = std.ArrayList(u8).init(allocator);
errdefer buf.deinit();
// +num_members are for sentinel zeroes
try buf.ensureTotalCapacity(total_members_len + num_members);
@ -624,7 +626,9 @@ test "high-level API" {
var db = try DB.fromCorpus(allocator, &corpus);
defer db.deinit(allocator);
const all = try db.getgrnam(allocator, "all");
var arena = ArenaAllocator.init(allocator);
defer arena.deinit();
const all = try db.getgrnam(arena.allocator(), "all");
try testing.expect(all != null);
try testing.expectEqual(all.?.gid, 9999);
try testing.expectEqualStrings(all.?.name, "all");