reflect: add support for remaining map types

This commit is contained in:
Damian Gryski
2023-03-03 22:19:49 -08:00
committed by Damian Gryski
parent a6084767b3
commit 69e5c5088d
3 changed files with 56 additions and 5 deletions
+17
View File
@@ -115,6 +115,23 @@ func TestMap(t *testing.T) {
if m2["foo"] != 2 {
t.Errorf("MakeMap failed to create map")
}
type stringint struct {
s string
i int
}
simap := make(map[stringint]int)
refsimap := MakeMap(TypeOf(simap))
refsimap.SetMapIndex(ValueOf(stringint{"hello", 4}), ValueOf(6))
six := refsimap.MapIndex(ValueOf(stringint{"hello", 4}))
if six.Interface().(int) != 6 {
t.Errorf("m[hello, 4]=%v, want 6", six)
}
}
func TestSlice(t *testing.T) {