cpp-ipc/test/mem/test_mem_block_pool.cpp
木头云 b35de5a154 fix(test): Update test.h include paths after master rebase
After rebasing onto master, test.h was moved to test/archive/.
Updated include paths in test subdirectories:
- test/imp/*.cpp: "test.h" -> "../archive/test.h"
- test/mem/*.cpp: "test.h" -> "../archive/test.h"
- test/concur/*.cpp: "test.h" -> "../archive/test.h"

This ensures all test files can properly find the test header
after the directory reorganization in master branch.
2025-12-03 08:28:37 +00:00

33 lines
901 B
C++

#include "../archive/test.h"
#include <utility>
#include "libipc/mem/block_pool.h"
TEST(block_pool, ctor) {
ASSERT_TRUE ((std::is_default_constructible<ipc::mem::block_pool<1, 1>>::value));
ASSERT_FALSE((std::is_copy_constructible<ipc::mem::block_pool<1, 1>>::value));
ASSERT_TRUE ((std::is_move_constructible<ipc::mem::block_pool<1, 1>>::value));
ASSERT_FALSE((std::is_copy_assignable<ipc::mem::block_pool<1, 1>>::value));
ASSERT_FALSE((std::is_move_assignable<ipc::mem::block_pool<1, 1>>::value));
}
TEST(block_pool, allocate) {
std::vector<void *> v;
ipc::mem::block_pool<1, 1> pool;
for (int i = 0; i < 100; ++i) {
v.push_back(pool.allocate());
}
for (void *p: v) {
ASSERT_FALSE(nullptr == p);
pool.deallocate(p);
}
for (int i = 0; i < 100; ++i) {
ASSERT_EQ(v[v.size() - i - 1], pool.allocate());
}
for (void *p: v) {
pool.deallocate(p);
}
}