New header-only modules: - Void::Hash — FNV-1a 32/64, CRC-32, DJB2, MurmurHash3-32, UDL literals - Void::Random — Xoshiro256** PRNG, uniform_int/real, coin_flip, shuffle, random_string - Void::Uuid — v4 (random), v5_lite (name-based), parse, RFC 4122 namespaces - Void::Encoding — Base64 (standard + URL-safe), Hex encode/decode - Void::Bits — popcount, bit extract/deposit, rotation, align, byteswap, masks - Void::Math — Vec2/Vec3/Vec4, Mat4 (identity, translation, scale, rotation) Testing module: move Stacktrace from INTERNAL_DEPS to OPTIONAL_DEPS. Added Detail/Color.hpp shim that delegates to Stacktrace::Color when present or provides inline ANSI fallback otherwise. All Stacktrace calls in SignalHandler, ConsoleReporter, and Runner are gated on VOID_HAS_STACKTRACE. Fix Repr.hpp reflect_struct to handle template specializations that lack std::meta::identifier_of (now guarded by has_identifier check). 33/33 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
63 lines
1.7 KiB
C++
63 lines
1.7 KiB
C++
#include <Void/Logging/ConsoleLogger.hpp>
|
|
#include <Void/Logging/Level.hpp>
|
|
#include <Void/Testing/Assert.hpp>
|
|
#include <Void/Testing/Fixture.hpp>
|
|
#include <Void/Testing/Test.hpp>
|
|
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
class ConsoleLoggerTests : public Void::Testing::Fixture
|
|
{
|
|
public:
|
|
|
|
Void::Testing::Test writes_to_stream()
|
|
{
|
|
std::ostringstream out;
|
|
{
|
|
Void::Logging::ConsoleLogger log(out);
|
|
log.info("hello world");
|
|
}
|
|
const auto content = out.str();
|
|
Void::Testing::expect(content.find("hello world") !=
|
|
std::string::npos);
|
|
Void::Testing::expect(content.find("Info") != std::string::npos);
|
|
}
|
|
|
|
Void::Testing::Test level_filtering()
|
|
{
|
|
std::ostringstream out;
|
|
{
|
|
Void::Logging::ConsoleLogger log(out);
|
|
log.set_level(Void::Logging::Level::Error);
|
|
log.info("filtered out");
|
|
log.error("kept");
|
|
}
|
|
const auto content = out.str();
|
|
Void::Testing::expect(content.find("filtered out") ==
|
|
std::string::npos);
|
|
Void::Testing::expect(content.find("kept") != std::string::npos);
|
|
}
|
|
|
|
Void::Testing::Test multiple_levels_emit_in_order()
|
|
{
|
|
std::ostringstream out;
|
|
{
|
|
Void::Logging::ConsoleLogger log(out);
|
|
log.set_level(Void::Logging::Level::Trace);
|
|
log.trace("first");
|
|
log.warning("second");
|
|
log.fatal("third");
|
|
}
|
|
const auto content = out.str();
|
|
const auto first = content.find("first");
|
|
const auto second = content.find("second");
|
|
const auto third = content.find("third");
|
|
Void::Testing::expect(first != std::string::npos);
|
|
Void::Testing::expect(second != std::string::npos);
|
|
Void::Testing::expect(third != std::string::npos);
|
|
Void::Testing::expect(first < second);
|
|
Void::Testing::expect(second < third);
|
|
}
|
|
};
|