aboutsummaryrefslogtreecommitdiffstats
path: root/util/memory/smallobj_ut.cpp
diff options
context:
space:
mode:
authorAnton Samokhvalov <pg83@yandex.ru>2022-02-10 16:45:15 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:15 +0300
commit72cb13b4aff9bc9cf22e49251bc8fd143f82538f (patch)
treeda2c34829458c7d4e74bdfbdf85dff449e9e7fb8 /util/memory/smallobj_ut.cpp
parent778e51ba091dc39e7b7fcab2b9cf4dbedfb6f2b5 (diff)
downloadydb-72cb13b4aff9bc9cf22e49251bc8fd143f82538f.tar.gz
Restoring authorship annotation for Anton Samokhvalov <pg83@yandex.ru>. Commit 1 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 86003d1d53..ccd4d7e520 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);