forms/forms_test.go
2018-12-16 15:50:35 +01:00

53 lines
565 B
Go

package forms
import (
"fmt"
"testing"
)
type testStruct struct {
A string
B int
C float64
D nested
Anon
PA *string
PD *nested
}
type nested struct {
A string
B int
C float64
}
type Anon struct {
E string
}
func TestDecode(t *testing.T) {
data := &testStruct{}
Decode(Values{
`A`: {`test`},
`B`: {`10`},
`C`: {`1.25`},
`D.A`: {`test2`},
`D.B`: {`20`},
`D.C`: {`2.50`},
`E`: {`test3`},
`PA`: {`test4`},
`PD.A`: {`test5`},
`PD.B`: {`30`},
`PD.C`: {`3.75`},
}, data)
fmt.Println(`data:`, data, *data.PA, *data.PD)
}