diff options
author | Anton Samokhvalov <pg83@yandex.ru> | 2022-02-10 16:45:15 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:15 +0300 |
commit | 72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch) | |
tree | da2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/system/guard_ut.cpp | |
parent | 778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff) | |
download | ydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz |
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/guard_ut.cpp')
-rw-r--r-- | util/system/guard_ut.cpp | 140 |
1 files changed, 70 insertions, 70 deletions
diff --git a/util/system/guard_ut.cpp b/util/system/guard_ut.cpp index 404ede99ab..d3501cba4e 100644 --- a/util/system/guard_ut.cpp +++ b/util/system/guard_ut.cpp @@ -1,17 +1,17 @@ -#include "guard.h" +#include "guard.h" #include "rwlock.h" - + #include <library/cpp/testing/unittest/registar.h> #include <util/thread/pool.h> -struct TTestGuard: public TTestBase { +struct TTestGuard: public TTestBase { UNIT_TEST_SUITE(TTestGuard); - UNIT_TEST(TestGuard) - UNIT_TEST(TestTryGuard) - UNIT_TEST(TestMove) - UNIT_TEST(TestSync) - UNIT_TEST(TestUnguard) + UNIT_TEST(TestGuard) + UNIT_TEST(TestTryGuard) + UNIT_TEST(TestMove) + UNIT_TEST(TestSync) + UNIT_TEST(TestUnguard) UNIT_TEST(TestTryReadGuard) UNIT_TEST(TestWithLock) UNIT_TEST(TestWithLockScope); @@ -41,66 +41,66 @@ struct TTestGuard: public TTestBase { bool guarded; }; - void TestUnguard() { - TGuardChecker m; - - { - auto guard = Guard(m); - - UNIT_ASSERT(m.guarded); - - { - auto unguard = Unguard(guard); - - UNIT_ASSERT(!m.guarded); - } - - UNIT_ASSERT(m.guarded); - } - - { - auto guard = Guard(m); - - UNIT_ASSERT(m.guarded); - - { - auto unguard = Unguard(m); - - UNIT_ASSERT(!m.guarded); - } - - UNIT_ASSERT(m.guarded); - } - } - - void TestMove() { - TGuardChecker m; - size_t n = 0; - - { - auto guard = Guard(m); - - UNIT_ASSERT(m.guarded); - ++n; - } - - UNIT_ASSERT(!m.guarded); - UNIT_ASSERT_VALUES_EQUAL(n, 1); - } - - void TestSync() { - TGuardChecker m; - size_t n = 0; - - with_lock (m) { - UNIT_ASSERT(m.guarded); - ++n; - } - - UNIT_ASSERT(!m.guarded); - UNIT_ASSERT_VALUES_EQUAL(n, 1); - } - + void TestUnguard() { + TGuardChecker m; + + { + auto guard = Guard(m); + + UNIT_ASSERT(m.guarded); + + { + auto unguard = Unguard(guard); + + UNIT_ASSERT(!m.guarded); + } + + UNIT_ASSERT(m.guarded); + } + + { + auto guard = Guard(m); + + UNIT_ASSERT(m.guarded); + + { + auto unguard = Unguard(m); + + UNIT_ASSERT(!m.guarded); + } + + UNIT_ASSERT(m.guarded); + } + } + + void TestMove() { + TGuardChecker m; + size_t n = 0; + + { + auto guard = Guard(m); + + UNIT_ASSERT(m.guarded); + ++n; + } + + UNIT_ASSERT(!m.guarded); + UNIT_ASSERT_VALUES_EQUAL(n, 1); + } + + void TestSync() { + TGuardChecker m; + size_t n = 0; + + with_lock (m) { + UNIT_ASSERT(m.guarded); + ++n; + } + + UNIT_ASSERT(!m.guarded); + UNIT_ASSERT_VALUES_EQUAL(n, 1); + } + void TestGuard() { TGuardChecker checker; @@ -154,7 +154,7 @@ struct TTestGuard: public TTestBase { } int WithLockIncrement(TGuardChecker& m, int n) { - with_lock (m) { + with_lock (m) { UNIT_ASSERT(m.guarded); return n + 1; } @@ -171,7 +171,7 @@ struct TTestGuard: public TTestBase { void TestWithLockScope() { auto Guard = [](auto) { UNIT_FAIL("Non global Guard used"); return 0; }; TGuardChecker m; - with_lock (m) { + with_lock (m) { Y_UNUSED(Guard); } } |