mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
18 lines
291 B
Go
18 lines
291 B
Go
package syncx
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestOnceGuard(t *testing.T) {
|
|
var guard OnceGuard
|
|
|
|
assert.False(t, guard.Taken())
|
|
assert.True(t, guard.Take())
|
|
assert.True(t, guard.Taken())
|
|
assert.False(t, guard.Take())
|
|
assert.True(t, guard.Taken())
|
|
}
|