ShineEngine test program structure, module registration, build command, and test/benchmark API. Invoke when creating a new test executable, adding correctness checks, or writing benchmark comparisons using the shine::test framework.
dev/test/TestContext)run_compare)dev/test/<TestName>/
<TestName>.cpp ← single translation unit
Module/test/
<TestName>.json ← module registration
Module/test/<TestName>.json){
"name": "TestName",
"files": [
"dev/test/TestName/TestName.cpp"
],
"deps": [
"fmt"
],
"defines": [
"TEST_BUILD"
],
"link": {
"debug": { "lib": ["mimallocd.lib"] },
"release": { "lib": ["mimalloc.lib"] }
},
"type": ["exe"],
"platform": ["Windows"],
"buildMode": ["both"],
"output": "exe/TestName.exe",
"comment": "..."
}
Add extra engine deps to "deps" only when needed (e.g. "string_util", "math").
.\build.bat test <TestName> # Debug
.\build.bat test <TestName> --release # Release (use for benchmarks)
#include "../../src/string/shine_string.h" // if using SString/STextView
#include "../common/test_benchmark_framework.h"
#include "fmt/base.h"
#include "fmt/format.h"
std::formatter<shine::SString> and std::formatter<shine::STextView> are defined in
shine_string.h / shine_text_view.h — do not redefine them in test files.
TestContextstatic shine::test::TestContext g_ctx;
#define CHECK(name, cond) SHINE_TEST_CHECK(g_ctx, name, cond)
void test_something()
{
CHECK("default empty", s.empty());
CHECK("size after assign", s.size() == 5);
}
Print summary and return exit code:
g_ctx.print_summary("My Test Results");
if (!g_ctx.all_passed()) { return 1; }
return 0;
run_compare#include <vector>
using shine::test::ComparisonResult;
using shine::test::run_compare;
using shine::test::print_comparison;
using shine::test::print_summary;
using shine::test::DoNotOptimize;