-
Notifications
You must be signed in to change notification settings - Fork 12
/
pcopy_time_Time_test.go
61 lines (49 loc) · 1.18 KB
/
pcopy_time_Time_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
// Copyright [2020-2023] [guonaihong]
package pcopy
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func Test_timeTime_BaseType(t *testing.T) {
err := Preheat(&time.Time{}, &time.Time{})
assert.NoError(t, err)
src := time.Now()
var dst time.Time
err = Copy(&dst, &src, WithUsePreheat())
assert.NoError(t, err)
assert.Equal(t, src, dst)
}
func Test_timeTime_Slice(t *testing.T) {
err := Preheat(&[]time.Time{}, &[]time.Time{})
assert.NoError(t, err)
src := []time.Time{time.Now(), time.Now(), time.Now()}
var dst []time.Time
err = Copy(&dst, &src, WithUsePreheat())
assert.NoError(t, err)
assert.Equal(t, src, dst)
}
type testCaseWithTime1 struct {
T1 time.Time
I int
}
type testCaseWithTime2 struct {
T1 time.Time
I int
}
func Test_Time(t *testing.T) {
var t1 testCaseWithTime1
t2 := testCaseWithTime2{T1: time.Now(), I: 3}
err := Copy(&t1, &t2)
assert.NoError(t, err)
assert.Equal(t, t1.T1, t2.T1)
assert.Equal(t, t1.I, t2.I)
}
func Test_TimeCopyEx(t *testing.T) {
var t1 testCaseWithTime1
t2 := testCaseWithTime2{T1: time.Now(), I: 3}
err := Copy(&t1, &t2)
assert.NoError(t, err)
assert.Equal(t, t1.T1, t2.T1)
assert.Equal(t, t1.I, t2.I)
}