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.
18 lines
291 B
Go
18 lines
291 B
Go
4 years ago
|
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())
|
||
|
}
|