-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathis_base_type_test.go
74 lines (67 loc) · 1.16 KB
/
is_base_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
68
69
70
71
72
73
74
package pcopy
import (
"reflect"
"testing"
"unsafe"
)
func Test_IsInt64(t *testing.T) {
if !isInt64(reflect.Int64) {
t.Fatalf("reflect.Int64 is int64")
i := int64(0)
if unsafe.Sizeof(i) != 8 {
t.Fatalf("int64 size is not 8")
}
}
if !isInt64(reflect.Uint64) {
t.Fatalf("reflect.Uint64 is int64")
i := uint64(0)
if unsafe.Sizeof(i) != 8 {
t.Fatalf("uint64 size is not 8")
}
}
if !isInt64(reflect.Int) {
t.Fatalf("reflect.Int is int64")
i := int(0)
if unsafe.Sizeof(i) != 8 {
t.Fatalf("int size is not 8")
}
}
}
type TestBaseTypeExDst struct {
N64 uint64
N32 uint32
N16 uint16
N8 uint8
}
type TestBaseTypeExSrc struct {
N64 int64
N32 int32
N16 int16
N8 int8
}
func Test_Base_Type_Ex(t *testing.T) {
err := Preheat(&TestBaseTypeExDst{}, &TestBaseTypeExSrc{})
if err != nil {
t.Fatalf("preheat error: %v", err)
}
d := TestBaseTypeExDst{}
s := TestBaseTypeExSrc{
N64: 1,
N32: 2,
N16: 3,
N8: 4,
}
need := TestBaseTypeExDst{
N64: 1,
N32: 2,
N16: 3,
N8: 4,
}
err = Copy(&d, &s, WithUsePreheat())
if err != nil {
t.Fatalf("copy error rv: %v", err)
}
if d != need {
t.Fatalf("copy error: %v", d)
}
}