| 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 | |
| 87 | UNIT_TEST_SUITE_REGISTRATION(TSmallObjAllocTest); |