nits in tests

This commit is contained in:
Motiejus Jakštys 2022-03-16 06:59:12 +02:00 committed by Motiejus Jakštys
parent 9c2f0969dc
commit e142621753

View File

@ -542,19 +542,11 @@ fn testCorpus(allocator: Allocator) !Corpus {
); );
defer members3.deinit(); defer members3.deinit();
const groups = [_]Group{ Group{ const groups = [_]Group{
.gid = 128, Group{ .gid = 128, .name = "vidmantas", .members = members1 },
.name = "vidmantas", Group{ .gid = 9999, .name = "all", .members = members3 },
.members = members1, Group{ .gid = 0, .name = "service-account", .members = members2 },
}, Group{ };
.gid = 9999,
.name = "all",
.members = members3,
}, Group{
.gid = 0,
.name = "service-account",
.members = members2,
} };
return try Corpus.init(allocator, users[0..], groups[0..]); return try Corpus.init(allocator, users[0..], groups[0..]);
} }
@ -705,6 +697,7 @@ test "bdzIdx" {
const allocator = testing.allocator; const allocator = testing.allocator;
const k_u32 = [_]u32{ 42, 1, 2, 3 }; const k_u32 = [_]u32{ 42, 1, 2, 3 };
const k_str = [_][]const u8{ "42", "1", "2", "3" }; const k_str = [_][]const u8{ "42", "1", "2", "3" };
assert(k_u32.len == k_str.len);
const mphf_str = try cmph.packStr(allocator, k_str[0..]); const mphf_str = try cmph.packStr(allocator, k_str[0..]);
const mphf_u32 = try cmph.packU32(allocator, k_u32[0..]); const mphf_u32 = try cmph.packU32(allocator, k_u32[0..]);
defer allocator.free(mphf_str); defer allocator.free(mphf_str);
@ -713,7 +706,7 @@ test "bdzIdx" {
{ {
var result = try bdzIdx(u32, allocator, mphf_u32, k_u32[0..]); var result = try bdzIdx(u32, allocator, mphf_u32, k_u32[0..]);
defer allocator.free(result); defer allocator.free(result);
var used = [_]bool{false} ** 4; var used = [_]bool{false} ** k_u32.len;
for (result) |elem| used[result[elem]] = true; for (result) |elem| used[result[elem]] = true;
for (used) |item| try testing.expect(item); for (used) |item| try testing.expect(item);
} }
@ -721,7 +714,7 @@ test "bdzIdx" {
{ {
var result = try bdzIdx([]const u8, allocator, mphf_str, k_str[0..]); var result = try bdzIdx([]const u8, allocator, mphf_str, k_str[0..]);
defer allocator.free(result); defer allocator.free(result);
var used = [_]bool{false} ** 4; var used = [_]bool{false} ** k_u32.len;
for (result) |elem| used[result[elem]] = true; for (result) |elem| used[result[elem]] = true;
for (used) |item| try testing.expect(item); for (used) |item| try testing.expect(item);
} }