src/reflect: add test for indirect array indexing

This commit is contained in:
Damian Gryski
2021-12-16 12:10:26 -08:00
committed by Ron Evans
parent 81edf577a3
commit c0ea21ece7
+15
View File
@@ -14,4 +14,19 @@ func TestIndirectPointers(t *testing.T) {
if ValueOf(a).Elem().Len() != 1 {
t.Errorf("bad map length via reflect")
}
var b struct {
Decoded *[3]byte
}
v1 := New(TypeOf(b.Decoded).Elem())
var bb [3]byte
bb[0] = 0xaa
v1.Elem().Set(ValueOf(bb))
if v1.Elem().Index(0).Uint() != 0xaa {
t.Errorf("bad indirect array index via reflect")
}
}