2024-09-12 20:23:54 +03:00
|
|
|
package flow
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2024-09-13 20:49:33 +03:00
|
|
|
func FuzzMarshall(f *testing.F) {
|
|
|
|
f.Fuzz(func(t *testing.T, ref []byte) {
|
|
|
|
rm := RawMessage(ref)
|
|
|
|
|
|
|
|
b, err := rm.MarshalJSON()
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Error MarshalJSON: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !reflect.DeepEqual(ref, b) {
|
|
|
|
t.Errorf("Error. Expected '%s', was '%s'", ref, b)
|
|
|
|
}
|
|
|
|
})
|
2024-09-12 20:23:54 +03:00
|
|
|
}
|
|
|
|
|
2024-09-13 20:49:33 +03:00
|
|
|
func FuzzUnmarshall(f *testing.F) {
|
|
|
|
f.Fuzz(func(t *testing.T, ref string) {
|
|
|
|
b := []byte(ref)
|
|
|
|
rm := RawMessage(b)
|
2024-09-12 20:23:54 +03:00
|
|
|
|
2024-09-13 20:49:33 +03:00
|
|
|
if err := rm.UnmarshalJSON(b); err != nil {
|
|
|
|
t.Errorf("Error UnmarshalJSON: %s", err)
|
|
|
|
}
|
2024-09-12 20:23:54 +03:00
|
|
|
|
2024-09-13 20:49:33 +03:00
|
|
|
if ref != string(rm) {
|
|
|
|
t.Errorf("Error. Expected '%s', was '%s'", ref, rm)
|
|
|
|
}
|
|
|
|
})
|
2024-09-12 20:23:54 +03:00
|
|
|
}
|