aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/store_policy_ut.cpp
diff options
context:
space:
mode:
authorpechatnov <pechatnov@yandex-team.ru>2022-02-10 16:48:57 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:48:57 +0300
commit132a3640fac343164b858d0a914e020a848a2848 (patch)
tree5d5cb817648f650d76cf1076100726fd9b8448e8 /util/generic/store_policy_ut.cpp
parent8e9b2f8bbf4a2320f539eef5b85555f42c065425 (diff)
downloadydb-132a3640fac343164b858d0a914e020a848a2848.tar.gz
Restoring authorship annotation for <pechatnov@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'util/generic/store_policy_ut.cpp')
-rw-r--r--util/generic/store_policy_ut.cpp162
1 files changed, 81 insertions, 81 deletions
diff --git a/util/generic/store_policy_ut.cpp b/util/generic/store_policy_ut.cpp
index 30710dc913..c9722203aa 100644
--- a/util/generic/store_policy_ut.cpp
+++ b/util/generic/store_policy_ut.cpp
@@ -1,87 +1,87 @@
-#include "store_policy.h"
-
+#include "store_policy.h"
+
#include <library/cpp/testing/unittest/registar.h>
-#include <util/generic/algorithm.h>
-#include <util/generic/vector.h>
-
-Y_UNIT_TEST_SUITE(StorePolicy) {
- Y_UNIT_TEST(Compileability) {
- // construction
- TAutoEmbedOrPtrPolicy<THolder<int>>(MakeHolder<int>(1));
- TAutoEmbedOrPtrPolicy<TVector<int>>(TVector<int>{1, 2, 3});
- auto a = MakeHolder<int>(42);
- TAutoEmbedOrPtrPolicy<THolder<int>&>{a};
-
- // const
- (**TAutoEmbedOrPtrPolicy<THolder<int>>(MakeHolder<int>(1)).Ptr())++; // ok
+#include <util/generic/algorithm.h>
+#include <util/generic/vector.h>
+
+Y_UNIT_TEST_SUITE(StorePolicy) {
+ Y_UNIT_TEST(Compileability) {
+ // construction
+ TAutoEmbedOrPtrPolicy<THolder<int>>(MakeHolder<int>(1));
+ TAutoEmbedOrPtrPolicy<TVector<int>>(TVector<int>{1, 2, 3});
+ auto a = MakeHolder<int>(42);
+ TAutoEmbedOrPtrPolicy<THolder<int>&>{a};
+
+ // const
+ (**TAutoEmbedOrPtrPolicy<THolder<int>>(MakeHolder<int>(1)).Ptr())++; // ok
(**TAutoEmbedOrPtrPolicy<THolder<int>&>(a).Ptr())++; // ok
-
- const TVector<int> b = {0};
- auto bValue = (*TAutoEmbedOrPtrPolicy<const TVector<int>&>(b).Ptr())[0]; // ok
- // (*TAutoEmbedOrPtrPolicy<const TVector<int>&>(b).Ptr())[0]++; // not ok
- Y_UNUSED(bValue);
- }
-
- template <typename T, typename TFunc>
+
+ const TVector<int> b = {0};
+ auto bValue = (*TAutoEmbedOrPtrPolicy<const TVector<int>&>(b).Ptr())[0]; // ok
+ // (*TAutoEmbedOrPtrPolicy<const TVector<int>&>(b).Ptr())[0]++; // not ok
+ Y_UNUSED(bValue);
+ }
+
+ template <typename T, typename TFunc>
void FunctionTakingRefDefaultIsObject(T&& a, TFunc func) {
- TAutoEmbedOrPtrPolicy<T> refHolder(a);
- func(refHolder);
- }
-
- Y_UNIT_TEST(Reference) {
- {
- TVector<ui32> a = {1, 2, 3};
-
- FunctionTakingRefDefaultIsObject(a, [](auto& holder) {
- holder.Ptr()->push_back(4);
- auto secondHolder = holder;
- secondHolder.Ptr()->push_back(5);
- });
-
- UNIT_ASSERT_VALUES_EQUAL(a.size(), 5);
- }
- {
- const TVector<ui32> a = {1, 2, 3};
-
- static_assert(std::is_const<decltype(a)>::value);
-
- FunctionTakingRefDefaultIsObject(a, [](auto& holder) {
+ TAutoEmbedOrPtrPolicy<T> refHolder(a);
+ func(refHolder);
+ }
+
+ Y_UNIT_TEST(Reference) {
+ {
+ TVector<ui32> a = {1, 2, 3};
+
+ FunctionTakingRefDefaultIsObject(a, [](auto& holder) {
+ holder.Ptr()->push_back(4);
+ auto secondHolder = holder;
+ secondHolder.Ptr()->push_back(5);
+ });
+
+ UNIT_ASSERT_VALUES_EQUAL(a.size(), 5);
+ }
+ {
+ const TVector<ui32> a = {1, 2, 3};
+
+ static_assert(std::is_const<decltype(a)>::value);
+
+ FunctionTakingRefDefaultIsObject(a, [](auto& holder) {
static_assert(std::is_const<std::remove_reference_t<decltype(*holder.Ptr())>>::value);
- UNIT_ASSERT_VALUES_EQUAL(holder.Ptr()->size(), 3);
- });
- }
- }
-
- template <typename T, typename TFunc>
+ UNIT_ASSERT_VALUES_EQUAL(holder.Ptr()->size(), 3);
+ });
+ }
+ }
+
+ template <typename T, typename TFunc>
void FunctionTakingObjectDefaultObject(T&& a, TFunc func) {
TAutoEmbedOrPtrPolicy<T> objectHolder(std::forward<T>(a));
- func(objectHolder);
- }
-
- Y_UNIT_TEST(Object) {
- TVector<ui32> a = {1, 2, 3};
-
- FunctionTakingObjectDefaultObject(std::move(a), [&a](auto& holder) {
- static_assert(std::is_copy_assignable<decltype(holder)>::value);
- UNIT_ASSERT_VALUES_EQUAL(a.size(), 0);
- UNIT_ASSERT_VALUES_EQUAL(holder.Ptr()->size(), 3);
- holder.Ptr()->push_back(4);
- auto secondHolder = holder;
- secondHolder.Ptr()->push_back(5);
-
- UNIT_ASSERT_VALUES_EQUAL(holder.Ptr()->size(), 4);
- UNIT_ASSERT_VALUES_EQUAL(secondHolder.Ptr()->size(), 5);
- });
-
- UNIT_ASSERT_VALUES_EQUAL(a.size(), 0);
-
- THolder<int> b = MakeHolder<int>(42);
- FunctionTakingObjectDefaultObject(std::move(b), [](auto& holder) {
- static_assert(!std::is_copy_assignable<decltype(holder)>::value);
- UNIT_ASSERT_VALUES_EQUAL(**holder.Ptr(), 42);
- auto secondHolder = std::move(holder);
- UNIT_ASSERT(!*holder.Ptr());
- UNIT_ASSERT_VALUES_EQUAL(**secondHolder.Ptr(), 42);
- });
- }
-}
+ func(objectHolder);
+ }
+
+ Y_UNIT_TEST(Object) {
+ TVector<ui32> a = {1, 2, 3};
+
+ FunctionTakingObjectDefaultObject(std::move(a), [&a](auto& holder) {
+ static_assert(std::is_copy_assignable<decltype(holder)>::value);
+ UNIT_ASSERT_VALUES_EQUAL(a.size(), 0);
+ UNIT_ASSERT_VALUES_EQUAL(holder.Ptr()->size(), 3);
+ holder.Ptr()->push_back(4);
+ auto secondHolder = holder;
+ secondHolder.Ptr()->push_back(5);
+
+ UNIT_ASSERT_VALUES_EQUAL(holder.Ptr()->size(), 4);
+ UNIT_ASSERT_VALUES_EQUAL(secondHolder.Ptr()->size(), 5);
+ });
+
+ UNIT_ASSERT_VALUES_EQUAL(a.size(), 0);
+
+ THolder<int> b = MakeHolder<int>(42);
+ FunctionTakingObjectDefaultObject(std::move(b), [](auto& holder) {
+ static_assert(!std::is_copy_assignable<decltype(holder)>::value);
+ UNIT_ASSERT_VALUES_EQUAL(**holder.Ptr(), 42);
+ auto secondHolder = std::move(holder);
+ UNIT_ASSERT(!*holder.Ptr());
+ UNIT_ASSERT_VALUES_EQUAL(**secondHolder.Ptr(), 42);
+ });
+ }
+}