File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -765,6 +765,32 @@ func TestClearSlice(t *testing.T) {
765765 }
766766}
767767
768+ func TestClearMap (t * testing.T ) {
769+ for _ , test := range []struct {
770+ m any
771+ expect any
772+ }{
773+ {
774+ m : map [int ]bool {1 : true , 2 : false , 3 : true },
775+ expect : map [int ]bool {},
776+ },
777+ {
778+ m : map [string ][]byte {"hello" : []byte ("world" )},
779+ expect : map [string ][]byte {},
780+ },
781+ } {
782+ v := ValueOf (test .m )
783+
784+ v .Clear ()
785+ if len := v .Len (); len != 0 {
786+ t .Errorf ("Clear(map) should set len to 0, got %d" , len )
787+ }
788+ if ! DeepEqual (test .m , test .expect ) {
789+ t .Errorf ("Clear(map) got %v, expected %v" , test .m , test .expect )
790+ }
791+ }
792+ }
793+
768794func TestIssue4040 (t * testing.T ) {
769795 var value interface {} = uint16 (0 )
770796
You can’t perform that action at this time.
0 commit comments