split bdz int and str tests
This commit is contained in:
parent
e142621753
commit
c721fa6d5d
@ -693,29 +693,30 @@ test "users compare function" {
|
|||||||
try testing.expect(!cmpUser({}, bb, b));
|
try testing.expect(!cmpUser({}, bb, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "bdzIdx" {
|
fn expectUsedHashes(allocator: Allocator, arr: []const u32) !void {
|
||||||
const allocator = testing.allocator;
|
var used = try allocator.alloc(bool, arr.len);
|
||||||
const k_u32 = [_]u32{ 42, 1, 2, 3 };
|
defer allocator.free(used);
|
||||||
const k_str = [_][]const u8{ "42", "1", "2", "3" };
|
mem.set(bool, used, false);
|
||||||
assert(k_u32.len == k_str.len);
|
for (arr) |elem|
|
||||||
const mphf_str = try cmph.packStr(allocator, k_str[0..]);
|
used[arr[elem]] = true;
|
||||||
const mphf_u32 = try cmph.packU32(allocator, k_u32[0..]);
|
for (used) |item|
|
||||||
defer allocator.free(mphf_str);
|
try testing.expect(item);
|
||||||
defer allocator.free(mphf_u32);
|
|
||||||
|
|
||||||
{
|
|
||||||
var result = try bdzIdx(u32, allocator, mphf_u32, k_u32[0..]);
|
|
||||||
defer allocator.free(result);
|
|
||||||
var used = [_]bool{false} ** k_u32.len;
|
|
||||||
for (result) |elem| used[result[elem]] = true;
|
|
||||||
for (used) |item| try testing.expect(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
test "bdzIdx on u32" {
|
||||||
var result = try bdzIdx([]const u8, allocator, mphf_str, k_str[0..]);
|
const keys = [_]u32{ 42, 1, 2, 3 };
|
||||||
defer allocator.free(result);
|
const mphf = try cmph.packU32(testing.allocator, keys[0..]);
|
||||||
var used = [_]bool{false} ** k_u32.len;
|
defer testing.allocator.free(mphf);
|
||||||
for (result) |elem| used[result[elem]] = true;
|
var result = try bdzIdx(u32, testing.allocator, mphf, keys[0..]);
|
||||||
for (used) |item| try testing.expect(item);
|
defer testing.allocator.free(result);
|
||||||
|
try expectUsedHashes(testing.allocator, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "bdzIdx on str" {
|
||||||
|
const keys = [_][]const u8{ "42", "1", "2", "3" };
|
||||||
|
const mphf = try cmph.packStr(testing.allocator, keys[0..]);
|
||||||
|
defer testing.allocator.free(mphf);
|
||||||
|
var result = try bdzIdx([]const u8, testing.allocator, mphf, keys[0..]);
|
||||||
|
defer testing.allocator.free(result);
|
||||||
|
try expectUsedHashes(testing.allocator, result);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user