-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathptr_test.go
More file actions
254 lines (232 loc) · 4.8 KB
/
ptr_test.go
File metadata and controls
254 lines (232 loc) · 4.8 KB
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
package ptr
import (
"testing"
"time"
)
func TestUint8(t *testing.T) {
var x uint8
x = 9
p := Uint8(x)
if p == nil {
t.Fatalf("failed to get pointer of Uint8, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Uint8, got invalid value: %d", *p)
}
}
func TestUint16(t *testing.T) {
var x uint16
x = 9
p := Uint16(x)
if p == nil {
t.Fatalf("failed to get pointer of Uint16, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Uint16, got invalid value: %d", *p)
}
}
func TestUint32(t *testing.T) {
var x uint32
x = 9
p := Uint32(x)
if p == nil {
t.Fatalf("failed to get pointer of Uint32, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Uint32, got invalid value: %d", *p)
}
}
func TestUint64(t *testing.T) {
var x uint64
x = 9
p := Uint64(x)
if p == nil {
t.Fatalf("failed to get pointer of Uint64, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Uint64, got invalid value: %d", *p)
}
}
func TestInt8(t *testing.T) {
var x int8
x = 9
p := Int8(x)
if p == nil {
t.Fatalf("failed to get pointer of Int8, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Int8, got invalid value: %d", *p)
}
}
func TestInt16(t *testing.T) {
var x int16
x = 9
p := Int16(x)
if p == nil {
t.Fatalf("failed to get pointer of Int16, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Int16, got invalid value: %d", *p)
}
}
func TestInt32(t *testing.T) {
var x int32
x = 9
p := Int32(x)
if p == nil {
t.Fatalf("failed to get pointer of Int32, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Int32, got invalid value: %d", *p)
}
}
func TestInt64(t *testing.T) {
var x int64
x = 9
p := Int64(x)
if p == nil {
t.Fatalf("failed to get pointer of Int64, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Int64, got invalid value: %d", *p)
}
}
func TestFloat32(t *testing.T) {
var x float32
x = 9
p := Float32(x)
if p == nil {
t.Fatalf("failed to get pointer of Float32, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Float32, got invalid value: %f", *p)
}
}
func TestFloat64(t *testing.T) {
var x float64
x = 9
p := Float64(x)
if p == nil {
t.Fatalf("failed to get pointer of Float64, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Float64, got invalid value: %f", *p)
}
}
func TestComplex64(t *testing.T) {
var x complex64
x = 9
p := Complex64(x)
if p == nil {
t.Fatalf("failed to get pointer of Complex64, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Complex64, got invalid value: %v", *p)
}
}
func TestComplex128(t *testing.T) {
var x complex128
x = 9
p := Complex128(x)
if p == nil {
t.Fatalf("failed to get pointer of Complex128, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Complex128, got invalid value: %v", *p)
}
}
func TestByte(t *testing.T) {
var x byte
x = 9
p := Byte(x)
if p == nil {
t.Fatalf("failed to get pointer of Byte, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Byte, got invalid value: %d", *p)
}
}
func TestRune(t *testing.T) {
var x rune
x = 9
p := Rune(x)
if p == nil {
t.Fatalf("failed to get pointer of Rune, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Rune, got invalid value: %d", *p)
}
}
func TestUint(t *testing.T) {
var x uint
x = 9
p := Uint(x)
if p == nil {
t.Fatalf("failed to get pointer of Uint, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Uint, got invalid value: %d", *p)
}
}
func TestInt(t *testing.T) {
var x int
x = 9
p := Int(x)
if p == nil {
t.Fatalf("failed to get pointer of Int, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Int, got invalid value: %d", *p)
}
}
func TestString(t *testing.T) {
var x string
x = "test"
p := String(x)
if p == nil {
t.Fatalf("failed to get pointer of String, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of String, got invalid value: %s", *p)
}
}
func TestBool(t *testing.T) {
var x bool
x = true
p := Bool(x)
if p == nil {
t.Fatalf("failed to get pointer of Bool, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of Bool, got invalid value: %v", *p)
}
}
func TestTrue(t *testing.T) {
p := True()
if p == nil {
t.Fatalf("failed to get pointer of True, got nil")
}
if *p != true {
t.Fatalf("failed to get pointer of True, got invalid value: %v", *p)
}
}
func TestFalse(t *testing.T) {
p := False()
if p == nil {
t.Fatalf("failed to get pointer of False, got nil")
}
if *p != false {
t.Fatalf("failed to get pointer of False, got invalid value: %v", *p)
}
}
func TestTime(t *testing.T) {
var x time.Time
x = time.Now()
p := Time(x)
if p == nil {
t.Fatalf("failed to get pointer of time.Time, got nil")
}
if *p != x {
t.Fatalf("failed to get pointer of time.Time, got invalid value: %v", *p)
}
}