You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
427 B
Go
34 lines
427 B
Go
4 years ago
|
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()
|
||
|
}
|