initial import
This commit is contained in:
31
core/syncx/barrier_test.go
Normal file
31
core/syncx/barrier_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package syncx
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestBarrier_Guard(t *testing.T) {
|
||||
const total = 10000
|
||||
var barrier Barrier
|
||||
var count int
|
||||
for i := 0; i < total; i++ {
|
||||
barrier.Guard(func() {
|
||||
count++
|
||||
})
|
||||
}
|
||||
assert.Equal(t, total, count)
|
||||
}
|
||||
|
||||
func TestBarrierPtr_Guard(t *testing.T) {
|
||||
const total = 10000
|
||||
barrier := new(Barrier)
|
||||
var count int
|
||||
for i := 0; i < total; i++ {
|
||||
barrier.Guard(func() {
|
||||
count++
|
||||
})
|
||||
}
|
||||
assert.Equal(t, total, count)
|
||||
}
|
||||
Reference in New Issue
Block a user