Files
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

96 lines
2.4 KiB
C++

#include <Void/Log/FileLogger.hpp>
#include <Void/Log/Level.hpp>
#include <Void/Testing/Assert.hpp>
#include <Void/Testing/Fixture.hpp>
#include <Void/Testing/Test.hpp>
#include <filesystem>
#include <format>
#include <fstream>
#include <string>
class FileLoggerTests : public Void::Testing::Fixture
{
public:
std::filesystem::path path;
void setup() override
{
path = std::filesystem::temp_directory_path() /
"void_filelogger_test.log";
std::filesystem::remove(path);
}
void teardown() override { std::filesystem::remove(path); }
Void::Testing::Test creates_file()
{
{
Void::Logging::FileLogger log(path);
log.info("hello");
}
Void::Testing::expect(std::filesystem::exists(path));
}
Void::Testing::Test writes_messages()
{
{
Void::Logging::FileLogger log(
path, Void::Logging::Mode::Buffered, 1);
log.info("test message");
}
std::ifstream f(path);
std::string content((std::istreambuf_iterator<char>(f)), {});
Void::Testing::expect(content.find("test message") !=
std::string::npos);
}
Void::Testing::Test level_filtering()
{
{
Void::Logging::FileLogger log(
path, Void::Logging::Mode::Buffered, 1);
log.set_level(Void::Logging::Level::Warning);
log.debug("should be dropped");
log.warning("should appear");
}
std::ifstream f(path);
std::string content((std::istreambuf_iterator<char>(f)), {});
Void::Testing::expect(content.find("should be dropped") ==
std::string::npos);
Void::Testing::expect(content.find("should appear") !=
std::string::npos);
}
Void::Testing::Test buffered_flush()
{
{
Void::Logging::FileLogger log(
path, Void::Logging::Mode::Buffered, 100);
for (int i = 0; i < 5; ++i) {
log.info(std::format("entry {}", i));
}
}
std::ifstream f(path);
std::string content((std::istreambuf_iterator<char>(f)), {});
Void::Testing::expect(content.find("entry 4") != std::string::npos);
}
Void::Testing::Test open_factory_returns_ok_on_valid_path()
{
auto r = Void::Logging::FileLogger::open(path);
Void::Testing::expect(r.has_value());
(*r)->info("via factory");
}
Void::Testing::Test open_factory_returns_error_on_bad_path()
{
auto r = Void::Logging::FileLogger::open(
"/this/path/does/not/exist/file.log");
Void::Testing::expect(!r.has_value());
Void::Testing::expect(r.error().message().find("FileLogger") !=
std::string::npos);
}
};