123456789101112131415161718192021222324252627282930313233343536 |
- #include "catch.hpp"
- #include "size_map.h"
- #include "shm_manager.h"
- TEST_CASE("SizeMap, CalcAlignment")
- {
- for(size_t i = 0; i < CLASS_MAX_BYTES; ++i)
- {
- auto value = bg::detail::SizeMap::CalcAlignment(i);
- REQUIRE(value > 0);
- REQUIRE(value % 8 == 0);
- REQUIRE(value <= PAGE_BYTES);
- if(i > 0x7F && i < (PAGE_BYTES << 4))
- {
- REQUIRE(PALIGN_DOWN(i, value << 3) == value << 3);
- }
- }
- }
- TEST_CASE("SizeMap, Class Index to Page")
- {
- bg::detail::SizeMap sizemap;
- sizemap.Init();
- for(size_t bytes = 0; bytes < CLASS_MAX_BYTES; ++bytes)
- {
- size_t index = sizemap.GetClassByBytes(bytes);
- REQUIRE(index < CLASS_MAX_COUNT);
- REQUIRE(sizemap.ClassToSize(index) >= bytes);
- REQUIRE(sizemap.ClassToPages(index) * PAGE_BYTES >= bytes);
- REQUIRE(sizemap.ClassToPages(index) * PAGE_BYTES <= CLASS_MAX_BYTES);
- }
- }
|