Files
Library/tests/standalone/Core/Uuid.cpp
faumarayandClaude Fable 5 28b94883fd 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>
2026-06-12 18:50:02 +03:00

114 lines
3.7 KiB
C++

#include <Void/Core/Uuid.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
// ── v4 ───────────────────────────────────────────────────────────────────────
Void::Testing::Test v4_not_nil()
{
Void::Testing::expect(!Void::Uuid::v4().is_nil());
}
Void::Testing::Test v4_version_nibble()
{
const auto u = Void::Uuid::v4();
Void::Testing::expect_eq(u.bytes[6] >> 4, std::uint8_t{4});
}
Void::Testing::Test v4_variant_bits()
{
const auto u = Void::Uuid::v4();
// top two bits of byte 8 must be 10
Void::Testing::expect_eq(u.bytes[8] >> 6, std::uint8_t{2});
}
Void::Testing::Test v4_unique()
{
Void::Testing::expect(Void::Uuid::v4() != Void::Uuid::v4());
}
Void::Testing::Test v4_string_length()
{
Void::Testing::expect_eq(Void::Uuid::v4().to_string().size(),
std::size_t{36});
}
Void::Testing::Test v4_string_has_dashes()
{
const auto s = Void::Uuid::v4().to_string();
Void::Testing::expect_eq(s[8], '-');
Void::Testing::expect_eq(s[13], '-');
Void::Testing::expect_eq(s[18], '-');
Void::Testing::expect_eq(s[23], '-');
}
// ── v5_lite ───────────────────────────────────────────────────────────────────
Void::Testing::Test v5_lite_deterministic()
{
const auto a = Void::Uuid::v5_lite(Void::Uuid::Namespace::Dns, "example.com");
const auto b = Void::Uuid::v5_lite(Void::Uuid::Namespace::Dns, "example.com");
Void::Testing::expect_eq(a, b);
}
Void::Testing::Test v5_lite_different_names()
{
const auto a = Void::Uuid::v5_lite(Void::Uuid::Namespace::Dns, "foo.com");
const auto b = Void::Uuid::v5_lite(Void::Uuid::Namespace::Dns, "bar.com");
Void::Testing::expect(a != b);
}
Void::Testing::Test v5_lite_different_namespaces()
{
const auto a = Void::Uuid::v5_lite(Void::Uuid::Namespace::Dns, "example");
const auto b = Void::Uuid::v5_lite(Void::Uuid::Namespace::Url, "example");
Void::Testing::expect(a != b);
}
Void::Testing::Test v5_lite_version_nibble()
{
const auto u = Void::Uuid::v5_lite(Void::Uuid::Namespace::Dns, "test");
Void::Testing::expect_eq(u.bytes[6] >> 4, std::uint8_t{5});
}
// ── parse ────────────────────────────────────────────────────────────────────
Void::Testing::Test parse_round_trip()
{
const auto u = Void::Uuid::v4();
const auto s = u.to_string();
const auto parsed = Void::Uuid::parse(s);
Void::Testing::expect(parsed.has_value());
Void::Testing::expect_eq(*parsed, u);
}
Void::Testing::Test parse_uppercase()
{
const auto opt = Void::Uuid::parse(
"550E8400-E29B-41D4-A716-446655440000");
Void::Testing::expect(opt.has_value());
}
Void::Testing::Test parse_invalid_returns_nullopt()
{
Void::Testing::expect(!Void::Uuid::parse("not-a-uuid").has_value());
}
Void::Testing::Test parse_32_char_hex()
{
const auto opt = Void::Uuid::parse("550e8400e29b41d4a716446655440000");
Void::Testing::expect(opt.has_value());
}
// ── nil ──────────────────────────────────────────────────────────────────────
Void::Testing::Test nil_uuid_is_nil()
{
Void::Testing::expect(Void::Uuid::Uuid::nil().is_nil());
}
Void::Testing::Test v4_not_nil_check()
{
Void::Testing::expect(!Void::Uuid::v4().is_nil());
}