github.com/jxskiss/gopkg@v0.17.3/ptr/copy_test.go (about) 1 package ptr 2 3 import ( 4 "github.com/stretchr/testify/assert" 5 "testing" 6 ) 7 8 func TestCopyAny(t *testing.T) { 9 x1 := int64(1) 10 11 got1, ok := CopyAny(x1).(*int64) 12 assert.True(t, ok) 13 assert.Equal(t, x1, *got1) 14 15 got2, ok := CopyAny(&x1).(*int64) 16 assert.True(t, ok) 17 assert.Equal(t, x1, *got2) 18 19 got3, ok := CopyAny((*int64)(nil)).(*int64) 20 assert.True(t, ok) 21 assert.Nil(t, got3) 22 }