-
Notifications
You must be signed in to change notification settings - Fork 1
/
ptrto_test.go
175 lines (136 loc) · 3.43 KB
/
ptrto_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package ptrto
import (
"reflect"
"testing"
)
const (
testBool bool = true
testByte byte = 0x01
testFloat32 float32 = 1.23
testFloat64 float64 = 1.23
testInt int = 1
testInt8 int8 = 2
testInt16 int16 = 3
testInt32 int32 = 4
testInt64 int64 = 5
testString string = "this is a test"
testUint uint = 1
testUint8 uint8 = 2
testUint16 uint16 = 3
testUint32 uint32 = 4
testUint64 uint64 = 5
testUintptr uintptr = 1
)
// Some types cannot be `const`
var (
testInterface interface{}
testStruct struct{}
)
func TestBool(t *testing.T) {
ptr := Bool(testBool)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to bool type")
}
}
func TestByte(t *testing.T) {
ptr := Byte(testByte)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to byte type")
}
}
func TestFloat32(t *testing.T) {
ptr := Float32(testFloat32)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to float32 type")
}
}
func TestFloat64(t *testing.T) {
ptr := Float64(testFloat64)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to float64 type")
}
}
func TestInt(t *testing.T) {
ptr := Int(testInt)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to int type")
}
}
func TestInt8(t *testing.T) {
ptr := Int8(testInt8)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to int8 type")
}
}
func TestInt16(t *testing.T) {
ptr := Int16(testInt16)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to int16 type")
}
}
func TestInt32(t *testing.T) {
ptr := Int32(testInt32)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to int32 type")
}
}
func TestInt64(t *testing.T) {
ptr := Int64(testInt64)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to int64 type")
}
}
func TestInterface(t *testing.T) {
ptr := Interface(testInterface)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to interface type")
}
}
func TestString(t *testing.T) {
ptr := String(testString)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to string type")
}
}
func TestStruct(t *testing.T) {
ptr := Struct(testStruct)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to struct type")
}
}
func TestUint(t *testing.T) {
ptr := Uint(testUint)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to uint type")
}
}
func TestUint8(t *testing.T) {
ptr := Uint8(testUint8)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to uint8 type")
}
}
func TestUint16(t *testing.T) {
ptr := Uint16(testUint16)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to uint16 type")
}
}
func TestUint32(t *testing.T) {
ptr := Uint32(testUint32)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to uint32 type")
}
}
func TestUint64(t *testing.T) {
ptr := Uint64(testUint64)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to uint64 type")
}
}
func TestUintptr(t *testing.T) {
ptr := Uintptr(testUintptr)
if reflect.Ptr != reflect.TypeOf(ptr).Kind() {
t.Errorf("Cannot return pointer to uintptr type")
}
}