@@ -447,6 +447,18 @@ func TestDefaultBinder_bindDataToMap(t *testing.T) {
447447 )
448448 })
449449
450+ t .Run ("ok, bind to map[string]string with nil map" , func (t * testing.T ) {
451+ var dest map [string ]string
452+ assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
453+ assert .Equal (t ,
454+ map [string ]string {
455+ "multiple" : "1" ,
456+ "single" : "3" ,
457+ },
458+ dest ,
459+ )
460+ })
461+
450462 t .Run ("ok, bind to map[string][]string" , func (t * testing.T ) {
451463 dest := map [string ][]string {}
452464 assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
@@ -459,6 +471,18 @@ func TestDefaultBinder_bindDataToMap(t *testing.T) {
459471 )
460472 })
461473
474+ t .Run ("ok, bind to map[string][]string with nil map" , func (t * testing.T ) {
475+ var dest map [string ][]string
476+ assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
477+ assert .Equal (t ,
478+ map [string ][]string {
479+ "multiple" : {"1" , "2" },
480+ "single" : {"3" },
481+ },
482+ dest ,
483+ )
484+ })
485+
462486 t .Run ("ok, bind to map[string]interface" , func (t * testing.T ) {
463487 dest := map [string ]interface {}{}
464488 assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
@@ -471,18 +495,41 @@ func TestDefaultBinder_bindDataToMap(t *testing.T) {
471495 )
472496 })
473497
498+ t .Run ("ok, bind to map[string]interface with nil map" , func (t * testing.T ) {
499+ var dest map [string ]interface {}
500+ assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
501+ assert .Equal (t ,
502+ map [string ]interface {}{
503+ "multiple" : []string {"1" , "2" },
504+ "single" : []string {"3" },
505+ },
506+ dest ,
507+ )
508+ })
509+
474510 t .Run ("ok, bind to map[string]int skips" , func (t * testing.T ) {
475511 dest := map [string ]int {}
476512 assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
477513 assert .Equal (t , map [string ]int {}, dest )
478514 })
479515
516+ t .Run ("ok, bind to map[string]int skips with nil map" , func (t * testing.T ) {
517+ var dest map [string ]int
518+ assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
519+ assert .Equal (t , map [string ]int (nil ), dest )
520+ })
521+
480522 t .Run ("ok, bind to map[string][]int skips" , func (t * testing.T ) {
481523 dest := map [string ][]int {}
482524 assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
483525 assert .Equal (t , map [string ][]int {}, dest )
484526 })
485527
528+ t .Run ("ok, bind to map[string][]int skips with nil map" , func (t * testing.T ) {
529+ var dest map [string ][]int
530+ assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
531+ assert .Equal (t , map [string ][]int (nil ), dest )
532+ })
486533}
487534
488535func TestBindbindData (t * testing.T ) {
0 commit comments