latch_ut.cpp 486 B

1234567891011121314151617181920
  1. #include <library/cpp/testing/unittest/registar.h>
  2. #include "latch.h"
  3. Y_UNIT_TEST_SUITE(TLatch) {
  4. Y_UNIT_TEST(Simple) {
  5. TLatch latch;
  6. UNIT_ASSERT(latch.TryWait());
  7. latch.Lock();
  8. UNIT_ASSERT(!latch.TryWait());
  9. latch.Lock();
  10. latch.Lock();
  11. UNIT_ASSERT(!latch.TryWait());
  12. latch.Unlock();
  13. UNIT_ASSERT(latch.TryWait());
  14. latch.Unlock();
  15. latch.Unlock();
  16. UNIT_ASSERT(latch.TryWait());
  17. }
  18. }