-
Notifications
You must be signed in to change notification settings - Fork 1
/
deepcopy_type_test.go
67 lines (60 loc) · 1.23 KB
/
deepcopy_type_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
package deepcopy
import (
"testing"
"github.com/stretchr/testify/assert"
)
// 测试所有类型(除了指针和inteface{})
func Test_TypeCase(t *testing.T) {
type allType struct {
Bool bool
Int8 int8
Int16 int16
Int32 int32
Int64 int64
Uint8 uint8
Uint16 uint16
Uint32 uint32
Uint64 uint64
Uintptr uintptr
Float32 float32
Float64 float64
Complex64 complex64
Complex128 complex128
ArrayInt [3]int
//TODO 展开所有类型array
SliceInt []int
C chan int
//CB func() error
S string
}
for _, tc := range []testCase{
func() testCase {
d := allType{}
src := allType{
Bool: true,
Int8: 1,
Int16: 2,
Int32: 3,
Int64: 4,
Uint8: 1,
Uint16: 2,
Uint32: 3,
Uint64: 4,
Uintptr: 0x123456,
Float32: 3.1,
Float64: 3.2,
Complex64: 1.1,
Complex128: 2.2,
ArrayInt: [3]int{1, 2, 3},
SliceInt: []int{4, 5, 6},
C: make(chan int),
//CB: func() error { return nil },
S: "test all",
}
Copy(&d, &src).Do()
return testCase{got: d, need: src}
}(),
} {
assert.Equal(t, tc.need, tc.got)
}
}