diff --git a/config/default_test.go b/config/default_test.go index d790fb5f..de104c2a 100644 --- a/config/default_test.go +++ b/config/default_test.go @@ -31,6 +31,9 @@ func (c *cfg) Validate() error { if c.IntValue != 10 { return fmt.Errorf("invalid IntValue %d != %d", 10, c.IntValue) } + if c.MapValue["key1"] != true { + return fmt.Errorf("invalid MapValue %t != %t", true, c.MapValue["key1"]) + } return nil } @@ -105,3 +108,19 @@ func TestValidate(t *testing.T) { t.Fatal(err) } } + +func TestString(t *testing.T) { + cfg := config.NewConfig() + res := cfg.String() + if res != "default" { + t.Fatalf("string value invalid: %s", res) + } +} + +func TestName(t *testing.T) { + cfg := config.NewConfig() + res := cfg.Name() + if res != "" { + t.Fatal("name value not empty") + } +} diff --git a/flow/flow_test.go b/flow/flow_test.go new file mode 100644 index 00000000..3adcdfff --- /dev/null +++ b/flow/flow_test.go @@ -0,0 +1,36 @@ +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) + } + }) +}