mirror of
https://github.com/nxshock/gwp.git
synced 2025-07-01 00:13:39 +05:00
Add basic test
This commit is contained in:
parent
4c690762bd
commit
ed1db97396
1 changed files with 27 additions and 0 deletions
27
gwp_test.go
Normal file
27
gwp_test.go
Normal file
|
@ -0,0 +1,27 @@
|
|||
package gwp
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestBasic(t *testing.T) {
|
||||
for i := 0; i < 10; i++ {
|
||||
wp := New(i)
|
||||
|
||||
count := new(int64)
|
||||
|
||||
for j := 0; j < 100; j++ {
|
||||
wp.Add(func() error {
|
||||
atomic.AddInt64(count, 1)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
wp.CloseAndWait()
|
||||
|
||||
assert.EqualValues(t, 100, *count)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue