Add Hash, Random, Uuid, Encoding, Bits, Math modules + make Testing deps optional
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>
This commit is contained in:
1 parent
42268c6c35
commit
a09e000f0f
65 files changed
+4959
-138
No files matched your search
@@ -86,6 +86,7 @@ namespace Void::Testing
|
||||
bool show_help{false};
|
||||
unsigned repeat{1};
|
||||
unsigned random_seed{0};
|
||||
unsigned parallel_threads{0}; // 0 = sequential
|
||||
};
|
||||
|
||||
} // namespace Void::Testing
|
||||
@@ -1,13 +1,13 @@
|
||||
#pragma once
|
||||
#include <Void/Testing/Reporter.hpp>
|
||||
#include <Void/Stacktrace/Color.hpp>
|
||||
#include <Void/Testing/Detail/Color.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace Void::Testing {
|
||||
class ConsoleReporter final : public Reporter {
|
||||
public:
|
||||
explicit ConsoleReporter(std::ostream& os, bool color_enabled = true) : os_(os) {
|
||||
Void::Stacktrace::Color::g_color_enabled = color_enabled;
|
||||
Void::Testing::Detail::Color::g_color_enabled = color_enabled;
|
||||
}
|
||||
void on_run_start(const RunConfig& config, int total_tests) override;
|
||||
void on_suite_start(const std::string& suite_name, int test_count) override;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef VOID_HAS_STACKTRACE
|
||||
#include <Void/Stacktrace/Color.hpp>
|
||||
namespace Void::Testing::Detail {
|
||||
namespace Color = Void::Stacktrace::Color;
|
||||
}
|
||||
#else
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
namespace Void::Testing::Detail::Color {
|
||||
inline bool g_color_enabled{true};
|
||||
constexpr std::string_view reset = "\033[0m";
|
||||
constexpr std::string_view bold = "\033[1m";
|
||||
constexpr std::string_view dim = "\033[2m";
|
||||
constexpr std::string_view bold_red = "\033[1;31m";
|
||||
constexpr std::string_view bold_green = "\033[1;32m";
|
||||
constexpr std::string_view bold_yellow = "\033[1;33m";
|
||||
constexpr std::string_view bold_blue = "\033[1;34m";
|
||||
constexpr std::string_view bold_magenta = "\033[1;35m";
|
||||
constexpr std::string_view bold_cyan = "\033[1;36m";
|
||||
constexpr std::string_view bold_white = "\033[1;37m";
|
||||
constexpr std::string_view red = "\033[31m";
|
||||
constexpr std::string_view green = "\033[32m";
|
||||
constexpr std::string_view yellow = "\033[33m";
|
||||
constexpr std::string_view cyan = "\033[36m";
|
||||
inline std::string apply(std::string_view code, std::string_view text)
|
||||
{
|
||||
if (!g_color_enabled) return std::string{text};
|
||||
return std::string{code} + std::string{text} + std::string{reset};
|
||||
}
|
||||
} // namespace Void::Testing::Detail::Color
|
||||
#endif
|
||||
@@ -3,21 +3,30 @@
|
||||
#include <Void/Testing/Reporter.hpp>
|
||||
#include <memory>
|
||||
|
||||
namespace Void::Testing {
|
||||
class Runner {
|
||||
public:
|
||||
static Runner& instance() {
|
||||
static Runner r;
|
||||
return r;
|
||||
}
|
||||
RunConfig parse_args(int argc, char** argv);
|
||||
RunResult run(const RunConfig& config);
|
||||
int main(int argc, char** argv);
|
||||
private:
|
||||
Runner() = default;
|
||||
std::vector<TestCase> filter_tests(const std::vector<TestCase>& tests, const RunConfig& config);
|
||||
std::unique_ptr<Reporter> create_reporter(const RunConfig& config);
|
||||
TestResult execute_test(TestCase& test_case);
|
||||
void run_test_body(TestCase& test_case, TestResult& result);
|
||||
};
|
||||
namespace Void::Testing
|
||||
{
|
||||
class Runner
|
||||
{
|
||||
public:
|
||||
|
||||
static Runner& instance()
|
||||
{
|
||||
static Runner r;
|
||||
return r;
|
||||
}
|
||||
RunConfig parse_args(int argc, char** argv);
|
||||
RunResult run(const RunConfig& config);
|
||||
int main(int argc, char** argv);
|
||||
|
||||
private:
|
||||
|
||||
Runner() = default;
|
||||
std::vector<TestCase>
|
||||
filter_tests(const std::vector<TestCase>& tests,
|
||||
const RunConfig& config);
|
||||
std::unique_ptr<Reporter> create_reporter(const RunConfig& config);
|
||||
TestResult execute_test(TestCase& test_case);
|
||||
TestResult execute_test_parallel(TestCase& test_case);
|
||||
void run_test_body(TestCase& test_case, TestResult& result);
|
||||
};
|
||||
} // namespace Void::Testing
|
||||
Reference in new issue
Block a user