Debian Codegraph @

internal/unsafe2/unsafe_test.go

raw symbols SCIP
1 package unsafe2_test
2
3 import (
4 "reflect"
5 "testing"
6
7 "github.com/traefik/yaegi/internal/unsafe2"
8 )
9
10 func TestSwapFieldType(t *testing.T) {
11 f := []reflect.StructField{
12 {
13 Name: "A",
14 Type: reflect.TypeOf(int(0)),
15 },
16 {
17 Name: "B",
18 Type: reflect.PtrTo(unsafe2.DummyType),
19 },
20 {
21 Name: "C",
22 Type: reflect.TypeOf(int64(0)),
23 },
24 }
25 typ := reflect.StructOf(f)
26 ntyp := reflect.PtrTo(typ)
27
28 unsafe2.SetFieldType(typ, 1, ntyp)
29
30 if typ.Field(1).Type != ntyp {
31 t.Fatalf("unexpected field type: want %s; got %s", ntyp, typ.Field(1).Type)
32 }
33 }