forked from github/multus-cni
26 lines
580 B
Go
26 lines
580 B
Go
package tests
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"context"
|
|
"github.com/modern-go/reflect2"
|
|
"github.com/modern-go/test"
|
|
"github.com/modern-go/test/must"
|
|
)
|
|
|
|
func Test_struct_ptr(t *testing.T) {
|
|
type TestObject struct {
|
|
Field1 *int
|
|
}
|
|
t.Run("PackEFace", test.Case(func(ctx context.Context) {
|
|
valType := reflect2.TypeOf(TestObject{})
|
|
ptr := valType.UnsafeNew()
|
|
must.Equal(&TestObject{}, valType.PackEFace(ptr))
|
|
}))
|
|
t.Run("Indirect", test.Case(func(ctx context.Context) {
|
|
valType := reflect2.TypeOf(TestObject{})
|
|
must.Equal(TestObject{}, valType.Indirect(&TestObject{}))
|
|
}))
|
|
}
|