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

Method TestAlign

util/memory/pool_ut.cpp:173–199  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

171 }
172
173 inline void TestAlign() {
174 TMemoryPool pool(1);
175
176 void* aligned16 = pool.Allocate(3, 16);
177 void* aligned2 = pool.Allocate(3, 2);
178 void* aligned128 = pool.Allocate(3, 128);
179 void* aligned4 = pool.Allocate(3, 4);
180 void* aligned256 = pool.Allocate(3, 256);
181 void* aligned8 = pool.Allocate(3, 8);
182 void* aligned1024 = pool.Allocate(3, 1024);
183
184 UNIT_ASSERT_VALUES_UNEQUAL(aligned16, nullptr);
185 UNIT_ASSERT_VALUES_UNEQUAL(aligned2, nullptr);
186 UNIT_ASSERT_VALUES_UNEQUAL(aligned128, nullptr);
187 UNIT_ASSERT_VALUES_UNEQUAL(aligned4, nullptr);
188 UNIT_ASSERT_VALUES_UNEQUAL(aligned256, nullptr);
189 UNIT_ASSERT_VALUES_UNEQUAL(aligned8, nullptr);
190 UNIT_ASSERT_VALUES_UNEQUAL(aligned1024, nullptr);
191
192 UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned2) & 1, 0);
193 UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned4) & 3, 0);
194 UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned8) & 7, 0);
195 UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned16) & 15, 0);
196 UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned128) & 127, 0);
197 UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned256) & 255, 0);
198 UNIT_ASSERT_VALUES_EQUAL(reinterpret_cast<uintptr_t>(aligned1024) & 1023, 0);
199 }
200
201 void TestZeroArray() {
202 TMemoryPool pool(1);

Callers

nothing calls this directly

Calls 1

AllocateMethod · 0.45

Tested by

no test coverage detected