-
-
Save percybolmer/81217d614c304e7620f1afbdf2c0f399 to your computer and use it in GitHub Desktop.
func MultipleInputs(a, b int, name string) { | |
// ... fancy code goes here | |
} | |
func FuzzMultipleInputs(f *testing.F) { | |
// We can add Multiple Seeds, but it has to be the same order as the input parameters for MultipleInputs | |
f.Add(10,20,"John the Ripper") | |
f.Fuzz(func(t *testing.T,a int,b int,name string){ | |
MultipleInputs(a,b,name) | |
}) | |
} |
Hey Monkrus! Thanks for reachig out,
It does look correct, there is just one small minor issue.
f.Fuzz accepts a function, which you pass in as a anonymous function( undecleared function) This is a short syntax, but it can confuse sometimes.
In your function you declare that there will be 3 local scoped variables
t which is a *testing.T
a and b which are ints.
But then you pass x and y into Multi. So simply rename the variables in the function to x and y and it should work :)
To make it clearer, you could use 3 functions instead
`func Multi(x int, y int) int {
return x * y
}
func FuzzMulti(f *testing.F) {
f.Add(10,20)
f.Fuzz(StuffToFuzz)
}
func StuffToFuzz(f *testing.F, x int, y int) {
Multi(x,y)
}
`
Hi @percybolmer, thank you very much for the detailed explanation! Not it is all clear for me!
Does it look right? Getting an
undeclared name
error for x and y in the last line.Thank you!