init repo
This commit is contained in:
37
queue_fuzz_test.go
Normal file
37
queue_fuzz_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package actor
|
||||
|
||||
import "testing"
|
||||
|
||||
func FuzzQueueOperations(f *testing.F) {
|
||||
seeds := [][]byte{
|
||||
{},
|
||||
{2, 3, 4}, // Singleton zero value.
|
||||
{0, 0, 8, 1, 3, 4, 2, 4, 3, 4}, // Publish reservations out of order.
|
||||
{2, 2, 2, 2, 3, 4, 2, 4, 2, 4, 4, 3, 4, 4}, // Partial batch, then republish.
|
||||
{2, 2, 2, 2, 2, 6, 4, 4, 2, 4, 4, 4, 3, 4}, // Publish during reversal.
|
||||
{0, 2, 2, 3, 4, 4, 1, 3, 4, 2, 3, 4}, // Delayed fixed reservation.
|
||||
}
|
||||
for capacity := range byte(5) {
|
||||
for _, seed := range seeds {
|
||||
f.Add(capacity, seed)
|
||||
}
|
||||
// Give every capacity a seed with repeated complete fixed rounds and
|
||||
// dynamic overflow, in addition to the partial-consumption seeds above.
|
||||
var cycles []byte
|
||||
for range 3 {
|
||||
count := [...]int{1, 2, 3, 8, 64}[capacity] + 2
|
||||
for range count {
|
||||
cycles = append(cycles, 2)
|
||||
}
|
||||
cycles = append(cycles, 3)
|
||||
for range count {
|
||||
cycles = append(cycles, 4)
|
||||
}
|
||||
}
|
||||
f.Add(capacity, cycles)
|
||||
}
|
||||
f.Fuzz(func(t *testing.T, capacity byte, operations []byte) {
|
||||
capacities := [...]int{1, 2, 3, 8, 64}
|
||||
runQueueModel(t, capacities[int(capacity)%len(capacities)], operations)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user