From b61f718084e03b9530967dea3821eeda82dbf3a6 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Wed, 19 Jun 2024 09:17:04 +0800 Subject: [PATCH] fix: add if macro for Windows only testbench code. - add if macro for Windows only testbench code to make sure testbench can be run on other platforms. --- testbench/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/testbench/main.cpp b/testbench/main.cpp index ac7cbc8..a2f7cf9 100644 --- a/testbench/main.cpp +++ b/testbench/main.cpp @@ -164,6 +164,7 @@ namespace YYCCTestbench { } // check wstring convertion on windows +#if YYCC_OS == YYCC_OS_WINDOWS for (size_t i = 0u; i < count; ++i) { // get item const auto& u8str = c_UTF8TestStrTable[i]; @@ -177,6 +178,7 @@ namespace YYCCTestbench { Assert(YYCC::EncodingHelper::UTF8ToWchar(u8str.c_str(), wcache) && wcache == wstr, "YYCC::EncodingHelper::UTF8ToWchar"); Assert(YYCC::EncodingHelper::WcharToUTF8(wstr.c_str(), u8cache) && u8cache == u8str, "YYCC::EncodingHelper::WcharToUTF8"); } +#endif } @@ -300,6 +302,8 @@ namespace YYCCTestbench { } static void DialogTestbench() { +#if YYCC_OS == YYCC_OS_WINDOWS + std::string ret; std::vector rets; @@ -327,9 +331,13 @@ namespace YYCCTestbench { if (YYCC::DialogHelper::OpenFolderDialog(params, ret)) { Console::FormatLine("Open Folder: %s", ret.c_str()); } + +#endif } static void ExceptionTestbench() { +#if YYCC_OS == YYCC_OS_WINDOWS + YYCC::ExceptionHelper::Register(); // Perform a div zero exception. @@ -337,9 +345,13 @@ namespace YYCCTestbench { int k = i / j; YYCC::ExceptionHelper::Unregister(); + +#endif } static void WinFctTestbench() { +#if YYCC_OS == YYCC_OS_WINDOWS + Console::FormatLine("Current Module HANDLE: 0x%" PRI_XPTR_LEFT_PADDING PRIXPTR, YYCC::WinFctHelper::GetCurrentModule()); std::string test_temp; @@ -353,6 +365,8 @@ namespace YYCCTestbench { std::string test_localappdata_path; Assert(YYCC::WinFctHelper::GetLocalAppData(test_localappdata_path), "YYCC::WinFctHelper::GetLocalAppData"); Console::FormatLine("Local AppData: %s", test_localappdata_path.c_str()); + +#endif } static void FsPathPatch() {