MCPcopy Create free account
hub / github.com/catboost/catboost / TestAllocate

Method TestAllocate

util/memory/smallobj_ut.cpp:62–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 }
61
62 inline void TestAllocate() {
63 TClass::TPool pool(TDefaultAllocator::Instance());
64 THashSet<TClass*> alloced;
65
66 for (size_t i = 0; i < 10000; ++i) {
67 TClass* c = new (&pool) TClass;
68
69 UNIT_ASSERT_EQUAL(alloced.find(c), alloced.end());
70 alloced.insert(c);
71 }
72
73 for (auto it : alloced) {
74 delete it;
75 }
76
77 for (size_t i = 0; i < 10000; ++i) {
78 TClass* c = new (&pool) TClass;
79
80 UNIT_ASSERT(alloced.find(c) != alloced.end());
81 }
82
83 UNIT_ASSERT_EQUAL(alloced.find(new (&pool) TClass), alloced.end());
84 }
85};
86
87UNIT_TEST_SUITE_REGISTRATION(TSmallObjAllocTest);

Callers

nothing calls this directly

Calls 4

InstanceFunction · 0.85
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected