1 parent
4fc129fb7e
commit
e7186f17f0
42 files changed
+1816
-413
No files matched your search
@@ -0,0 +1,90 @@
|
||||
#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;
|
||||
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};
|
||||
};
|
||||
|
||||
} // namespace Void::Testing
|
||||
Reference in new issue
Block a user