github.com/gogf/gf/v2@v2.7.4/util/gconv/gconv_z_unit_ptr_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package gconv_test 8 9 import ( 10 "testing" 11 12 "github.com/gogf/gf/v2/test/gtest" 13 "github.com/gogf/gf/v2/util/gconv" 14 ) 15 16 func TestPtrAny(t *testing.T) { 17 gtest.C(t, func(t *gtest.T) { 18 var v interface{} = 1 19 t.AssertEQ(gconv.PtrAny(v), &v) 20 }) 21 } 22 23 func TestPtrString(t *testing.T) { 24 gtest.C(t, func(t *gtest.T) { 25 var v string = "Pluto" 26 t.AssertEQ(gconv.PtrString(v), &v) 27 }) 28 } 29 30 func TestPtrBool(t *testing.T) { 31 gtest.C(t, func(t *gtest.T) { 32 var v bool = true 33 t.AssertEQ(gconv.PtrBool(v), &v) 34 }) 35 } 36 37 func TestPtrInt(t *testing.T) { 38 gtest.C(t, func(t *gtest.T) { 39 var v int = 123 40 t.AssertEQ(gconv.PtrInt(v), &v) 41 }) 42 } 43 44 func TestPtrInt8(t *testing.T) { 45 gtest.C(t, func(t *gtest.T) { 46 var v int8 = 123 47 t.AssertEQ(gconv.PtrInt8(v), &v) 48 }) 49 } 50 51 func TestPtrInt16(t *testing.T) { 52 gtest.C(t, func(t *gtest.T) { 53 var v int16 = 123 54 t.AssertEQ(gconv.PtrInt16(v), &v) 55 }) 56 } 57 58 func TestPtrInt32(t *testing.T) { 59 gtest.C(t, func(t *gtest.T) { 60 var v int32 = 123 61 t.AssertEQ(gconv.PtrInt32(v), &v) 62 }) 63 } 64 65 func TestPtrInt64(t *testing.T) { 66 gtest.C(t, func(t *gtest.T) { 67 var v int64 = 123 68 t.AssertEQ(gconv.PtrInt64(v), &v) 69 }) 70 } 71 72 func TestPtrUint(t *testing.T) { 73 gtest.C(t, func(t *gtest.T) { 74 var v uint = 123 75 t.AssertEQ(gconv.PtrUint(v), &v) 76 }) 77 } 78 79 func TestPtrUint8(t *testing.T) { 80 gtest.C(t, func(t *gtest.T) { 81 var v uint8 = 123 82 t.AssertEQ(gconv.PtrUint8(v), &v) 83 }) 84 } 85 86 func TestPtrUint16(t *testing.T) { 87 gtest.C(t, func(t *gtest.T) { 88 var v uint16 = 123 89 t.AssertEQ(gconv.PtrUint16(v), &v) 90 }) 91 } 92 93 func TestPtrUint32(t *testing.T) { 94 gtest.C(t, func(t *gtest.T) { 95 var v uint32 = 123 96 t.AssertEQ(gconv.PtrUint32(v), &v) 97 }) 98 } 99 100 func TestPtrUint64(t *testing.T) { 101 gtest.C(t, func(t *gtest.T) { 102 var v uint64 = 123 103 t.AssertEQ(gconv.PtrUint64(v), &v) 104 }) 105 } 106 107 func TestPtrFloat32(t *testing.T) { 108 gtest.C(t, func(t *gtest.T) { 109 var v float32 = 123.456 110 t.AssertEQ(gconv.PtrFloat32(v), &v) 111 }) 112 } 113 114 func TestPtrFloat64(t *testing.T) { 115 gtest.C(t, func(t *gtest.T) { 116 var v float64 = 123.456 117 t.AssertEQ(gconv.PtrFloat64(v), &v) 118 }) 119 }