onceguard_test.go 291 B

1234567891011121314151617
  1. package syncx
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestOnceGuard(t *testing.T) {
  7. var guard OnceGuard
  8. assert.False(t, guard.Taken())
  9. assert.True(t, guard.Take())
  10. assert.True(t, guard.Taken())
  11. assert.False(t, guard.Take())
  12. assert.True(t, guard.Taken())
  13. }