Last active
March 28, 2022 17:25
-
-
Save percybolmer/81217d614c304e7620f1afbdf2c0f399 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)
}
`