mirror of
https://github.com/wneessen/apg-go.git
synced 2024-12-22 11:10:39 +01:00
Add expanded fuzz testing to algo_test.go
This commit introduces several new fuzz tests to the algo_test.go file. These tests specifically target the IntToAlgo functionality to ensure proper handling of negative, out-of-range, and very large input values. By covering these edge-cases, we enhance the reliability of the algorithm conversion process.
This commit is contained in:
parent
f5f6a12e83
commit
b40b4b7e63
1 changed files with 31 additions and 0 deletions
31
algo_test.go
31
algo_test.go
|
@ -29,3 +29,34 @@ func TestIntToAlgo(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func FuzzIntToAlgo(f *testing.F) {
|
||||
f.Add(-1) // Test negative input
|
||||
f.Add(4) // Test out-of-range positive input
|
||||
f.Add(100) // Test very large input
|
||||
f.Fuzz(func(t *testing.T, a int) {
|
||||
algo := IntToAlgo(a)
|
||||
switch a {
|
||||
case 0:
|
||||
if algo != AlgoPronounceable {
|
||||
t.Errorf("IntToAlgo(%d) expected AlgoPronounceable, got %v", a, algo)
|
||||
}
|
||||
case 1:
|
||||
if algo != AlgoRandom {
|
||||
t.Errorf("IntToAlgo(%d) expected AlgoRandom, got %v", a, algo)
|
||||
}
|
||||
case 2:
|
||||
if algo != AlgoCoinFlip {
|
||||
t.Errorf("IntToAlgo(%d) expected AlgoCoinFlip, got %v", a, algo)
|
||||
}
|
||||
case 3:
|
||||
if algo != AlgoBinary {
|
||||
t.Errorf("IntToAlgo(%d) expected AlgoBinary, got %v", a, algo)
|
||||
}
|
||||
default:
|
||||
if algo != AlgoUnsupported {
|
||||
t.Errorf("IntToAlgo(%d) expected AlgoUnsupported, got %v", a, algo)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue