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