-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpool_test.go
79 lines (65 loc) · 1.05 KB
/
pool_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
package funny
import (
"fmt"
"testing"
"time"
)
type page struct {
Name string
}
func(p *page)newObject()(o Object){
return &page{Name: "dsdsds"}
}
func TestTimeout(t *testing.T) {
pp:=&page{}
np:=NewPool(10,pp)
for i:=0;i<12;i++{
go func() {
o,err:=np.Get(time.Second)
if err!=nil{
t.Error("get error")
}
if pag,ok:=o.(*page);ok{
t.Log(pag.Name)
time.Sleep(time.Millisecond)
np.Close(pag)
}
}()
}
time.Sleep(time.Second*10)
}
func TestNoSource(t *testing.T) {
pp:=&page{}
np:=NewPool(10,pp)
for i:=0;i<12;i++{
o,err:=np.Get(time.Millisecond)
if err!=nil{
t.Error("get error")
}
if pag,ok:=o.(*page);ok{
t.Log(pag.Name)
}
}
}
type ssss struct {
Fg string
}
func TestNoSource2(t *testing.T) {
s:=fg()
fmt.Printf("%p\n%p\n",&s,&s)
}
func fg()chan ssss {
var ty chan ssss
ty = make(chan ssss)
go func() {
close(ty)
close(ty)
fmt.Printf("sdsdsdsdddsdd")
}()
time.Sleep(time.Second)
gh := make(chan ssss,1)
hj := gh
hj2 := gh
fmt.Printf("%p\n%p\n%p\n%p\n",&gh,&hj,&ty,&hj2)
return gh
}