@@ -447,6 +447,18 @@ func TestDefaultBinder_bindDataToMap(t *testing.T) {
447
447
)
448
448
})
449
449
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
+
450
462
t .Run ("ok, bind to map[string][]string" , func (t * testing.T ) {
451
463
dest := map [string ][]string {}
452
464
assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
@@ -459,6 +471,18 @@ func TestDefaultBinder_bindDataToMap(t *testing.T) {
459
471
)
460
472
})
461
473
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
+
462
486
t .Run ("ok, bind to map[string]interface" , func (t * testing.T ) {
463
487
dest := map [string ]interface {}{}
464
488
assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
@@ -471,18 +495,42 @@ func TestDefaultBinder_bindDataToMap(t *testing.T) {
471
495
)
472
496
})
473
497
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
+
474
510
t .Run ("ok, bind to map[string]int skips" , func (t * testing.T ) {
475
511
dest := map [string ]int {}
476
512
assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
477
513
assert .Equal (t , map [string ]int {}, dest )
478
514
})
479
515
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 {}, dest )
520
+ })
521
+
480
522
t .Run ("ok, bind to map[string][]int skips" , func (t * testing.T ) {
481
523
dest := map [string ][]int {}
482
524
assert .NoError (t , new (DefaultBinder ).bindData (& dest , exampleData , "param" ))
483
525
assert .Equal (t , map [string ][]int {}, dest )
484
526
})
485
527
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 {}, dest )
532
+ })
533
+
486
534
}
487
535
488
536
func TestBindbindData (t * testing.T ) {
0 commit comments