in sftest/sftest.go [292:326]
func TestEncodeParseConsistent(
t *testing.T,
samples []Recording,
constr func() (structform.Visitor, func(structform.Visitor) error),
) {
for i, sample := range samples {
sample := sample
expected, err := sample.ToJSON()
if err != nil {
panic(err)
}
title := fmt.Sprintf("test %v: %#v => %v", i, sample, expected)
t.Run(title, func(t *testing.T) {
t.Parallel()
enc, dec := constr()
err = sample.Replay(enc)
if err != nil {
t.Errorf("Failed to encode %#v with %v", sample, err)
return
}
var target Recording
err = dec(&target)
if err != nil {
t.Errorf("Failed to decode %#v with %v", target, err)
t.Logf(" recording: %#v", target)
}
target.Assert(t, sample)
})
}
}