Update flow_test.go
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

This commit is contained in:
Aleksandr Tolstikhin 2024-09-14 00:49:33 +07:00
parent f8e97545c1
commit 26e1267f6c

View File

@ -5,33 +5,32 @@ import (
"testing" "testing"
) )
func TestMarshall(t *testing.T) { func FuzzMarshall(f *testing.F) {
a := "json" f.Fuzz(func(t *testing.T, ref []byte) {
res := []byte(a) rm := RawMessage(ref)
m := RawMessage(a)
b, err := m.MarshalJSON() b, err := rm.MarshalJSON()
if err != nil { if err != nil {
t.Errorf("Error %s", err) t.Errorf("Error MarshalJSON: %s", err)
} }
if !reflect.DeepEqual(b, res) { if !reflect.DeepEqual(ref, b) {
t.Errorf("Error %s", err) t.Errorf("Error. Expected '%s', was '%s'", ref, b)
} }
})
} }
func TestUnmarshall(t *testing.T) { func FuzzUnmarshall(f *testing.F) {
strn := "json" f.Fuzz(func(t *testing.T, ref string) {
b := []byte(strn) b := []byte(ref)
// exp := string(b) rm := RawMessage(b)
m := RawMessage(b)
if err := m.UnmarshalJSON(b); err != nil { if err := rm.UnmarshalJSON(b); err != nil {
t.Errorf("Error %s", m) t.Errorf("Error UnmarshalJSON: %s", err)
} }
if string(m) != strn { if ref != string(rm) {
t.Errorf("Error %s", m) t.Errorf("Error. Expected '%s', was '%s'", ref, rm)
} }
})
} }