mirror of
https://github.com/wneessen/apg-go.git
synced 2024-11-24 14:50:50 +01:00
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:
parent
b40b4b7e63
commit
3ffb499c1b
1 changed files with 15 additions and 0 deletions
|
@ -196,3 +196,18 @@ func TestWithModeMask(t *testing.T) {
|
||||||
e, c.Mode)
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue