diff options
author | haposik <haposik@yandex-team.ru> | 2022-02-10 16:50:37 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:50:37 +0300 |
commit | f28ae3e2752def3bd0a14422be2a0b22ab434b9c (patch) | |
tree | 5d5cb817648f650d76cf1076100726fd9b8448e8 /library/cpp/containers/stack_vector/stack_vec_ut.cpp | |
parent | 8ae61e4a3dbd76284bc0d997975a50d6df18d448 (diff) | |
download | ydb-f28ae3e2752def3bd0a14422be2a0b22ab434b9c.tar.gz |
Restoring authorship annotation for <haposik@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/containers/stack_vector/stack_vec_ut.cpp')
-rw-r--r-- | library/cpp/containers/stack_vector/stack_vec_ut.cpp | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/library/cpp/containers/stack_vector/stack_vec_ut.cpp b/library/cpp/containers/stack_vector/stack_vec_ut.cpp index 85c25f21c0..19f9677781 100644 --- a/library/cpp/containers/stack_vector/stack_vec_ut.cpp +++ b/library/cpp/containers/stack_vector/stack_vec_ut.cpp @@ -19,28 +19,28 @@ namespace { char Junk[JunkPayloadSize]{sizeof(T)}; }; - - template <class T> - struct TStatefulAlloc: public std::allocator<T> { - using TBase = std::allocator<T>; - - template <class U> - struct rebind { - using other = TStatefulAlloc<U>; - }; - - TStatefulAlloc(size_t* allocCount) - : AllocCount(allocCount) - {} - - size_t* AllocCount; - - T* allocate(size_t n) - { - *AllocCount += 1; - return TBase::allocate(n); - } - }; + + template <class T> + struct TStatefulAlloc: public std::allocator<T> { + using TBase = std::allocator<T>; + + template <class U> + struct rebind { + using other = TStatefulAlloc<U>; + }; + + TStatefulAlloc(size_t* allocCount) + : AllocCount(allocCount) + {} + + size_t* AllocCount; + + T* allocate(size_t n) + { + *AllocCount += 1; + return TBase::allocate(n); + } + }; } Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { @@ -132,13 +132,13 @@ Y_UNIT_TEST_SUITE(TStackBasedVectorTest) { using TVec = TStackVec<size_t, 1, true, TThickAlloc<size_t, n>>; UNIT_ASSERT_LT(sizeof(TVec), 1.5 * n); } - - Y_UNIT_TEST(TestStatefulAlloc) { - size_t count = 0; - TStackVec<size_t, 1, true, TStatefulAlloc<size_t>> vec{{ &count }}; - for (size_t i = 0; i < 5; ++i) { - vec.push_back(1); - } - UNIT_ASSERT_VALUES_EQUAL(count, 3); - } + + Y_UNIT_TEST(TestStatefulAlloc) { + size_t count = 0; + TStackVec<size_t, 1, true, TStatefulAlloc<size_t>> vec{{ &count }}; + for (size_t i = 0; i < 5; ++i) { + vec.push_back(1); + } + UNIT_ASSERT_VALUES_EQUAL(count, 3); + } } |