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,120 @@
|
||||
#include <Void/Math/Random.hpp>
|
||||
#include <Void/Testing/Assert.hpp>
|
||||
#include <Void/Testing/Test.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
// ── Xoshiro256 ───────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test xoshiro_produces_output()
|
||||
{
|
||||
Void::Random::Xoshiro256 rng{42};
|
||||
const auto a = rng();
|
||||
const auto b = rng();
|
||||
Void::Testing::expect(a != b);
|
||||
}
|
||||
|
||||
Void::Testing::Test xoshiro_same_seed_same_sequence()
|
||||
{
|
||||
Void::Random::Xoshiro256 r1{12345};
|
||||
Void::Random::Xoshiro256 r2{12345};
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
Void::Testing::expect_eq(r1(), r2());
|
||||
}
|
||||
}
|
||||
|
||||
Void::Testing::Test xoshiro_different_seeds_differ()
|
||||
{
|
||||
Void::Random::Xoshiro256 r1{1};
|
||||
Void::Random::Xoshiro256 r2{2};
|
||||
Void::Testing::expect(r1() != r2());
|
||||
}
|
||||
|
||||
// ── uniform_int ──────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test uniform_int_in_range()
|
||||
{
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
const auto v = Void::Random::uniform_int(1, 6);
|
||||
Void::Testing::expect(v >= 1);
|
||||
Void::Testing::expect(v <= 6);
|
||||
}
|
||||
}
|
||||
|
||||
Void::Testing::Test uniform_int_single_value()
|
||||
{
|
||||
Void::Testing::expect_eq(Void::Random::uniform_int(7, 7), 7);
|
||||
}
|
||||
|
||||
// ── uniform_real ─────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test uniform_real_in_range()
|
||||
{
|
||||
for (int i = 0; i < 50; ++i) {
|
||||
const double v = Void::Random::uniform_real(0.0, 1.0);
|
||||
Void::Testing::expect(v >= 0.0);
|
||||
Void::Testing::expect(v < 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
// ── coin_flip ────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test coin_flip_always_true()
|
||||
{
|
||||
Void::Testing::expect(Void::Random::coin_flip(1.0));
|
||||
}
|
||||
|
||||
Void::Testing::Test coin_flip_always_false()
|
||||
{
|
||||
Void::Testing::expect(!Void::Random::coin_flip(0.0));
|
||||
}
|
||||
|
||||
// ── shuffle ──────────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test shuffle_preserves_elements()
|
||||
{
|
||||
std::vector<int> v{1, 2, 3, 4, 5};
|
||||
const auto orig = v;
|
||||
Void::Random::shuffle(v);
|
||||
auto sorted = v;
|
||||
std::sort(sorted.begin(), sorted.end());
|
||||
Void::Testing::expect_eq(sorted, orig);
|
||||
}
|
||||
|
||||
// ── random_string ────────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test random_string_correct_length()
|
||||
{
|
||||
Void::Testing::expect_eq(Void::Random::random_string(10).size(),
|
||||
std::size_t{10});
|
||||
}
|
||||
|
||||
Void::Testing::Test random_string_empty()
|
||||
{
|
||||
Void::Testing::expect(Void::Random::random_string(0).empty());
|
||||
}
|
||||
|
||||
Void::Testing::Test random_string_varies()
|
||||
{
|
||||
// Extremely unlikely to produce identical 16-char strings twice
|
||||
const auto a = Void::Random::random_string(16);
|
||||
const auto b = Void::Random::random_string(16);
|
||||
Void::Testing::expect(a != b);
|
||||
}
|
||||
|
||||
// ── sample_indices ───────────────────────────────────────────────────────────
|
||||
|
||||
Void::Testing::Test sample_indices_correct_count()
|
||||
{
|
||||
const auto idxs = Void::Random::sample_indices(20, 5);
|
||||
Void::Testing::expect_eq(idxs.size(), std::size_t{5});
|
||||
}
|
||||
|
||||
Void::Testing::Test sample_indices_in_range()
|
||||
{
|
||||
const auto idxs = Void::Random::sample_indices(10, 10);
|
||||
for (auto i : idxs) {
|
||||
Void::Testing::expect(i < std::size_t{10});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user