Add a test case for issue #27

This commit is contained in:
hjusforgues
2016-07-01 18:41:08 +07:00
parent 69e532648c
commit 9c32e038e7
2 changed files with 31 additions and 0 deletions
+1
View File
@@ -31,6 +31,7 @@ var testCases = []struct {
{&unexportedStructValue, unexportedStructString},
{&excludedFieldValue, excludedFieldString},
{&mapsValue, mapsString},
{&deepNestValue, deepNestString},
}
func TestMarshal(t *testing.T) {
+30
View File
@@ -436,6 +436,36 @@ var mapsString = `{` +
`"CustomMap":{"c":"d"}` +
`}`
type DeepNest struct {
SliceMap map[Str][]Str
MapSlice []map[Str]Str
}
var deepNestValue = DeepNest{
SliceMap: map[Str][]Str{
"testSliceMap1": []Str{
"0",
"1",
},
"testSliceMap2": nil,
},
MapSlice: []map[Str]Str{
map[Str]Str{
"testMapSlice1": "someValue",
},
},
}
var deepNestString = `{` +
`"SliceMap":{` +
`"testSliceMap1":["0","1"],` +
`"testSliceMap2":[]` +
`},` +
`"MapSlice":[` +
`{"testMapSlice1":"someValue"}` +
`]` +
`}`
type RequiredOptionalStruct struct {
FirstName string `json:"first_name,required"`
Lastname string `json:"last_name"`