From dc5291c62ab489672fc1202eeafa1d59a559e214 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 4 Apr 2017 17:32:56 +0200 Subject: [PATCH] update test files to match the previous commit --- internal/tests/mapconv/output.go | 38 ++++++++++++++-------------- internal/tests/nameclash/output.go | 36 +++++++++++++-------------- internal/tests/omitempty/output.go | 28 ++++++++++----------- internal/tests/sliceconv/output.go | 40 ++++++++++++++---------------- 4 files changed, 67 insertions(+), 75 deletions(-) diff --git a/internal/tests/mapconv/output.go b/internal/tests/mapconv/output.go index 5eaffb4..76d7fd9 100644 --- a/internal/tests/mapconv/output.go +++ b/internal/tests/mapconv/output.go @@ -8,13 +8,13 @@ import ( ) func (x X) MarshalJSON() ([]byte, error) { - type XJSON struct { + type X struct { Map map[replacedString]replacedInt Named namedMap2 NoConv map[string]int NoConvNamed namedMap } - var enc XJSON + var enc X if x.Map != nil { enc.Map = make(map[replacedString]replacedInt, len(x.Map)) for k, v := range x.Map { @@ -33,51 +33,49 @@ func (x X) MarshalJSON() ([]byte, error) { } func (x *X) UnmarshalJSON(input []byte) error { - type XJSON struct { + type X struct { Map map[replacedString]replacedInt Named namedMap2 NoConv map[string]int NoConvNamed namedMap } - var dec XJSON + var dec X if err := json.Unmarshal(input, &dec); err != nil { return err } - var x0 X if dec.Map == nil { return errors.New("missing required field 'map' for X") } - x0.Map = make(map[string]int, len(dec.Map)) + x.Map = make(map[string]int, len(dec.Map)) for k, v := range dec.Map { - x0.Map[string(k)] = int(v) + x.Map[string(k)] = int(v) } if dec.Named == nil { return errors.New("missing required field 'named' for X") } - x0.Named = make(namedMap, len(dec.Named)) + x.Named = make(namedMap, len(dec.Named)) for k, v := range dec.Named { - x0.Named[string(k)] = int(v) + x.Named[string(k)] = int(v) } if dec.NoConv == nil { return errors.New("missing required field 'noConv' for X") } - x0.NoConv = dec.NoConv + x.NoConv = dec.NoConv if dec.NoConvNamed == nil { return errors.New("missing required field 'noConvNamed' for X") } - x0.NoConvNamed = dec.NoConvNamed - *x = x0 + x.NoConvNamed = dec.NoConvNamed return nil } func (x X) MarshalYAML() (interface{}, error) { - type XYAML struct { + type X struct { Map map[replacedString]replacedInt Named namedMap2 NoConv map[string]int NoConvNamed namedMap } - var enc XYAML + var enc X if x.Map != nil { enc.Map = make(map[replacedString]replacedInt, len(x.Map)) for k, v := range x.Map { @@ -96,13 +94,13 @@ func (x X) MarshalYAML() (interface{}, error) { } func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { - type XYAML struct { + type X struct { Map map[replacedString]replacedInt Named namedMap2 NoConv map[string]int NoConvNamed namedMap } - var dec XYAML + var dec X if err := unmarshal(&dec); err != nil { return err } @@ -132,13 +130,13 @@ func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { } func (x X) MarshalTOML() (interface{}, error) { - type XTOML struct { + type X struct { Map map[replacedString]replacedInt Named namedMap2 NoConv map[string]int NoConvNamed namedMap } - var enc XTOML + var enc X if x.Map != nil { enc.Map = make(map[replacedString]replacedInt, len(x.Map)) for k, v := range x.Map { @@ -157,13 +155,13 @@ func (x X) MarshalTOML() (interface{}, error) { } func (x *X) UnmarshalTOML(unmarshal func(interface{}) error) error { - type XTOML struct { + type X struct { Map map[replacedString]replacedInt Named namedMap2 NoConv map[string]int NoConvNamed namedMap } - var dec XTOML + var dec X if err := unmarshal(&dec); err != nil { return err } diff --git a/internal/tests/nameclash/output.go b/internal/tests/nameclash/output.go index d1ebc9e..37a89a1 100644 --- a/internal/tests/nameclash/output.go +++ b/internal/tests/nameclash/output.go @@ -10,14 +10,14 @@ import ( ) func (y Y) MarshalJSON() ([]byte, error) { - type YJSON0 struct { + type Y struct { Foo json0.Foo `optional:"true"` Foo2 json0.Foo `optional:"true"` Bar errors0.Foo `optional:"true"` Gazonk YJSON `optional:"true"` Over enc `optional:"true"` } - var enc0 YJSON0 + var enc0 Y enc0.Foo = y.Foo enc0.Foo2 = y.Foo2 enc0.Bar = y.Bar @@ -27,46 +27,44 @@ func (y Y) MarshalJSON() ([]byte, error) { } func (y *Y) UnmarshalJSON(input []byte) error { - type YJSON0 struct { + type Y struct { Foo *json0.Foo `optional:"true"` Foo2 *json0.Foo `optional:"true"` Bar *errors0.Foo `optional:"true"` Gazonk *YJSON `optional:"true"` Over *enc `optional:"true"` } - var dec YJSON0 + var dec Y if err := json.Unmarshal(input, &dec); err != nil { return err } - var x Y if dec.Foo != nil { - x.Foo = *dec.Foo + y.Foo = *dec.Foo } if dec.Foo2 != nil { - x.Foo2 = *dec.Foo2 + y.Foo2 = *dec.Foo2 } if dec.Bar != nil { - x.Bar = *dec.Bar + y.Bar = *dec.Bar } if dec.Gazonk != nil { - x.Gazonk = *dec.Gazonk + y.Gazonk = *dec.Gazonk } if dec.Over != nil { - x.Over = int(*dec.Over) + y.Over = int(*dec.Over) } - *y = x return nil } func (y Y) MarshalYAML() (interface{}, error) { - type YYAML struct { + type Y struct { Foo json0.Foo `optional:"true"` Foo2 json0.Foo `optional:"true"` Bar errors0.Foo `optional:"true"` Gazonk YJSON `optional:"true"` Over enc `optional:"true"` } - var enc0 YYAML + var enc0 Y enc0.Foo = y.Foo enc0.Foo2 = y.Foo2 enc0.Bar = y.Bar @@ -76,14 +74,14 @@ func (y Y) MarshalYAML() (interface{}, error) { } func (y *Y) UnmarshalYAML(unmarshal func(interface{}) error) error { - type YYAML struct { + type Y struct { Foo *json0.Foo `optional:"true"` Foo2 *json0.Foo `optional:"true"` Bar *errors0.Foo `optional:"true"` Gazonk *YJSON `optional:"true"` Over *enc `optional:"true"` } - var dec YYAML + var dec Y if err := unmarshal(&dec); err != nil { return err } @@ -106,14 +104,14 @@ func (y *Y) UnmarshalYAML(unmarshal func(interface{}) error) error { } func (y Y) MarshalTOML() (interface{}, error) { - type YTOML struct { + type Y struct { Foo json0.Foo `optional:"true"` Foo2 json0.Foo `optional:"true"` Bar errors0.Foo `optional:"true"` Gazonk YJSON `optional:"true"` Over enc `optional:"true"` } - var enc0 YTOML + var enc0 Y enc0.Foo = y.Foo enc0.Foo2 = y.Foo2 enc0.Bar = y.Bar @@ -123,14 +121,14 @@ func (y Y) MarshalTOML() (interface{}, error) { } func (y *Y) UnmarshalTOML(unmarshal func(interface{}) error) error { - type YTOML struct { + type Y struct { Foo *json0.Foo `optional:"true"` Foo2 *json0.Foo `optional:"true"` Bar *errors0.Foo `optional:"true"` Gazonk *YJSON `optional:"true"` Over *enc `optional:"true"` } - var dec YTOML + var dec Y if err := unmarshal(&dec); err != nil { return err } diff --git a/internal/tests/omitempty/output.go b/internal/tests/omitempty/output.go index d2a3770..cd9b9ac 100644 --- a/internal/tests/omitempty/output.go +++ b/internal/tests/omitempty/output.go @@ -8,45 +8,43 @@ import ( ) func (x X) MarshalJSON() ([]byte, error) { - type XJSON struct { + type X struct { Int replacedInt `json:",omitempty"` } - var enc XJSON + var enc X enc.Int = replacedInt(x.Int) return json.Marshal(&enc) } func (x *X) UnmarshalJSON(input []byte) error { - type XJSON struct { + type X struct { Int *replacedInt `json:",omitempty"` } - var dec XJSON + var dec X if err := json.Unmarshal(input, &dec); err != nil { return err } - var x0 X if dec.Int == nil { return errors.New("missing required field 'int' for X") } - x0.Int = int(*dec.Int) - *x = x0 + x.Int = int(*dec.Int) return nil } func (x X) MarshalYAML() (interface{}, error) { - type XYAML struct { + type X struct { Int replacedInt `json:",omitempty"` } - var enc XYAML + var enc X enc.Int = replacedInt(x.Int) return &enc, nil } func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { - type XYAML struct { + type X struct { Int *replacedInt `json:",omitempty"` } - var dec XYAML + var dec X if err := unmarshal(&dec); err != nil { return err } @@ -58,19 +56,19 @@ func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { } func (x X) MarshalTOML() (interface{}, error) { - type XTOML struct { + type X struct { Int replacedInt `json:",omitempty"` } - var enc XTOML + var enc X enc.Int = replacedInt(x.Int) return &enc, nil } func (x *X) UnmarshalTOML(unmarshal func(interface{}) error) error { - type XTOML struct { + type X struct { Int *replacedInt `json:",omitempty"` } - var dec XTOML + var dec X if err := unmarshal(&dec); err != nil { return err } diff --git a/internal/tests/sliceconv/output.go b/internal/tests/sliceconv/output.go index 3e14114..0c0b028 100644 --- a/internal/tests/sliceconv/output.go +++ b/internal/tests/sliceconv/output.go @@ -8,14 +8,14 @@ import ( ) func (x X) MarshalJSON() ([]byte, error) { - type XJSON struct { + type X struct { Slice []replacedInt Named namedSlice2 ByteString []byte NoConv []int NoConvNamed namedSlice } - var enc XJSON + var enc X if x.Slice != nil { enc.Slice = make([]replacedInt, len(x.Slice)) for k, v := range x.Slice { @@ -35,57 +35,55 @@ func (x X) MarshalJSON() ([]byte, error) { } func (x *X) UnmarshalJSON(input []byte) error { - type XJSON struct { + type X struct { Slice []replacedInt Named namedSlice2 ByteString []byte NoConv []int NoConvNamed namedSlice } - var dec XJSON + var dec X if err := json.Unmarshal(input, &dec); err != nil { return err } - var x0 X if dec.Slice == nil { return errors.New("missing required field 'slice' for X") } - x0.Slice = make([]int, len(dec.Slice)) + x.Slice = make([]int, len(dec.Slice)) for k, v := range dec.Slice { - x0.Slice[k] = int(v) + x.Slice[k] = int(v) } if dec.Named == nil { return errors.New("missing required field 'named' for X") } - x0.Named = make(namedSlice, len(dec.Named)) + x.Named = make(namedSlice, len(dec.Named)) for k, v := range dec.Named { - x0.Named[k] = int(v) + x.Named[k] = int(v) } if dec.ByteString == nil { return errors.New("missing required field 'byteString' for X") } - x0.ByteString = string(dec.ByteString) + x.ByteString = string(dec.ByteString) if dec.NoConv == nil { return errors.New("missing required field 'noConv' for X") } - x0.NoConv = dec.NoConv + x.NoConv = dec.NoConv if dec.NoConvNamed == nil { return errors.New("missing required field 'noConvNamed' for X") } - x0.NoConvNamed = dec.NoConvNamed - *x = x0 + x.NoConvNamed = dec.NoConvNamed return nil } func (x X) MarshalYAML() (interface{}, error) { - type XYAML struct { + type X struct { Slice []replacedInt Named namedSlice2 ByteString []byte NoConv []int NoConvNamed namedSlice } - var enc XYAML + var enc X if x.Slice != nil { enc.Slice = make([]replacedInt, len(x.Slice)) for k, v := range x.Slice { @@ -105,14 +103,14 @@ func (x X) MarshalYAML() (interface{}, error) { } func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { - type XYAML struct { + type X struct { Slice []replacedInt Named namedSlice2 ByteString []byte NoConv []int NoConvNamed namedSlice } - var dec XYAML + var dec X if err := unmarshal(&dec); err != nil { return err } @@ -146,14 +144,14 @@ func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { } func (x X) MarshalTOML() (interface{}, error) { - type XTOML struct { + type X struct { Slice []replacedInt Named namedSlice2 ByteString []byte NoConv []int NoConvNamed namedSlice } - var enc XTOML + var enc X if x.Slice != nil { enc.Slice = make([]replacedInt, len(x.Slice)) for k, v := range x.Slice { @@ -173,14 +171,14 @@ func (x X) MarshalTOML() (interface{}, error) { } func (x *X) UnmarshalTOML(unmarshal func(interface{}) error) error { - type XTOML struct { + type X struct { Slice []replacedInt Named namedSlice2 ByteString []byte NoConv []int NoConvNamed namedSlice } - var dec XTOML + var dec X if err := unmarshal(&dec); err != nil { return err }