update test files to match the previous commit

master
Felix Lange 8 years ago
parent 1c8a99a71b
commit dc5291c62a
  1. 38
      internal/tests/mapconv/output.go
  2. 36
      internal/tests/nameclash/output.go
  3. 28
      internal/tests/omitempty/output.go
  4. 40
      internal/tests/sliceconv/output.go

@ -8,13 +8,13 @@ import (
) )
func (x X) MarshalJSON() ([]byte, error) { func (x X) MarshalJSON() ([]byte, error) {
type XJSON struct { type X struct {
Map map[replacedString]replacedInt Map map[replacedString]replacedInt
Named namedMap2 Named namedMap2
NoConv map[string]int NoConv map[string]int
NoConvNamed namedMap NoConvNamed namedMap
} }
var enc XJSON var enc X
if x.Map != nil { if x.Map != nil {
enc.Map = make(map[replacedString]replacedInt, len(x.Map)) enc.Map = make(map[replacedString]replacedInt, len(x.Map))
for k, v := range 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 { func (x *X) UnmarshalJSON(input []byte) error {
type XJSON struct { type X struct {
Map map[replacedString]replacedInt Map map[replacedString]replacedInt
Named namedMap2 Named namedMap2
NoConv map[string]int NoConv map[string]int
NoConvNamed namedMap NoConvNamed namedMap
} }
var dec XJSON var dec X
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
return err return err
} }
var x0 X
if dec.Map == nil { if dec.Map == nil {
return errors.New("missing required field 'map' for X") 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 { for k, v := range dec.Map {
x0.Map[string(k)] = int(v) x.Map[string(k)] = int(v)
} }
if dec.Named == nil { if dec.Named == nil {
return errors.New("missing required field 'named' for X") 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 { for k, v := range dec.Named {
x0.Named[string(k)] = int(v) x.Named[string(k)] = int(v)
} }
if dec.NoConv == nil { if dec.NoConv == nil {
return errors.New("missing required field 'noConv' for X") return errors.New("missing required field 'noConv' for X")
} }
x0.NoConv = dec.NoConv x.NoConv = dec.NoConv
if dec.NoConvNamed == nil { if dec.NoConvNamed == nil {
return errors.New("missing required field 'noConvNamed' for X") return errors.New("missing required field 'noConvNamed' for X")
} }
x0.NoConvNamed = dec.NoConvNamed x.NoConvNamed = dec.NoConvNamed
*x = x0
return nil return nil
} }
func (x X) MarshalYAML() (interface{}, error) { func (x X) MarshalYAML() (interface{}, error) {
type XYAML struct { type X struct {
Map map[replacedString]replacedInt Map map[replacedString]replacedInt
Named namedMap2 Named namedMap2
NoConv map[string]int NoConv map[string]int
NoConvNamed namedMap NoConvNamed namedMap
} }
var enc XYAML var enc X
if x.Map != nil { if x.Map != nil {
enc.Map = make(map[replacedString]replacedInt, len(x.Map)) enc.Map = make(map[replacedString]replacedInt, len(x.Map))
for k, v := range 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 { func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error {
type XYAML struct { type X struct {
Map map[replacedString]replacedInt Map map[replacedString]replacedInt
Named namedMap2 Named namedMap2
NoConv map[string]int NoConv map[string]int
NoConvNamed namedMap NoConvNamed namedMap
} }
var dec XYAML var dec X
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }
@ -132,13 +130,13 @@ func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error {
} }
func (x X) MarshalTOML() (interface{}, error) { func (x X) MarshalTOML() (interface{}, error) {
type XTOML struct { type X struct {
Map map[replacedString]replacedInt Map map[replacedString]replacedInt
Named namedMap2 Named namedMap2
NoConv map[string]int NoConv map[string]int
NoConvNamed namedMap NoConvNamed namedMap
} }
var enc XTOML var enc X
if x.Map != nil { if x.Map != nil {
enc.Map = make(map[replacedString]replacedInt, len(x.Map)) enc.Map = make(map[replacedString]replacedInt, len(x.Map))
for k, v := range 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 { func (x *X) UnmarshalTOML(unmarshal func(interface{}) error) error {
type XTOML struct { type X struct {
Map map[replacedString]replacedInt Map map[replacedString]replacedInt
Named namedMap2 Named namedMap2
NoConv map[string]int NoConv map[string]int
NoConvNamed namedMap NoConvNamed namedMap
} }
var dec XTOML var dec X
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }

@ -10,14 +10,14 @@ import (
) )
func (y Y) MarshalJSON() ([]byte, error) { func (y Y) MarshalJSON() ([]byte, error) {
type YJSON0 struct { type Y struct {
Foo json0.Foo `optional:"true"` Foo json0.Foo `optional:"true"`
Foo2 json0.Foo `optional:"true"` Foo2 json0.Foo `optional:"true"`
Bar errors0.Foo `optional:"true"` Bar errors0.Foo `optional:"true"`
Gazonk YJSON `optional:"true"` Gazonk YJSON `optional:"true"`
Over enc `optional:"true"` Over enc `optional:"true"`
} }
var enc0 YJSON0 var enc0 Y
enc0.Foo = y.Foo enc0.Foo = y.Foo
enc0.Foo2 = y.Foo2 enc0.Foo2 = y.Foo2
enc0.Bar = y.Bar enc0.Bar = y.Bar
@ -27,46 +27,44 @@ func (y Y) MarshalJSON() ([]byte, error) {
} }
func (y *Y) UnmarshalJSON(input []byte) error { func (y *Y) UnmarshalJSON(input []byte) error {
type YJSON0 struct { type Y struct {
Foo *json0.Foo `optional:"true"` Foo *json0.Foo `optional:"true"`
Foo2 *json0.Foo `optional:"true"` Foo2 *json0.Foo `optional:"true"`
Bar *errors0.Foo `optional:"true"` Bar *errors0.Foo `optional:"true"`
Gazonk *YJSON `optional:"true"` Gazonk *YJSON `optional:"true"`
Over *enc `optional:"true"` Over *enc `optional:"true"`
} }
var dec YJSON0 var dec Y
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
return err return err
} }
var x Y
if dec.Foo != nil { if dec.Foo != nil {
x.Foo = *dec.Foo y.Foo = *dec.Foo
} }
if dec.Foo2 != nil { if dec.Foo2 != nil {
x.Foo2 = *dec.Foo2 y.Foo2 = *dec.Foo2
} }
if dec.Bar != nil { if dec.Bar != nil {
x.Bar = *dec.Bar y.Bar = *dec.Bar
} }
if dec.Gazonk != nil { if dec.Gazonk != nil {
x.Gazonk = *dec.Gazonk y.Gazonk = *dec.Gazonk
} }
if dec.Over != nil { if dec.Over != nil {
x.Over = int(*dec.Over) y.Over = int(*dec.Over)
} }
*y = x
return nil return nil
} }
func (y Y) MarshalYAML() (interface{}, error) { func (y Y) MarshalYAML() (interface{}, error) {
type YYAML struct { type Y struct {
Foo json0.Foo `optional:"true"` Foo json0.Foo `optional:"true"`
Foo2 json0.Foo `optional:"true"` Foo2 json0.Foo `optional:"true"`
Bar errors0.Foo `optional:"true"` Bar errors0.Foo `optional:"true"`
Gazonk YJSON `optional:"true"` Gazonk YJSON `optional:"true"`
Over enc `optional:"true"` Over enc `optional:"true"`
} }
var enc0 YYAML var enc0 Y
enc0.Foo = y.Foo enc0.Foo = y.Foo
enc0.Foo2 = y.Foo2 enc0.Foo2 = y.Foo2
enc0.Bar = y.Bar enc0.Bar = y.Bar
@ -76,14 +74,14 @@ func (y Y) MarshalYAML() (interface{}, error) {
} }
func (y *Y) UnmarshalYAML(unmarshal func(interface{}) error) error { func (y *Y) UnmarshalYAML(unmarshal func(interface{}) error) error {
type YYAML struct { type Y struct {
Foo *json0.Foo `optional:"true"` Foo *json0.Foo `optional:"true"`
Foo2 *json0.Foo `optional:"true"` Foo2 *json0.Foo `optional:"true"`
Bar *errors0.Foo `optional:"true"` Bar *errors0.Foo `optional:"true"`
Gazonk *YJSON `optional:"true"` Gazonk *YJSON `optional:"true"`
Over *enc `optional:"true"` Over *enc `optional:"true"`
} }
var dec YYAML var dec Y
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }
@ -106,14 +104,14 @@ func (y *Y) UnmarshalYAML(unmarshal func(interface{}) error) error {
} }
func (y Y) MarshalTOML() (interface{}, error) { func (y Y) MarshalTOML() (interface{}, error) {
type YTOML struct { type Y struct {
Foo json0.Foo `optional:"true"` Foo json0.Foo `optional:"true"`
Foo2 json0.Foo `optional:"true"` Foo2 json0.Foo `optional:"true"`
Bar errors0.Foo `optional:"true"` Bar errors0.Foo `optional:"true"`
Gazonk YJSON `optional:"true"` Gazonk YJSON `optional:"true"`
Over enc `optional:"true"` Over enc `optional:"true"`
} }
var enc0 YTOML var enc0 Y
enc0.Foo = y.Foo enc0.Foo = y.Foo
enc0.Foo2 = y.Foo2 enc0.Foo2 = y.Foo2
enc0.Bar = y.Bar enc0.Bar = y.Bar
@ -123,14 +121,14 @@ func (y Y) MarshalTOML() (interface{}, error) {
} }
func (y *Y) UnmarshalTOML(unmarshal func(interface{}) error) error { func (y *Y) UnmarshalTOML(unmarshal func(interface{}) error) error {
type YTOML struct { type Y struct {
Foo *json0.Foo `optional:"true"` Foo *json0.Foo `optional:"true"`
Foo2 *json0.Foo `optional:"true"` Foo2 *json0.Foo `optional:"true"`
Bar *errors0.Foo `optional:"true"` Bar *errors0.Foo `optional:"true"`
Gazonk *YJSON `optional:"true"` Gazonk *YJSON `optional:"true"`
Over *enc `optional:"true"` Over *enc `optional:"true"`
} }
var dec YTOML var dec Y
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }

@ -8,45 +8,43 @@ import (
) )
func (x X) MarshalJSON() ([]byte, error) { func (x X) MarshalJSON() ([]byte, error) {
type XJSON struct { type X struct {
Int replacedInt `json:",omitempty"` Int replacedInt `json:",omitempty"`
} }
var enc XJSON var enc X
enc.Int = replacedInt(x.Int) enc.Int = replacedInt(x.Int)
return json.Marshal(&enc) return json.Marshal(&enc)
} }
func (x *X) UnmarshalJSON(input []byte) error { func (x *X) UnmarshalJSON(input []byte) error {
type XJSON struct { type X struct {
Int *replacedInt `json:",omitempty"` Int *replacedInt `json:",omitempty"`
} }
var dec XJSON var dec X
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
return err return err
} }
var x0 X
if dec.Int == nil { if dec.Int == nil {
return errors.New("missing required field 'int' for X") return errors.New("missing required field 'int' for X")
} }
x0.Int = int(*dec.Int) x.Int = int(*dec.Int)
*x = x0
return nil return nil
} }
func (x X) MarshalYAML() (interface{}, error) { func (x X) MarshalYAML() (interface{}, error) {
type XYAML struct { type X struct {
Int replacedInt `json:",omitempty"` Int replacedInt `json:",omitempty"`
} }
var enc XYAML var enc X
enc.Int = replacedInt(x.Int) enc.Int = replacedInt(x.Int)
return &enc, nil return &enc, nil
} }
func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error {
type XYAML struct { type X struct {
Int *replacedInt `json:",omitempty"` Int *replacedInt `json:",omitempty"`
} }
var dec XYAML var dec X
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }
@ -58,19 +56,19 @@ func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error {
} }
func (x X) MarshalTOML() (interface{}, error) { func (x X) MarshalTOML() (interface{}, error) {
type XTOML struct { type X struct {
Int replacedInt `json:",omitempty"` Int replacedInt `json:",omitempty"`
} }
var enc XTOML var enc X
enc.Int = replacedInt(x.Int) enc.Int = replacedInt(x.Int)
return &enc, nil return &enc, nil
} }
func (x *X) UnmarshalTOML(unmarshal func(interface{}) error) error { func (x *X) UnmarshalTOML(unmarshal func(interface{}) error) error {
type XTOML struct { type X struct {
Int *replacedInt `json:",omitempty"` Int *replacedInt `json:",omitempty"`
} }
var dec XTOML var dec X
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }

@ -8,14 +8,14 @@ import (
) )
func (x X) MarshalJSON() ([]byte, error) { func (x X) MarshalJSON() ([]byte, error) {
type XJSON struct { type X struct {
Slice []replacedInt Slice []replacedInt
Named namedSlice2 Named namedSlice2
ByteString []byte ByteString []byte
NoConv []int NoConv []int
NoConvNamed namedSlice NoConvNamed namedSlice
} }
var enc XJSON var enc X
if x.Slice != nil { if x.Slice != nil {
enc.Slice = make([]replacedInt, len(x.Slice)) enc.Slice = make([]replacedInt, len(x.Slice))
for k, v := range 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 { func (x *X) UnmarshalJSON(input []byte) error {
type XJSON struct { type X struct {
Slice []replacedInt Slice []replacedInt
Named namedSlice2 Named namedSlice2
ByteString []byte ByteString []byte
NoConv []int NoConv []int
NoConvNamed namedSlice NoConvNamed namedSlice
} }
var dec XJSON var dec X
if err := json.Unmarshal(input, &dec); err != nil { if err := json.Unmarshal(input, &dec); err != nil {
return err return err
} }
var x0 X
if dec.Slice == nil { if dec.Slice == nil {
return errors.New("missing required field 'slice' for X") 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 { for k, v := range dec.Slice {
x0.Slice[k] = int(v) x.Slice[k] = int(v)
} }
if dec.Named == nil { if dec.Named == nil {
return errors.New("missing required field 'named' for X") 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 { for k, v := range dec.Named {
x0.Named[k] = int(v) x.Named[k] = int(v)
} }
if dec.ByteString == nil { if dec.ByteString == nil {
return errors.New("missing required field 'byteString' for X") return errors.New("missing required field 'byteString' for X")
} }
x0.ByteString = string(dec.ByteString) x.ByteString = string(dec.ByteString)
if dec.NoConv == nil { if dec.NoConv == nil {
return errors.New("missing required field 'noConv' for X") return errors.New("missing required field 'noConv' for X")
} }
x0.NoConv = dec.NoConv x.NoConv = dec.NoConv
if dec.NoConvNamed == nil { if dec.NoConvNamed == nil {
return errors.New("missing required field 'noConvNamed' for X") return errors.New("missing required field 'noConvNamed' for X")
} }
x0.NoConvNamed = dec.NoConvNamed x.NoConvNamed = dec.NoConvNamed
*x = x0
return nil return nil
} }
func (x X) MarshalYAML() (interface{}, error) { func (x X) MarshalYAML() (interface{}, error) {
type XYAML struct { type X struct {
Slice []replacedInt Slice []replacedInt
Named namedSlice2 Named namedSlice2
ByteString []byte ByteString []byte
NoConv []int NoConv []int
NoConvNamed namedSlice NoConvNamed namedSlice
} }
var enc XYAML var enc X
if x.Slice != nil { if x.Slice != nil {
enc.Slice = make([]replacedInt, len(x.Slice)) enc.Slice = make([]replacedInt, len(x.Slice))
for k, v := range 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 { func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error {
type XYAML struct { type X struct {
Slice []replacedInt Slice []replacedInt
Named namedSlice2 Named namedSlice2
ByteString []byte ByteString []byte
NoConv []int NoConv []int
NoConvNamed namedSlice NoConvNamed namedSlice
} }
var dec XYAML var dec X
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }
@ -146,14 +144,14 @@ func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error {
} }
func (x X) MarshalTOML() (interface{}, error) { func (x X) MarshalTOML() (interface{}, error) {
type XTOML struct { type X struct {
Slice []replacedInt Slice []replacedInt
Named namedSlice2 Named namedSlice2
ByteString []byte ByteString []byte
NoConv []int NoConv []int
NoConvNamed namedSlice NoConvNamed namedSlice
} }
var enc XTOML var enc X
if x.Slice != nil { if x.Slice != nil {
enc.Slice = make([]replacedInt, len(x.Slice)) enc.Slice = make([]replacedInt, len(x.Slice))
for k, v := range 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 { func (x *X) UnmarshalTOML(unmarshal func(interface{}) error) error {
type XTOML struct { type X struct {
Slice []replacedInt Slice []replacedInt
Named namedSlice2 Named namedSlice2
ByteString []byte ByteString []byte
NoConv []int NoConv []int
NoConvNamed namedSlice NoConvNamed namedSlice
} }
var dec XTOML var dec X
if err := unmarshal(&dec); err != nil { if err := unmarshal(&dec); err != nil {
return err return err
} }

Loading…
Cancel
Save