Files
Library/tests/standalone/Containers/Interval.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

110 lines
3.5 KiB
C++

#include <Void/Containers/Interval.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Test.hpp>
using namespace Void::Interval;
// ── contains ──────────────────────────────────────────────────────────────────
Void::Testing::Test interval_contains_midpoint()
{
const auto iv = make_interval(0, 10);
Void::Testing::expect(iv.contains(5));
Void::Testing::expect(iv.contains(0));
Void::Testing::expect(!iv.contains(10));
}
Void::Testing::Test interval_contains_closed()
{
const auto iv = make_interval(0, 10);
Void::Testing::expect(iv.contains_closed(10));
Void::Testing::expect(!iv.contains_closed(11));
}
Void::Testing::Test interval_empty()
{
const auto iv = make_interval(5, 5);
Void::Testing::expect(iv.empty());
Void::Testing::expect(!make_interval(1, 2).empty());
}
Void::Testing::Test interval_length()
{
const auto iv = make_interval(3, 8);
Void::Testing::expect_eq(iv.length(), 5);
}
// ── set operations ────────────────────────────────────────────────────────────
Void::Testing::Test interval_overlaps()
{
const auto a = make_interval(0, 5);
const auto b = make_interval(3, 8);
const auto c = make_interval(5, 9);
Void::Testing::expect(a.overlaps(b));
Void::Testing::expect(!a.overlaps(c));
}
Void::Testing::Test interval_adjacent()
{
const auto a = make_interval(0, 5);
const auto b = make_interval(5, 10);
Void::Testing::expect(a.adjacent(b));
Void::Testing::expect(!a.adjacent(make_interval(6, 10)));
}
Void::Testing::Test interval_hull()
{
const auto a = make_interval(0, 5);
const auto b = make_interval(3, 10);
const auto h = a.hull(b);
Void::Testing::expect_eq(h.lo, 0);
Void::Testing::expect_eq(h.hi, 10);
}
Void::Testing::Test interval_intersection_overlap()
{
const auto a = make_interval(0, 8);
const auto b = make_interval(4, 12);
const auto i = a.intersection(b);
Void::Testing::expect_eq(i.lo, 4);
Void::Testing::expect_eq(i.hi, 8);
}
Void::Testing::Test interval_intersection_disjoint()
{
const auto a = make_interval(0, 3);
const auto b = make_interval(5, 9);
const auto i = a.intersection(b);
Void::Testing::expect(i.empty());
}
Void::Testing::Test interval_clamp_value()
{
const auto iv = make_interval(0, 10);
Void::Testing::expect_eq(iv.clamp(-5), 0);
Void::Testing::expect_eq(iv.clamp(5), 5);
Void::Testing::expect_eq(iv.clamp(15), 10);
}
// ── closed helper ─────────────────────────────────────────────────────────────
Void::Testing::Test interval_closed_helper()
{
const auto iv = closed(1, 5);
Void::Testing::expect(iv.contains(1));
Void::Testing::expect(iv.contains(5));
Void::Testing::expect(!iv.contains(6));
}
// ── equality ──────────────────────────────────────────────────────────────────
Void::Testing::Test interval_equality()
{
const auto a = make_interval(0, 5);
const auto b = make_interval(0, 5);
const auto c = make_interval(0, 6);
Void::Testing::expect(a == b);
Void::Testing::expect(!(a == c));
}