Александр Толстихин
d0f9d44fe4
Coverage default.go Added tests for default.go. The tests are successful Co-authored-by: Aleksandr Tolstikhin <atolstikhin@mtsbank.ru> Co-authored-by: Василий Толстов <v.tolstov@unistack.org> Reviewed-on: #330 Reviewed-by: Василий Толстов <v.tolstov@unistack.org> Co-authored-by: Александр Толстихин <tolstihin1996@mail.ru> Co-committed-by: Александр Толстихин <tolstihin1996@mail.ru>
37 lines
645 B
Go
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)
|
|
}
|
|
})
|
|
}
|