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:
@ -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
|
||||
)
|
||||
|
16
testbench/yycc/windows/com.cpp
Normal file
16
testbench/yycc/windows/com.cpp
Normal 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
|
||||
}
|
16
testbench/yycc/windows/dialog.cpp
Normal file
16
testbench/yycc/windows/dialog.cpp
Normal 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
|
||||
}
|
48
testbench/yycc/windows/winfct.cpp
Normal file
48
testbench/yycc/windows/winfct.cpp
Normal 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
|
Reference in New Issue
Block a user