refactor: migrate windows specific content.

- move com, dialog and winfct function into new place.
- add testbench for com and winfct.
- dialog now still not working.
This commit is contained in:
2025-08-13 15:29:47 +08:00
parent ff8c7d04cc
commit bdeaea294f
14 changed files with 1138 additions and 124 deletions

View File

@ -22,6 +22,9 @@ PRIVATE
yycc/encoding/stl.cpp
yycc/encoding/windows.cpp
yycc/encoding/iconv.cpp
yycc/windows/com.cpp
#yycc/windows/dialog.cpp
yycc/windows/winfct.cpp
yycc/carton/pycodec.cpp
)

View File

@ -0,0 +1,16 @@
#include <gtest/gtest.h>
#include <yycc.hpp>
#include <yycc/windows/com.hpp>
#define COM ::yycc::windows::com
namespace yycctest::windows::com {
#if defined(YYCC_OS_WINDOWS) && defined(YYCC_STL_MSSTL)
TEST(WindowsCom, IsInitialized) {
// COM environment should always be ready.
EXPECT_TRUE(COM::is_initialized());
}
#endif
}

View File

@ -0,0 +1,16 @@
#include <gtest/gtest.h>
#include <yycc.hpp>
#include <yycc/windows/dialog.hpp>
#define DIALOG ::yycc::windows::dialog
namespace yycctest::windows::dialog {
#if defined(YYCC_OS_WINDOWS) && defined(YYCC_STL_MSSTL)
// TEST(WindowsDialog, Normal) {
// }
#endif
}

View File

@ -0,0 +1,48 @@
#include <gtest/gtest.h>
#include <yycc.hpp>
#include <yycc/windows/winfct.hpp>
#define WINFCT ::yycc::windows::winfct
namespace yycctest::windows::winfct {
#if defined(YYCC_OS_WINDOWS)
TEST(WindowsWinFct, GetCurrentModule) {
auto rv = WINFCT::get_current_module();
EXPECT_TRUE(rv.has_value());
}
TEST(WindowsWinFct, GetTempDirectory) {
auto rv = WINFCT::get_temp_directory();
EXPECT_TRUE(rv.has_value());
}
TEST(WindowsWinFct, GetModuleFileName) {
auto handle = WINFCT::get_current_module();
ASSERT_TRUE(handle.has_value());
auto rv = WINFCT::get_module_file_name(handle.value());
EXPECT_TRUE(rv.has_value());
}
TEST(WindowsWinFct, IsValidCodePage) {
EXPECT_TRUE(WINFCT::is_valid_code_page(437));
EXPECT_TRUE(WINFCT::is_valid_code_page(65001));
EXPECT_FALSE(WINFCT::is_valid_code_page(6161));
}
#if defined(YYCC_STL_MSSTL)
TEST(WindowsWinFct, GetKnownPath) {
auto rv = WINFCT::get_known_path(WINFCT::KnownDirectory::LocalAppData);
EXPECT_TRUE(rv.has_value());
}
#endif
// YYC MARK:
// I can't test CopyFile, MoveFile and DeleteFile.
#endif
} // namespace yycctest::windows::winfct