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>
45 lines
994 B
C++
45 lines
994 B
C++
#include <Void/Functional/Error.hpp>
|
|
#include <Void/Functional/Result.hpp>
|
|
#include <Void/Testing/Assert.hpp>
|
|
#include <Void/Testing/Test.hpp>
|
|
|
|
#include <string>
|
|
|
|
namespace
|
|
{
|
|
Void::Result::Result<int> divide(int n, int d)
|
|
{
|
|
if (d == 0) {
|
|
return Void::Result::fail("division by zero");
|
|
}
|
|
return Void::Result::ok(n / d);
|
|
}
|
|
} // namespace
|
|
|
|
Void::Testing::Test ok_constructs_success()
|
|
{
|
|
auto r = divide(10, 2);
|
|
Void::Testing::expect(r.has_value());
|
|
Void::Testing::expect_eq(*r, 5);
|
|
}
|
|
|
|
Void::Testing::Test fail_constructs_failure()
|
|
{
|
|
auto r = divide(10, 0);
|
|
Void::Testing::expect(!r.has_value());
|
|
Void::Testing::expect_eq(r.error().message(),
|
|
std::string{"division by zero"});
|
|
}
|
|
|
|
Void::Testing::Test value_or_returns_fallback_on_error()
|
|
{
|
|
auto r = divide(10, 0);
|
|
Void::Testing::expect_eq(r.value_or(-1), -1);
|
|
}
|
|
|
|
Void::Testing::Test bool_conversion()
|
|
{
|
|
Void::Testing::expect(static_cast<bool>(divide(10, 2)));
|
|
Void::Testing::expect(!static_cast<bool>(divide(10, 0)));
|
|
}
|