aboutsummaryrefslogtreecommitdiffstats
path: root/util/memory/smallobj_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:17 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:17 +0300
commitd3a398281c6fd1d3672036cb2d63f842d2cb28c5 (patch)
treedd4bd3ca0f36b817e96812825ffaf10d645803f2 /util/memory/smallobj_ut.cpp
parent72cb13b4aff9bc9cf22e49251bc8fd143f82538f (diff)
downloadydb-d3a398281c6fd1d3672036cb2d63f842d2cb28c5.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 2 of 2.
Diffstat (limited to 'util/memory/smallobj_ut.cpp')
-rw-r--r--util/memory/smallobj_ut.cpp126
1 files changed, 63 insertions, 63 deletions
diff --git a/util/memory/smallobj_ut.cpp b/util/memory/smallobj_ut.cpp
index ccd4d7e520..86003d1d53 100644
--- a/util/memory/smallobj_ut.cpp
+++ b/util/memory/smallobj_ut.cpp
@@ -1,33 +1,33 @@
-#include "smallobj.h"
-
+#include "smallobj.h"
+
#include <library/cpp/testing/unittest/registar.h>
-
+
#include <util/generic/hash_set.h>
-
-class TSmallObjAllocTest: public TTestBase {
- struct TClass: public TObjectFromPool<TClass> {
- char buf[125];
- };
-
- struct TErrClass: public TObjectFromPool<TErrClass> {
- inline TErrClass(bool t) {
- if (t) {
- throw 1;
- }
- }
- };
-
+
+class TSmallObjAllocTest: public TTestBase {
+ struct TClass: public TObjectFromPool<TClass> {
+ char buf[125];
+ };
+
+ struct TErrClass: public TObjectFromPool<TErrClass> {
+ inline TErrClass(bool t) {
+ if (t) {
+ throw 1;
+ }
+ }
+ };
+
struct TClass64: public TObjectFromPool<TClass64> {
alignas(64) ui64 Data = 0;
};
- UNIT_TEST_SUITE(TSmallObjAllocTest);
+ UNIT_TEST_SUITE(TSmallObjAllocTest);
UNIT_TEST(TestAlign)
UNIT_TEST(TestError)
- UNIT_TEST(TestAllocate)
- UNIT_TEST_SUITE_END();
-
-private:
+ UNIT_TEST(TestAllocate)
+ UNIT_TEST_SUITE_END();
+
+private:
void TestAlign() {
TClass64::TPool pool(TDefaultAllocator::Instance());
TClass64* f1 = new (&pool) TClass64;
@@ -41,47 +41,47 @@ private:
UNIT_ASSERT_VALUES_EQUAL((size_t)0, (size_t)(f4) & (alignof(TClass64) - 1));
}
- inline void TestError() {
- TErrClass::TPool pool(TDefaultAllocator::Instance());
- TErrClass* f = new (&pool) TErrClass(false);
-
- delete f;
-
- bool wasError = false;
-
- try {
- new (&pool) TErrClass(true);
- } catch (...) {
- wasError = true;
- }
-
- UNIT_ASSERT(wasError);
- UNIT_ASSERT_EQUAL(f, new (&pool) TErrClass(false));
- }
-
- inline void TestAllocate() {
- TClass::TPool pool(TDefaultAllocator::Instance());
+ inline void TestError() {
+ TErrClass::TPool pool(TDefaultAllocator::Instance());
+ TErrClass* f = new (&pool) TErrClass(false);
+
+ delete f;
+
+ bool wasError = false;
+
+ try {
+ new (&pool) TErrClass(true);
+ } catch (...) {
+ wasError = true;
+ }
+
+ UNIT_ASSERT(wasError);
+ UNIT_ASSERT_EQUAL(f, new (&pool) TErrClass(false));
+ }
+
+ inline void TestAllocate() {
+ TClass::TPool pool(TDefaultAllocator::Instance());
THashSet<TClass*> alloced;
-
- for (size_t i = 0; i < 10000; ++i) {
- TClass* c = new (&pool) TClass;
-
- UNIT_ASSERT_EQUAL(alloced.find(c), alloced.end());
- alloced.insert(c);
- }
-
+
+ for (size_t i = 0; i < 10000; ++i) {
+ TClass* c = new (&pool) TClass;
+
+ UNIT_ASSERT_EQUAL(alloced.find(c), alloced.end());
+ alloced.insert(c);
+ }
+
for (auto it : alloced) {
delete it;
- }
-
- for (size_t i = 0; i < 10000; ++i) {
- TClass* c = new (&pool) TClass;
-
- UNIT_ASSERT(alloced.find(c) != alloced.end());
- }
-
- UNIT_ASSERT_EQUAL(alloced.find(new (&pool) TClass), alloced.end());
- }
-};
-
-UNIT_TEST_SUITE_REGISTRATION(TSmallObjAllocTest);
+ }
+
+ for (size_t i = 0; i < 10000; ++i) {
+ TClass* c = new (&pool) TClass;
+
+ UNIT_ASSERT(alloced.find(c) != alloced.end());
+ }
+
+ UNIT_ASSERT_EQUAL(alloced.find(new (&pool) TClass), alloced.end());
+ }
+};
+
+UNIT_TEST_SUITE_REGISTRATION(TSmallObjAllocTest);