-
Notifications
You must be signed in to change notification settings - Fork 12
/
pcopy_bug_test.go
80 lines (66 loc) · 1.34 KB
/
pcopy_bug_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
package pcopy
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
type LetterInbox struct {
ID int32
FromRid int64
ToRid int64
Msg string
}
var resp = []LetterInbox{
{
ID: 1,
FromRid: 3,
ToRid: 4,
Msg: "ww,",
},
}
type ReadLetterResponseItem struct {
Msg string
}
type ReadLetterResponse struct {
List []*ReadLetterResponseItem `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"`
}
func Test_ReadLetter(t *testing.T) {
var rv ReadLetterResponse
err := Preheat(&rv.List, &resp)
assert.NoError(t, err)
err = Copy(&rv.List, &resp, WithUsePreheat())
assert.NoError(t, err)
fmt.Printf("%#v\n", rv.List)
fmt.Printf("%#v\n", rv.List[0])
// fmt.Printf("%#v\n", rv.List[1])
}
func Test_ReadLetter2(t *testing.T) {
var rv ReadLetterResponse
err := Preheat(&rv.List, &LetterInbox{})
assert.NoError(t, err)
resp2 := []LetterInbox{
{
ID: 1,
FromRid: 3,
ToRid: 4,
Msg: "hello",
},
}
err = Copy(&rv.List, &resp2, WithUsePreheat())
assert.NoError(t, err)
assert.Equal(t, rv.List[0].Msg, "hello")
}
func Test_ReadLetter3(t *testing.T) {
var rv ReadLetterResponse
resp2 := []LetterInbox{
{
ID: 1,
FromRid: 3,
ToRid: 4,
Msg: "hello",
},
}
err := Copy(&rv.List, &resp2)
assert.NoError(t, err)
assert.Equal(t, rv.List[0].Msg, "hello")
}