From c2a1af049e9deca890e9923abe64fe6c59060348 Mon Sep 17 00:00:00 2001 From: nga <nga@yandex-team.ru> Date: Thu, 10 Feb 2022 16:48:09 +0300 Subject: Restoring authorship annotation for <nga@yandex-team.ru>. Commit 2 of 2. --- library/cpp/messagebus/misc/weak_ptr_ut.cpp | 72 ++++++++++++++--------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'library/cpp/messagebus/misc/weak_ptr_ut.cpp') diff --git a/library/cpp/messagebus/misc/weak_ptr_ut.cpp b/library/cpp/messagebus/misc/weak_ptr_ut.cpp index 63d253e128..5a325278db 100644 --- a/library/cpp/messagebus/misc/weak_ptr_ut.cpp +++ b/library/cpp/messagebus/misc/weak_ptr_ut.cpp @@ -1,11 +1,11 @@ #include <library/cpp/testing/unittest/registar.h> - -#include "weak_ptr.h" - + +#include "weak_ptr.h" + Y_UNIT_TEST_SUITE(TWeakPtrTest) { - struct TWeakPtrTester: public TWeakRefCounted<TWeakPtrTester> { - int* const CounterPtr; - + struct TWeakPtrTester: public TWeakRefCounted<TWeakPtrTester> { + int* const CounterPtr; + TWeakPtrTester(int* counterPtr) : CounterPtr(counterPtr) { @@ -13,34 +13,34 @@ Y_UNIT_TEST_SUITE(TWeakPtrTest) { ~TWeakPtrTester() { ++*CounterPtr; } - }; - + }; + Y_UNIT_TEST(Simple) { - int destroyCount = 0; - - TIntrusivePtr<TWeakPtrTester> p(new TWeakPtrTester(&destroyCount)); - - UNIT_ASSERT(!!p); - UNIT_ASSERT_VALUES_EQUAL(1u, p->RefCount()); - - TWeakPtr<TWeakPtrTester> p2(p); - - UNIT_ASSERT_VALUES_EQUAL(1u, p->RefCount()); - - { - TIntrusivePtr<TWeakPtrTester> p3 = p2.Get(); - UNIT_ASSERT(!!p3); - UNIT_ASSERT_VALUES_EQUAL(2u, p->RefCount()); - } - - p.Drop(); - UNIT_ASSERT_VALUES_EQUAL(1, destroyCount); - - { - TIntrusivePtr<TWeakPtrTester> p3 = p2.Get(); - UNIT_ASSERT(!p3); - } - - UNIT_ASSERT_VALUES_EQUAL(1, destroyCount); - } -} + int destroyCount = 0; + + TIntrusivePtr<TWeakPtrTester> p(new TWeakPtrTester(&destroyCount)); + + UNIT_ASSERT(!!p); + UNIT_ASSERT_VALUES_EQUAL(1u, p->RefCount()); + + TWeakPtr<TWeakPtrTester> p2(p); + + UNIT_ASSERT_VALUES_EQUAL(1u, p->RefCount()); + + { + TIntrusivePtr<TWeakPtrTester> p3 = p2.Get(); + UNIT_ASSERT(!!p3); + UNIT_ASSERT_VALUES_EQUAL(2u, p->RefCount()); + } + + p.Drop(); + UNIT_ASSERT_VALUES_EQUAL(1, destroyCount); + + { + TIntrusivePtr<TWeakPtrTester> p3 = p2.Get(); + UNIT_ASSERT(!p3); + } + + UNIT_ASSERT_VALUES_EQUAL(1, destroyCount); + } +} -- cgit v1.2.3