Add fuzz testing to config_test.go

This commit adds a function `FuzzWithAlgorithm` to the configuration test file (config_test.go). The function introduces more comprehensive fuzz testing for the algorithm configuration. It focuses on handling different integers including negative and high numbers, thus enhancing robustness of the algorithm.
This commit is contained in:
Winni Neessen 2024-03-17 22:05:44 +01:00
parent b40b4b7e63
commit 3ffb499c1b
Signed by: wneessen
GPG key ID: 5F3AF39B820C119D

View file

@ -196,3 +196,18 @@ func TestWithModeMask(t *testing.T) {
e, c.Mode)
}
}
func FuzzWithAlgorithm(f *testing.F) {
f.Add(0)
f.Add(1)
f.Add(2)
f.Add(3)
f.Add(-1)
f.Add(100)
f.Fuzz(func(t *testing.T, algo int) {
config := NewConfig(WithAlgorithm(Algorithm(algo)))
if config.MaxLength < config.MinLength {
t.Errorf("Invalid algorithm: %d", algo)
}
})
}