Heyo, I wanted to try and fuzz something using master as of today but failed to use the api correctly. How do I fuzz test a test case?
I managed to get it to work (correctly, as far as I can tell).
The function std.testing.fuzzInput
no longer exists. Instead, the user has to wrap the test in a function with the signature fn ([]const u8) anyerror!void
and the pass that function to std.testing.fuzzInput
. To run, type zig build test --fuzz
.
Could you provide a code example?
const std = @import("std");
test {
try std.testing.fuzz(struct {
fn testOne(input: []const u8) anyerror!void {
try std.testing.expect(input.len != 2);
}
}.testOne, .{});
}
4 Likes