diff options
author | lukyan <lukyan@yandex-team.ru> | 2022-02-10 16:48:13 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:48:13 +0300 |
commit | 96647fad5355ff5ef45a00a6d85c097028584ab0 (patch) | |
tree | b222e5ac2e2e98872661c51ccceee5da0d291e13 /library/cpp/yt/memory/unittests | |
parent | 3e359c7e6344b01b8d0b0fc619297ffdc2644c49 (diff) | |
download | ydb-96647fad5355ff5ef45a00a6d85c097028584ab0.tar.gz |
Restoring authorship annotation for <lukyan@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/yt/memory/unittests')
-rw-r--r-- | library/cpp/yt/memory/unittests/intrusive_ptr_ut.cpp | 160 | ||||
-rw-r--r-- | library/cpp/yt/memory/unittests/weak_ptr_ut.cpp | 68 | ||||
-rw-r--r-- | library/cpp/yt/memory/unittests/ya.make | 30 |
3 files changed, 129 insertions, 129 deletions
diff --git a/library/cpp/yt/memory/unittests/intrusive_ptr_ut.cpp b/library/cpp/yt/memory/unittests/intrusive_ptr_ut.cpp index 5b19a9add8..622bed0eb0 100644 --- a/library/cpp/yt/memory/unittests/intrusive_ptr_ut.cpp +++ b/library/cpp/yt/memory/unittests/intrusive_ptr_ut.cpp @@ -1,4 +1,4 @@ -#include <library/cpp/testing/gtest/gtest.h> +#include <library/cpp/testing/gtest/gtest.h> #include <library/cpp/yt/memory/new.h> #include <library/cpp/yt/memory/ref_counted.h> @@ -68,9 +68,9 @@ MATCHER_P3(HasRefCounts, increments, decrements, zeros, void PrintTo(const TIntricateObject& arg, ::std::ostream* os) { - *os << arg.Increments << " increments, " - << arg.Decrements << " decrements and " - << arg.Zeros << " times vanished"; + *os << arg.Increments << " increments, " + << arg.Decrements << " decrements and " + << arg.Zeros << " times vanished"; } // This is an object which creates intrusive pointers to the self @@ -480,82 +480,82 @@ TEST(TIntrusivePtrTest, ObjectAlignment) EXPECT_TRUE(reinterpret_cast<uintptr_t>(bar.Get()) % 64 == 0); } -TEST(TIntrusivePtrTest, InitStruct) -{ - struct TObj1 final - { - const int A; - const int B; - }; - - New<TObj1>(1, 2); - - struct TExplicitObj final - { - explicit TExplicitObj(int a = 0) - : A(a) - { } - - const int A; - }; - - New<TExplicitObj>(); - New<TExplicitObj>(1); - - struct TObj2 final - { - TObj2(i64 a = 0) - : A(a) - { } - - const i64 A; - }; - - New<TObj2>(123); - - struct TObj3 final - { - TObj3(ui64 a = 0) - : A(a) - { } - - const ui64 A; - }; - - New<TObj3>(123); - - struct TObj4 final - { - TObj4(int a, ui64 b = 0) - : A(a) - , B(b) - { } - - int A; - const ui64 B; - }; - - New<TObj4>(123); - New<TObj4>(123, 123); - - struct TObj5 final - { - TExplicitObj E; - int B; - }; - - New<TObj5>(); - - struct TObj6 final - { - TObj2 O; - int B; - }; - - New<TObj6>(); - New<TObj6>(1, 2); -} - +TEST(TIntrusivePtrTest, InitStruct) +{ + struct TObj1 final + { + const int A; + const int B; + }; + + New<TObj1>(1, 2); + + struct TExplicitObj final + { + explicit TExplicitObj(int a = 0) + : A(a) + { } + + const int A; + }; + + New<TExplicitObj>(); + New<TExplicitObj>(1); + + struct TObj2 final + { + TObj2(i64 a = 0) + : A(a) + { } + + const i64 A; + }; + + New<TObj2>(123); + + struct TObj3 final + { + TObj3(ui64 a = 0) + : A(a) + { } + + const ui64 A; + }; + + New<TObj3>(123); + + struct TObj4 final + { + TObj4(int a, ui64 b = 0) + : A(a) + , B(b) + { } + + int A; + const ui64 B; + }; + + New<TObj4>(123); + New<TObj4>(123, 123); + + struct TObj5 final + { + TExplicitObj E; + int B; + }; + + New<TObj5>(); + + struct TObj6 final + { + TObj2 O; + int B; + }; + + New<TObj6>(); + New<TObj6>(1, 2); +} + //////////////////////////////////////////////////////////////////////////////// } // namespace diff --git a/library/cpp/yt/memory/unittests/weak_ptr_ut.cpp b/library/cpp/yt/memory/unittests/weak_ptr_ut.cpp index c00451badd..180c16b5ca 100644 --- a/library/cpp/yt/memory/unittests/weak_ptr_ut.cpp +++ b/library/cpp/yt/memory/unittests/weak_ptr_ut.cpp @@ -1,9 +1,9 @@ -#include <library/cpp/testing/gtest/gtest.h> +#include <library/cpp/testing/gtest/gtest.h> #include <library/cpp/yt/memory/new.h> #include <library/cpp/yt/memory/weak_ptr.h> -#include <array> +#include <array> namespace NYT { namespace { @@ -91,8 +91,8 @@ MATCHER_P2(HasRefCounts, strongRefs, weakRefs, template <class T> void PrintExtrinsicRefCounted(const T& arg, ::std::ostream* os) { - *os << arg.GetRefCount() << " strong and " - << arg.GetWeakRefCount() << " weak references"; + *os << arg.GetRefCount() << " strong and " + << arg.GetWeakRefCount() << " weak references"; } void PrintTo(const TIntricateObject& arg, ::std::ostream* os) @@ -353,32 +353,32 @@ TEST_F(TWeakPtrTest, VirtualBase) ptr.Reset(); } -#if 0 -class TSlowlyDyingObject - : public TRefCounted -{ -public: - TSlowlyDyingObject() - { - ++ConstructorShadowState; - } - - virtual ~TSlowlyDyingObject() - { - ++DestructorShadowState; - DeathEvent->Wait(); - ++DestructorShadowState; - } -}; - -void PrintTo(const TSlowlyDyingObject& arg, ::std::ostream* os) -{ - PrintExtrinsicRefCounted(arg, os); -} - -typedef TIntrusivePtr<TSlowlyDyingObject> TSlowlyDyingObjectPtr; -typedef TWeakPtr<TSlowlyDyingObject> TSlowlyDyingObjectWkPtr; - +#if 0 +class TSlowlyDyingObject + : public TRefCounted +{ +public: + TSlowlyDyingObject() + { + ++ConstructorShadowState; + } + + virtual ~TSlowlyDyingObject() + { + ++DestructorShadowState; + DeathEvent->Wait(); + ++DestructorShadowState; + } +}; + +void PrintTo(const TSlowlyDyingObject& arg, ::std::ostream* os) +{ + PrintExtrinsicRefCounted(arg, os); +} + +typedef TIntrusivePtr<TSlowlyDyingObject> TSlowlyDyingObjectPtr; +typedef TWeakPtr<TSlowlyDyingObject> TSlowlyDyingObjectWkPtr; + static void* AsynchronousDeleter(void* param) { TSlowlyDyingObjectPtr* indirectObject = @@ -388,11 +388,11 @@ static void* AsynchronousDeleter(void* param) } std::unique_ptr<NThreading::TEvent> DeathEvent; - + TEST_F(TWeakPtrTest, DISABLED_AcquisionOfSlowlyDyingObject) { DeathEvent.reset(new NThreading::TEvent()); - + TSlowlyDyingObjectPtr object = New<TSlowlyDyingObject>(); TSlowlyDyingObjectWkPtr ptr(object); @@ -425,8 +425,8 @@ TEST_F(TWeakPtrTest, DISABLED_AcquisionOfSlowlyDyingObject) EXPECT_EQ(TSlowlyDyingObjectPtr(), ptr.Lock()); } -#endif - +#endif + //////////////////////////////////////////////////////////////////////////////// } // namespace diff --git a/library/cpp/yt/memory/unittests/ya.make b/library/cpp/yt/memory/unittests/ya.make index 4b86574609..f09ad7d0c9 100644 --- a/library/cpp/yt/memory/unittests/ya.make +++ b/library/cpp/yt/memory/unittests/ya.make @@ -1,19 +1,19 @@ -GTEST(unittester-library-memory) - -OWNER(g:yt) - +GTEST(unittester-library-memory) + +OWNER(g:yt) + IF (NOT OS_WINDOWS) ALLOCATOR(YT) ENDIF() - -SRCS( - intrusive_ptr_ut.cpp - weak_ptr_ut.cpp -) - -PEERDIR( - library/cpp/testing/gtest + +SRCS( + intrusive_ptr_ut.cpp + weak_ptr_ut.cpp +) + +PEERDIR( + library/cpp/testing/gtest library/cpp/yt/memory -) - -END() +) + +END() |