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>
71 lines
2.0 KiB
C++
71 lines
2.0 KiB
C++
#include <Void/System/TempDir.hpp>
|
|
#include <Void/Testing/Assert.hpp>
|
|
#include <Void/Testing/Test.hpp>
|
|
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <utility>
|
|
|
|
Void::Testing::Test temp_dir_creates_directory_under_temp()
|
|
{
|
|
std::filesystem::path captured;
|
|
{
|
|
Void::FileSystem::TempDir tmp;
|
|
captured = tmp.path();
|
|
Void::Testing::expect(std::filesystem::is_directory(captured));
|
|
Void::Testing::expect(captured.parent_path() ==
|
|
std::filesystem::temp_directory_path());
|
|
}
|
|
// Removed on destruction.
|
|
Void::Testing::expect(!std::filesystem::exists(captured));
|
|
}
|
|
|
|
Void::Testing::Test temp_dir_removes_recursive_contents()
|
|
{
|
|
std::filesystem::path captured;
|
|
{
|
|
Void::FileSystem::TempDir tmp;
|
|
captured = tmp.path();
|
|
std::filesystem::create_directories(tmp / "nested/deep");
|
|
std::ofstream{tmp / "nested/deep/leaf.txt"} << "data";
|
|
Void::Testing::expect(
|
|
std::filesystem::exists(tmp / "nested/deep/leaf.txt"));
|
|
}
|
|
Void::Testing::expect(!std::filesystem::exists(captured));
|
|
}
|
|
|
|
Void::Testing::Test temp_dir_move_transfers_ownership()
|
|
{
|
|
std::filesystem::path captured;
|
|
{
|
|
Void::FileSystem::TempDir a;
|
|
captured = a.path();
|
|
Void::FileSystem::TempDir b{std::move(a)};
|
|
// `a` is moved-from; `b` owns the directory.
|
|
Void::Testing::expect_eq(b.path(), captured);
|
|
Void::Testing::expect(std::filesystem::is_directory(b.path()));
|
|
}
|
|
Void::Testing::expect(!std::filesystem::exists(captured));
|
|
}
|
|
|
|
Void::Testing::Test temp_dir_open_factory_returns_result()
|
|
{
|
|
std::filesystem::path captured;
|
|
{
|
|
auto r = Void::FileSystem::TempDir::open("void_factory_test_");
|
|
Void::Testing::expect(r.has_value());
|
|
captured = r->path();
|
|
Void::Testing::expect(std::filesystem::is_directory(captured));
|
|
}
|
|
// `r` is destroyed at end of scope, which destroys the contained
|
|
// TempDir and removes the directory.
|
|
Void::Testing::expect(!std::filesystem::exists(captured));
|
|
}
|
|
|
|
Void::Testing::Test temp_dir_two_concurrent_dirs_have_distinct_paths()
|
|
{
|
|
Void::FileSystem::TempDir a;
|
|
Void::FileSystem::TempDir b;
|
|
Void::Testing::expect(a.path() != b.path());
|
|
}
|