cpp-ipc/test/mem/test_mem_central_cache_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

45 lines
1.7 KiB
C++

#include "../archive/test.h"
#include <utility>
#include "libipc/mem/central_cache_pool.h"
TEST(central_cache_pool, ctor) {
ASSERT_FALSE((std::is_default_constructible<ipc::mem::central_cache_pool<ipc::mem::block<1>, 1>>::value));
ASSERT_FALSE((std::is_copy_constructible<ipc::mem::central_cache_pool<ipc::mem::block<1>, 1>>::value));
ASSERT_FALSE((std::is_move_constructible<ipc::mem::central_cache_pool<ipc::mem::block<1>, 1>>::value));
ASSERT_FALSE((std::is_copy_assignable<ipc::mem::central_cache_pool<ipc::mem::block<1>, 1>>::value));
ASSERT_FALSE((std::is_move_assignable<ipc::mem::central_cache_pool<ipc::mem::block<1>, 1>>::value));
{
auto &pool = ipc::mem::central_cache_pool<ipc::mem::block<1024>, 1>::instance();
ipc::mem::block<1024> *b1 = pool.aqueire();
ASSERT_FALSE(nullptr == b1);
EXPECT_TRUE (nullptr == b1->next);
pool.release(b1);
ipc::mem::block<1024> *b2 = pool.aqueire();
EXPECT_EQ(b1, b2);
ipc::mem::block<1024> *b3 = pool.aqueire();
ASSERT_FALSE(nullptr == b3);
EXPECT_TRUE (nullptr == b3->next);
EXPECT_NE(b1, b3);
}
{
auto &pool = ipc::mem::central_cache_pool<ipc::mem::block<1>, 2>::instance();
ipc::mem::block<1> *b1 = pool.aqueire();
ASSERT_FALSE(nullptr == b1);
ASSERT_FALSE(nullptr == b1->next);
EXPECT_TRUE (nullptr == b1->next->next);
pool.release(b1);
ipc::mem::block<1> *b2 = pool.aqueire();
EXPECT_EQ(b1, b2);
ipc::mem::block<1> *b3 = pool.aqueire();
EXPECT_NE(b1, b3);
ipc::mem::block<1> *b4 = pool.aqueire();
ASSERT_FALSE(nullptr == b4);
ASSERT_FALSE(nullptr == b4->next);
EXPECT_TRUE (nullptr == b4->next->next);
EXPECT_NE(b1, b4);
}
}