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>
93 lines
2.1 KiB
C++
93 lines
2.1 KiB
C++
#pragma once
|
|
#include <chrono>
|
|
#include <filesystem>
|
|
#include <functional>
|
|
#include <memory>
|
|
#include <optional>
|
|
#include <source_location>
|
|
#include <string>
|
|
#include <string_view>
|
|
#include <vector>
|
|
|
|
namespace Void::Testing
|
|
{
|
|
|
|
enum class AssertKind : uint8_t { Expect, Require, Assert };
|
|
enum class TestState : uint8_t { Passed, Failed, Skipped, Crashed };
|
|
|
|
struct AssertionResult {
|
|
bool passed{true};
|
|
AssertKind kind{AssertKind::Expect};
|
|
std::string expression;
|
|
std::string expected_repr;
|
|
std::string actual_repr;
|
|
std::string message;
|
|
std::source_location location;
|
|
static AssertionResult
|
|
ok(std::source_location loc = std::source_location::current())
|
|
{
|
|
return {.passed = true, .location = loc};
|
|
}
|
|
};
|
|
|
|
struct TestCase {
|
|
std::function<void()> run;
|
|
std::string name;
|
|
std::string suite;
|
|
std::string file;
|
|
int line{0};
|
|
bool disabled{false};
|
|
std::string skip_reason;
|
|
std::vector<std::string> tags;
|
|
std::function<void*()> fixture_create;
|
|
std::function<void(void*)> fixture_destroy;
|
|
std::function<void(void*)> fixture_setup;
|
|
std::function<void(void*)> fixture_teardown;
|
|
};
|
|
|
|
struct TestResult {
|
|
std::string name;
|
|
std::string suite;
|
|
TestState state{TestState::Passed};
|
|
std::chrono::nanoseconds duration{0};
|
|
std::vector<AssertionResult> assertions;
|
|
std::string skip_reason;
|
|
std::string crash_info;
|
|
std::string stacktrace;
|
|
std::vector<std::string> tags;
|
|
};
|
|
|
|
struct SuiteResult {
|
|
std::string name;
|
|
std::vector<TestResult> tests;
|
|
};
|
|
|
|
struct RunResult {
|
|
std::vector<SuiteResult> suites;
|
|
std::chrono::nanoseconds total_duration{0};
|
|
int passed{0};
|
|
int failed{0};
|
|
int skipped{0};
|
|
int crashed{0};
|
|
int total{0};
|
|
};
|
|
|
|
struct RunConfig {
|
|
std::string filter_pattern;
|
|
std::string suite_filter;
|
|
std::string reporter{"console"};
|
|
std::string output_file;
|
|
std::string tag_filter;
|
|
std::string log_file;
|
|
bool list_only{false};
|
|
bool verbose{false};
|
|
bool no_color{false};
|
|
bool shuffle{false};
|
|
bool show_help{false};
|
|
unsigned repeat{1};
|
|
unsigned random_seed{0};
|
|
unsigned parallel_threads{0}; // 0 = sequential
|
|
};
|
|
|
|
} // namespace Void::Testing
|