-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcache_test.go
80 lines (72 loc) · 1.66 KB
/
cache_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 spdag
import (
"testing"
"time"
)
func TestNewCache(t *testing.T) {
t.Run("缓存库初始化。", func(t *testing.T) {
//jtime1 := "2015-03-20 08:50:29"
//time2 := "2015-03-21 09:04:25"
time3 := "2015-03-30 09:04:25"
//time4 := "2015-05-01 09:04:25"
//t1, _ := time.Parse("2006-01-02 15:04:05", time1)
//t2, _ := time.Parse("2006-01-02 15:04:05", time2)
t3, _ := time.Parse("2006-01-02 15:04:05", time3)
//t4, _ := time.Parse("2006-01-02 15:04:05", time4)
c := NewCache()
v1 := &SubbranchPlan{
SubbranchPlanId: 1,
SubbranchPlanName: "123",
SubSeq: []int{2, 3},
}
v2 := &SubbranchPlan{
SubbranchPlanId: 2,
SubbranchPlanName: "789",
PreSeq: []int{1},
SubSeq: []int{3},
}
v3 := &SubbranchPlan{
SubbranchPlanId: 3,
SubbranchPlanName: "111",
PlanStartDate: t3,
PreSeq: []int{1, 2},
}
c.Init(111, v1)
c.Init(111, v3)
c.Init(111, v2)
c.Build()
dag := c.Get(111)
v4 := &SubbranchPlan{
SubbranchPlanId: 3,
SubbranchPlanName: "111",
PlanStartDate: t3,
PreSeq: []int{1},
}
aa := dag.Get(3)
dag.Update(v4, aa)
//c.Add(111, v)
//c.Add(111, v3)
//c.Add(111, v7)
//c.Add(111, v5)
//c.Add(111, v6)
//d := c.Add(111, v10)
//t.Logf("结果:%+v\n\n", d.vertexsMap[123])
//d.Update(v3, aa)
for _, v := range c.SpdagList() {
for _, p := range v.vertexsMap {
t.Logf("结果:%+v\n\n", p)
}
}
})
}
func Test_cache_Get(t *testing.T) {
//t.Run("cache.Get", func(t *testing.T) {
// c := NewCache()
// vertex := &SubbranchPlan{
// ID: 123,
// }
// c.Add(1, vertex)
// d := c.Get(1)
// t.Log(d)
//})
}