- name: Test
run: |
- go test -v .
- go test -v -race github.com/qydysky/part/signal
- go test -v -race github.com/qydysky/part/reqf
- go test -v -race github.com/qydysky/part/limit
- go test -v -race github.com/qydysky/part/file
- go test -v -race github.com/qydysky/part/pool
- go test -v -race github.com/qydysky/part/funcCtrl
- go test -v -race github.com/qydysky/part/msgq
+ go test -count 1 -timeout 30s -v .
+ go test -count 1 -timeout 5s -v -race github.com/qydysky/part/signal
+ go test -count 1 -timeout 15s -v -race github.com/qydysky/part/reqf
+ go test -count 1 -timeout 15s -v -race github.com/qydysky/part/limit
+ go test -count 1 -timeout 20s -v -race github.com/qydysky/part/file
+ go test -count 1 -timeout 5s -v -race github.com/qydysky/part/pool
+ go test -count 1 -timeout 10s -v -race github.com/qydysky/part/funcCtrl
+ go test -count 1 -timeout 30s -v -race github.com/qydysky/part/msgq
}
mq.Push_tag(`A3`, i)
}
- t.Log(`fin`)
}
func Test_msgq3(t *testing.T) {
},
})
- var fin_turn = 0
- t.Log(`start`)
time.Sleep(time.Second)
- for fin_turn < 1000000 {
+ for fin_turn := 0; fin_turn < 1000000; fin_turn += 1 {
mq.Push_tag(`A1`, fin_turn)
if fin_turn != <-mun_c {
- t.Error(fin_turn)
+ t.Fatal(fin_turn)
}
- fin_turn += 1
- fmt.Print("\r", fin_turn)
}
- t.Log(`fin`)
}
func Test_msgq4(t *testing.T) {
})
var fin_turn = 0
- t.Log(`start`)
time.Sleep(time.Second)
for fin_turn < 5 {
go mq.Push_tag(`A1`, `a11`)
<-mun_c1
// <-mun_c3
fin_turn += 1
- fmt.Print("\r", fin_turn)
}
- t.Log(`fin`)
}
func Test_msgq5(t *testing.T) {
})
var fin_turn = 0
- t.Log(`start`)
time.Sleep(time.Second)
for fin_turn < 10 {
mq.Push_tag(`A1`, `a11`)
<-mun_c1
<-mun_c2
fin_turn += 1
- fmt.Print("\r", fin_turn)
}
- t.Log(`fin`)
}
func Test_msgq6(t *testing.T) {
if b != 0 {
t.Fatal()
}
- t.Log(b)
return false
},
})
}
func Test_msgq7(t *testing.T) {
+ var c = make(chan string, 100)
msg := NewType[int]()
msg.Pull_tag_async_only(`1`, func(i int) (disable bool) {
time.Sleep(time.Second)
- t.Log(`async1`)
+ c <- "1"
return i > 10
})
msg.Pull_tag_async_only(`1`, func(i int) (disable bool) {
time.Sleep(time.Second * 2)
- t.Log(`async2`)
+ c <- "2"
return i > 10
})
msg.Pull_tag_only(`1`, func(i int) (disable bool) {
time.Sleep(time.Second * 2)
- t.Log(`sync1`)
+ c <- "3"
return i > 10
})
msg.Pull_tag_only(`1`, func(i int) (disable bool) {
time.Sleep(time.Second * 2)
- t.Log(`sync2`)
+ c <- "4"
return i > 10
})
msg.Push_tag(`1`, 0)
- time.Sleep(time.Second * 10)
+ if <-c != "1" {
+ t.Fatal()
+ }
+ if <-c != "2" {
+ t.Fatal()
+ }
+ if <-c != "3" {
+ t.Fatal()
+ }
+ if <-c != "4" {
+ t.Fatal()
+ }
}
func Test_msgq8(t *testing.T) {
+ var c = make(chan string, 100)
+ var cc string
msg := NewType[int]()
msg.Pull_tag_async_only(`1`, func(i int) (disable bool) {
time.Sleep(time.Second)
- t.Logf("async %d", i)
+ c <- fmt.Sprintf("a%d", i)
return i > 3
})
msg.Pull_tag_only(`1`, func(i int) (disable bool) {
time.Sleep(time.Second)
- t.Logf("sync %d", i)
+ c <- fmt.Sprintf("s%d", i)
return i > 5
})
for i := 0; i < 20; i++ {
msg.Push_tag(`1`, i)
}
- time.Sleep(time.Second * 10)
+ time.Sleep(time.Second)
+ for len(c) != 0 {
+ cc += <-c
+ }
+ if cc != "a0s0a1s1a2s2a3s3a4s4s5s6" {
+ t.Fatal()
+ }
}
// func Test_msgq6(t *testing.T) {