Files
msime-windows/server/tests/includes/test_framework.h
T
fanlusky ac8394291b fix(tests): keep the shared test header free of engine dependencies
The portable test target builds on a bare Linux runner with no vcpkg tree, so
the UTF-8 path helper cannot live in test_framework.h -- including the engine's
data_path.h there broke the sanitizer build. Move it to test_utf8_path.h, which
only the Windows tests that need it include.
2026-09-09 04:48:56 +08:00

51 lines
2.8 KiB
C++

#pragma once
#include <functional>
#include <stdexcept>
#include <string>
#include <vector>
// This header is shared with the portable test target, which builds on a bare Linux runner with no
// vcpkg tree and no engine headers. Keep it dependency-free; path helpers live in test_utf8_path.h.
namespace test
{
struct TestCase
{
std::string name;
std::function<void()> fn;
};
std::vector<TestCase> &registry();
struct Registrar
{
Registrar(const char *name, std::function<void()> fn);
};
} // namespace test
#define TEST_CASE(name) \
static void name(); \
static test::Registrar name##_registrar(#name, name); \
static void name()
#define REQUIRE(expr) \
do \
{ \
if (!(expr)) \
{ \
throw std::runtime_error("Requirement failed: " #expr); \
} \
} while (false)
#define REQUIRE_EQ(lhs, rhs) \
do \
{ \
const auto &_lhs = (lhs); \
const auto &_rhs = (rhs); \
if (!(_lhs == _rhs)) \
{ \
throw std::runtime_error("Requirement failed: " #lhs " == " #rhs); \
} \
} while (false)