MCPcopy
hub / github.com/NVIDIA/aistore / TestDecodeAndEncodeFuzz

Function TestDecodeAndEncodeFuzz

cmn/jsp/io_test.go:121–144  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestDecodeAndEncodeFuzz(t *testing.T) {
122 mmsa := memsys.PageMM()
123 b := mmsa.NewSGL(cos.MiB)
124 defer b.Free()
125
126 for i := 0; i < 10000; i++ {
127 var (
128 x, v string
129 opts = jsp.Options{Signature: true, Checksum: true}
130 )
131
132 x = cos.RandString(i)
133
134 err := jsp.Encode(b, x, opts)
135 tassert.CheckFatal(t, err)
136
137 _, err = jsp.Decode(b, &v, opts, fmt.Sprintf("%d", i))
138 tassert.CheckFatal(t, err)
139
140 tassert.Fatalf(t, x == v, "strings are not equal, (got: %+v, expected: %+v)", x, v)
141
142 b.Reset()
143 }
144}
145
146func BenchmarkEncode(b *testing.B) {
147 benches := []struct {

Callers

nothing calls this directly

Calls 9

FreeMethod · 0.95
ResetMethod · 0.95
PageMMFunction · 0.92
RandStringFunction · 0.92
EncodeFunction · 0.92
CheckFatalFunction · 0.92
DecodeFunction · 0.92
FatalfFunction · 0.92
NewSGLMethod · 0.80

Tested by

no test coverage detected