-
Notifications
You must be signed in to change notification settings - Fork 3
/
ptr_test.go
97 lines (74 loc) · 1.84 KB
/
ptr_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
package ptr
import (
"reflect"
"testing"
"time"
)
func equal(t *testing.T, expected, actual interface{}) {
if !reflect.DeepEqual(expected, actual) {
t.Errorf("Expected %#v, actual %#v", expected, actual)
}
}
func TestOf(t *testing.T) {
equal(t, int(10), *Of(10))
}
func TestInt(t *testing.T) {
equal(t, int(10), *Int(10))
}
func TestInt8(t *testing.T) {
equal(t, int8(10), *Int8(10))
}
func TestInt16(t *testing.T) {
equal(t, int16(10), *Int16(10))
}
func TestInt32(t *testing.T) {
equal(t, int32(10), *Int32(10))
}
func TestInt64(t *testing.T) {
equal(t, int64(10), *Int64(10))
}
func TestUInt(t *testing.T) {
equal(t, uint(10), *UInt(10))
}
func TestUInt8(t *testing.T) {
equal(t, uint8(10), *UInt8(10))
}
func TestUInt16(t *testing.T) {
equal(t, uint16(10), *UInt16(10))
}
func TestUInt32(t *testing.T) {
equal(t, uint32(10), *UInt32(10))
}
func TestUInt64(t *testing.T) {
equal(t, uint64(10), *UInt64(10))
}
func TestByte(t *testing.T) {
equal(t, byte(10), *Byte(10))
}
func TestRune(t *testing.T) {
equal(t, rune('🤔'), *Rune('🤔'))
}
func TestBool(t *testing.T) {
equal(t, bool(true), *Bool(true))
}
func TestString(t *testing.T) {
equal(t, string("10"), *String("10"))
}
func TestFloat32(t *testing.T) {
equal(t, float32(10.1), *Float32(10.1))
}
func TestFloat64(t *testing.T) {
equal(t, float64(10.1), *Float64(10.1))
}
func TestComplex64(t *testing.T) {
equal(t, complex(float32(10.0), float32(100.0)), *Complex64(complex(float32(10.0), float32(100.0))))
}
func TestComplex128(t *testing.T) {
equal(t, complex(float64(10.0), float64(100.0)), *Complex128(complex(float64(10.0), float64(100.0))))
}
func TestDuration(t *testing.T) {
equal(t, time.Second, *Duration(time.Second))
}
func TestTime(t *testing.T) {
equal(t, time.Date(2001, 2, 3, 4, 5, 6, 7, time.UTC), *Time(time.Date(2001, 2, 3, 4, 5, 6, 7, time.UTC)))
}