Skip to content

Commit

Permalink
reflect: add TestClearMap
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-krieger committed Oct 25, 2024
1 parent ba79b94 commit 8cf68aa
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/reflect/value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,32 @@ func TestClearSlice(t *testing.T) {
}
}

func TestClearMap(t *testing.T) {
for _, test := range []struct {
m any
expect any
}{
{
m: map[int]bool{1: true, 2: false, 3: true},
expect: map[int]bool{},
},
{
m: map[string][]byte{"hello": []byte("world")},
expect: map[string][]byte{},
},
} {
v := ValueOf(test.m)

v.Clear()
if len := v.Len(); len != 0 {
t.Errorf("Clear(map) should set len to 0, got %d", len)
}
if !DeepEqual(test.m, test.expect) {
t.Errorf("Clear(map) got %v, expected %v", test.m, test.expect)
}
}
}

func TestIssue4040(t *testing.T) {
var value interface{} = uint16(0)

Expand Down

0 comments on commit 8cf68aa

Please sign in to comment.