Restructure into umbrella modules (~55 -> 16 targets)
Headers move, CMake targets merge, C++ namespaces stay unchanged: - Core: Scope, Lazy, Counted, Flags, Hash, Bits, Uuid, TypeList, TypeMap, Variant - Functional: Pipeline, Either, Result, Retry - Containers: Ring, Pool, PriorityQueue, LRU, Trie, Graph, DisjointSet, Bitset, Interval - Math: +Matrix, Numeric, Random, Histogram - Text: Str, Format, Tokenizer, Diff, Encoding, Semver - Data: Json, Csv, Ini - Async: Coro, Concurrency, EventBus, Observable - Time: +Bench - Log: Log facade + Logging framework (facade now header-only, breaking the Stacktrace<->Log link cycle the merge would have created) - System: FileSystem + Process - Configuration: +Argparse - Unchanged: Stacktrace, Plugin, StateMachine, Testing, TestingMock, Detail Module system fixes: - OPTIONAL_DEPS resolution deferred to void_finalize_modules() so it no longer depends on the alphabetical discovery order of src/ subdirs (Testing -> Text would have been silently dropped). - Every header-only module now has a tracked module.cmake; previously the empty src/<Name> marker dirs were untracked, so a fresh clone would have silently skipped those modules. - VOID_HAS_LOGGING/CONCURRENCY/STR consumers renamed to LOG/ASYNC/TEXT. Tests move to tests/standalone/<Umbrella>/<Feature>.cpp (Result suite files prefixed: ResultBasic etc.). Test count verified identical (831) before and after. README/CLAUDE.md module tables updated. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
da2e93c405
commit
28b94883fd
156 files changed
+278
-220
No files matched your search
@@ -0,0 +1,103 @@
|
||||
#include <Void/Containers/Pool.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
// ── ObjectPool ────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test object_pool_acquire_returns_valid_ptr()
|
||||
{
|
||||
Void::Pool::ObjectPool<int> pool;
|
||||
auto p = pool.acquire(42);
|
||||
Void::Testing::expect(p != nullptr);
|
||||
Void::Testing::expect_eq(*p, 42);
|
||||
}
|
||||
|
||||
Void::Testing::Test object_pool_release_on_ptr_destruction()
|
||||
{
|
||||
Void::Pool::ObjectPool<int, 4> pool;
|
||||
Void::Testing::expect_eq(pool.available(), std::size_t{0});
|
||||
{
|
||||
auto p = pool.acquire(1);
|
||||
// capacity grew to 4, 3 slots free
|
||||
Void::Testing::expect_eq(pool.available(), std::size_t{3});
|
||||
}
|
||||
// Released back to pool
|
||||
Void::Testing::expect_eq(pool.available(), std::size_t{4});
|
||||
}
|
||||
|
||||
Void::Testing::Test object_pool_reuses_memory()
|
||||
{
|
||||
Void::Pool::ObjectPool<int, 4> pool;
|
||||
int* raw1 = nullptr;
|
||||
{
|
||||
auto p = pool.acquire(1);
|
||||
raw1 = p.get();
|
||||
}
|
||||
auto p2 = pool.acquire(2);
|
||||
// After release the same slot should be reused (LIFO from free list)
|
||||
Void::Testing::expect(p2.get() == raw1);
|
||||
}
|
||||
|
||||
Void::Testing::Test object_pool_string_construction()
|
||||
{
|
||||
Void::Pool::ObjectPool<std::string> pool;
|
||||
auto p = pool.acquire("hello");
|
||||
Void::Testing::expect_eq(*p, std::string{"hello"});
|
||||
}
|
||||
|
||||
Void::Testing::Test object_pool_capacity_grows()
|
||||
{
|
||||
Void::Pool::ObjectPool<int, 4> pool;
|
||||
Void::Testing::expect_eq(pool.capacity(), std::size_t{0});
|
||||
auto p = pool.acquire(1);
|
||||
Void::Testing::expect_eq(pool.capacity(), std::size_t{4});
|
||||
}
|
||||
|
||||
// ── FixedPool ─────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test fixed_pool_capacity()
|
||||
{
|
||||
Void::Pool::FixedPool<int, 8> pool;
|
||||
static_assert(pool.capacity() == 8);
|
||||
Void::Testing::expect_eq(pool.available(), std::size_t{8});
|
||||
}
|
||||
|
||||
Void::Testing::Test fixed_pool_acquire_decrements_available()
|
||||
{
|
||||
Void::Pool::FixedPool<int, 4> pool;
|
||||
auto p = pool.acquire(99);
|
||||
Void::Testing::expect_eq(pool.available(), std::size_t{3});
|
||||
Void::Testing::expect_eq(*p, 99);
|
||||
}
|
||||
|
||||
Void::Testing::Test fixed_pool_returns_null_when_full()
|
||||
{
|
||||
Void::Pool::FixedPool<int, 2> pool;
|
||||
auto p1 = pool.acquire(1);
|
||||
auto p2 = pool.acquire(2);
|
||||
auto p3 = pool.acquire(3); // should be nullptr
|
||||
Void::Testing::expect(p3 == nullptr);
|
||||
}
|
||||
|
||||
Void::Testing::Test fixed_pool_release_restores_available()
|
||||
{
|
||||
Void::Pool::FixedPool<int, 4> pool;
|
||||
{
|
||||
auto p = pool.acquire(1);
|
||||
Void::Testing::expect_eq(pool.available(), std::size_t{3});
|
||||
}
|
||||
Void::Testing::expect_eq(pool.available(), std::size_t{4});
|
||||
}
|
||||
|
||||
Void::Testing::Test fixed_pool_reuse_after_release()
|
||||
{
|
||||
Void::Pool::FixedPool<int, 4> pool;
|
||||
auto p1 = pool.acquire(1);
|
||||
auto p2 = pool.acquire(2);
|
||||
p1.reset();
|
||||
auto p3 = pool.acquire(3);
|
||||
Void::Testing::expect(p3 != nullptr);
|
||||
Void::Testing::expect_eq(*p3, 3);
|
||||
}
|
||||
Reference in new issue
Block a user