micro/flow/flow_test.go
Aleksandr Tolstikhin 26e1267f6c
All checks were successful
pr / test (pull_request) Successful in 1m38s
lint / lint (pull_request) Successful in 9m49s
Go / test (pull_request) Successful in 10m34s
Update flow_test.go
2024-09-14 00:49:33 +07:00

37 lines
645 B
Go

package flow
import (
"reflect"
"testing"
)
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)
}
})
}
func FuzzUnmarshall(f *testing.F) {
f.Fuzz(func(t *testing.T, ref string) {
b := []byte(ref)
rm := RawMessage(b)
if err := rm.UnmarshalJSON(b); err != nil {
t.Errorf("Error UnmarshalJSON: %s", err)
}
if ref != string(rm) {
t.Errorf("Error. Expected '%s', was '%s'", ref, rm)
}
})
}