只接 std::exception 的话,第三方库或跨 FFI 边界抛出来的东西照样会逃出 main 走 abort, 和上一个 commit 修掉的是同一类故障:ctest 看不到原因,栈也不展开。引擎内现有的抛出确实 都是 std::exception 派生,但这一层缺的是「无论什么异常都到不了 terminate」的保证,补上它 才让 main 的边界真正闭合。 只加 catch 分支,输出通道沿用各文件原来那一个(fprintf / cerr / fmt::println), 不改任何断言。
43 lines
995 B
C++
43 lines
995 B
C++
#include "../../core/query_request.h"
|
|
|
|
#include <cstdint>
|
|
#include <type_traits>
|
|
#include <cstdio>
|
|
|
|
#ifdef _WIN32
|
|
static_assert(std::is_same_v<decltype(KeyStroke::vk), UINT>);
|
|
static_assert(std::is_same_v<decltype(KeyStroke::modifiers_down), UINT>);
|
|
static_assert(std::is_same_v<decltype(KeyStroke::wch), WCHAR>);
|
|
static_assert(sizeof(WCHAR) == 2);
|
|
#else
|
|
static_assert(std::is_same_v<decltype(KeyStroke::vk), std::uint32_t>);
|
|
static_assert(std::is_same_v<decltype(KeyStroke::modifiers_down), std::uint32_t>);
|
|
static_assert(std::is_same_v<decltype(KeyStroke::wch), char16_t>);
|
|
#endif
|
|
|
|
void test_public_session_interface();
|
|
|
|
int run_test()
|
|
{
|
|
test_public_session_interface();
|
|
return 0;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
try
|
|
{
|
|
return run_test();
|
|
}
|
|
catch (const std::exception &error)
|
|
{
|
|
std::fprintf(stderr, "%s\n", error.what());
|
|
return 1;
|
|
}
|
|
catch (...)
|
|
{
|
|
std::fprintf(stderr, "An exception escaped the test body.\n");
|
|
return 1;
|
|
}
|
|
}
|