initial import
This commit is contained in:
33
core/syncx/donechan_test.go
Normal file
33
core/syncx/donechan_test.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package syncx
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDoneChanClose(t *testing.T) {
|
||||
doneChan := NewDoneChan()
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
doneChan.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func TestDoneChanDone(t *testing.T) {
|
||||
var waitGroup sync.WaitGroup
|
||||
doneChan := NewDoneChan()
|
||||
|
||||
waitGroup.Add(1)
|
||||
go func() {
|
||||
select {
|
||||
case <-doneChan.Done():
|
||||
waitGroup.Done()
|
||||
}
|
||||
}()
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
doneChan.Close()
|
||||
}
|
||||
|
||||
waitGroup.Wait()
|
||||
}
|
||||
Reference in New Issue
Block a user