Files
Library/tests/standalone/Text/Semver.cpp
T
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

162 lines
5.4 KiB
C++

#include <Void/Text/Semver.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
#include <string>
// ── parse ─────────────────────────────────────────────────────────────────────
Void::Testing::Test semver_parse_simple()
{
const auto v = Void::Semver::parse("1.2.3");
Void::Testing::expect(v.has_value());
Void::Testing::expect_eq(v->major, 1u);
Void::Testing::expect_eq(v->minor, 2u);
Void::Testing::expect_eq(v->patch, 3u);
}
Void::Testing::Test semver_parse_with_v_prefix()
{
const auto v = Void::Semver::parse("v2.0.0");
Void::Testing::expect(v.has_value());
Void::Testing::expect_eq(v->major, 2u);
}
Void::Testing::Test semver_parse_pre_release()
{
const auto v = Void::Semver::parse("1.0.0-alpha.1");
Void::Testing::expect(v.has_value());
Void::Testing::expect_eq(v->pre_release, std::string{"alpha.1"});
}
Void::Testing::Test semver_parse_build_metadata()
{
const auto v = Void::Semver::parse("1.0.0+build.123");
Void::Testing::expect(v.has_value());
Void::Testing::expect_eq(v->build, std::string{"build.123"});
}
Void::Testing::Test semver_parse_full()
{
const auto v = Void::Semver::parse("2.3.4-beta.2+20240101");
Void::Testing::expect(v.has_value());
Void::Testing::expect_eq(v->major, 2u);
Void::Testing::expect_eq(v->pre_release, std::string{"beta.2"});
Void::Testing::expect_eq(v->build, std::string{"20240101"});
}
Void::Testing::Test semver_parse_invalid()
{
Void::Testing::expect(!Void::Semver::parse("not-a-version").has_value());
Void::Testing::expect(!Void::Semver::parse("1.2").has_value());
}
// ── to_string ─────────────────────────────────────────────────────────────────
Void::Testing::Test semver_to_string_simple()
{
Void::Semver::Version v{1, 2, 3};
Void::Testing::expect_eq(v.to_string(), std::string{"1.2.3"});
}
Void::Testing::Test semver_to_string_with_pre_release()
{
Void::Semver::Version v{1, 0, 0};
v.pre_release = "alpha";
Void::Testing::expect_eq(v.to_string(), std::string{"1.0.0-alpha"});
}
Void::Testing::Test semver_round_trip()
{
const auto v = Void::Semver::parse("3.1.4-rc.1+build1");
Void::Testing::expect(v.has_value());
Void::Testing::expect_eq(v->to_string(), std::string{"3.1.4-rc.1+build1"});
}
// ── comparison ───────────────────────────────────────────────────────────────
Void::Testing::Test semver_compare_major()
{
const auto a = *Void::Semver::parse("2.0.0");
const auto b = *Void::Semver::parse("1.9.9");
Void::Testing::expect(a > b);
}
Void::Testing::Test semver_compare_minor()
{
const auto a = *Void::Semver::parse("1.2.0");
const auto b = *Void::Semver::parse("1.1.9");
Void::Testing::expect(a > b);
}
Void::Testing::Test semver_compare_patch()
{
const auto a = *Void::Semver::parse("1.0.1");
const auto b = *Void::Semver::parse("1.0.0");
Void::Testing::expect(a > b);
}
Void::Testing::Test semver_release_gt_pre_release()
{
const auto a = *Void::Semver::parse("1.0.0");
const auto b = *Void::Semver::parse("1.0.0-alpha");
Void::Testing::expect(a > b);
}
Void::Testing::Test semver_equal()
{
const auto a = *Void::Semver::parse("1.2.3");
const auto b = *Void::Semver::parse("1.2.3");
Void::Testing::expect(a == b);
}
// ── bump ─────────────────────────────────────────────────────────────────────
Void::Testing::Test semver_bump_major()
{
const auto v = Void::Semver::Version{1, 2, 3};
const auto b = v.bumped_major();
Void::Testing::expect_eq(b.major, 2u);
Void::Testing::expect_eq(b.minor, 0u);
Void::Testing::expect_eq(b.patch, 0u);
}
Void::Testing::Test semver_bump_minor()
{
const auto v = Void::Semver::Version{1, 2, 3};
const auto b = v.bumped_minor();
Void::Testing::expect_eq(b.minor, 3u);
Void::Testing::expect_eq(b.patch, 0u);
}
Void::Testing::Test semver_bump_patch()
{
const auto v = Void::Semver::Version{1, 2, 3};
Void::Testing::expect_eq(v.bumped_patch().patch, 4u);
}
// ── compatible_with ───────────────────────────────────────────────────────────
Void::Testing::Test semver_compatible_same_major()
{
const auto a = *Void::Semver::parse("1.3.0");
const auto req = *Void::Semver::parse("1.2.0");
Void::Testing::expect(a.compatible_with(req));
}
Void::Testing::Test semver_incompatible_different_major()
{
const auto a = *Void::Semver::parse("2.0.0");
const auto req = *Void::Semver::parse("1.9.9");
Void::Testing::expect(!a.compatible_with(req));
}
Void::Testing::Test semver_is_stable()
{
Void::Testing::expect(Void::Semver::Version{1,0,0}.is_stable());
Void::Testing::expect(!Void::Semver::Version{0,9,0}.is_stable());
Void::Semver::Version pre{1,0,0};
pre.pre_release = "alpha";
Void::Testing::expect(!pre.is_stable());
}