github.com/thepudds/swisstable@v0.0.0-20221011152303-9c77dc657777/autofuzzchain_test.go (about) 1 package swisstable 2 3 // Edit if desired. Code generated by "fzgen -chain .". 4 5 import ( 6 "testing" 7 8 "github.com/google/go-cmp/cmp" 9 "github.com/thepudds/fzgen/fuzzer" 10 ) 11 12 func Fuzz_NewVmap_Chain(f *testing.F) { 13 f.Fuzz(func(t *testing.T, data []byte) { 14 var capacity byte 15 fz := fuzzer.NewFuzzer(data) 16 fz.Fill(&capacity) 17 18 target := NewVmap(capacity, nil) 19 20 steps := []fuzzer.Step{ 21 { 22 Name: "Fuzz_ValidatingMap_Delete", 23 Func: func(k Key) { 24 target.Delete(k) 25 }, 26 }, 27 { 28 Name: "Fuzz_ValidatingMap_DeleteBulk", 29 Func: func(list Keys) { 30 target.DeleteBulk(list) 31 }, 32 }, 33 { 34 Name: "Fuzz_ValidatingMap_Get", 35 Func: func(k Key) (Value, bool) { 36 return target.Get(k) 37 }, 38 }, 39 { 40 Name: "Fuzz_ValidatingMap_GetBulk", 41 Func: func(list Keys) ([]Value, []bool) { 42 return target.GetBulk(list) 43 }, 44 }, 45 { 46 Name: "Fuzz_ValidatingMap_Len", 47 Func: func() int { 48 return target.Len() 49 }, 50 }, 51 { 52 Name: "Fuzz_ValidatingMap_Range", 53 Func: func(ops []Op) { 54 target.Range(ops) 55 }, 56 }, 57 { 58 Name: "Fuzz_ValidatingMap_Set", 59 Func: func(k Key, v Value) { 60 target.Set(k, v) 61 }, 62 }, 63 { 64 Name: "Fuzz_ValidatingMap_SetBulk", 65 Func: func(list Keys) { 66 target.SetBulk(list) 67 }, 68 }, 69 } 70 71 // Execute a specific chain of steps, with the count, sequence and arguments controlled by fz.Chain 72 fz.Chain(steps) 73 74 // Final validation. 75 got := keysAndValues(target.m) 76 if diff := cmp.Diff(target.mirror, got); diff != "" { 77 t.Errorf("Fuzz_NewVmap_Chain target mismatch after steps completed (-want +got):\n%s", diff) 78 } 79 }) 80 }