这些测试用 throw 报告断言失败,但 13 个测试的 main 没有顶层 try,异常一路逃出去就会 走 std::terminate -> abort。abort 不做栈展开,ScopedDataDirectoryCleanup 的析构不执行, 测试建的临时目录和用户词库句柄留在原地;失败原因也不会打到 stderr,ctest 只能看到一段 崩溃,排查时得先猜是哪个断言。 按仓里已有的写法把函数体挪进 run_test(),main 变成一层薄包装,catch 里打 what() 再返回 1。 fuzzy_pinyin 的 create_directories 原本落在 try 之前,一并挪进去。 只是给失败换一条能读到的出口,没有改任何断言或阈值。
38 lines
878 B
C++
38 lines
878 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;
|
|
}
|
|
}
|