12345678910111213141516171819202122232425262728293031323334353637383940 |
- #include "catch.hpp"
- #include "page_heap.h"
- #include "shm.h"
- TEST_CASE("RadixTree, Allocate Span")
- {
- bg::ShmOptions opts(false, "Test", nullptr);
- opts.fix_vptr_on_init = false;
- REQUIRE(bg::ShmInit(opts) == true);
- bg::detail::MetadataAllocator<bg::detail::Span> span_allocator;
- std::vector<bg::detail::Span*> vec;
- vec.reserve(2340);
- for(int i = 0; i < 2340; ++i)
- {
- bg::detail::Span* span = span_allocator.Allocate();
- REQUIRE(span);
- span->SetUsedCount(i);
- vec.push_back(span);
- }
- for(int i = 2340 - 1; i >= 0; --i)
- {
- span_allocator.Destroy(vec[i]);
- }
- for(int i = 0; i < 2340; ++i)
- {
- bg::detail::Span* span = span_allocator.Allocate();
- REQUIRE(span);
- REQUIRE(span->GetUsedCount() == i);
- }
- for(int i = 2340 - 1; i >= 0; --i)
- {
- span_allocator.Destroy(vec[i]);
- }
- bg::ShmFini();
- }
|