mirror of https://github.com/Icinga/icinga2.git
Merge pull request #8712 from Icinga/feature/avoid-windows-atl-dependency
Avoid dependency on Visual C++ ATL in tests on Windows
This commit is contained in:
commit
8dc069dc24
|
@ -7,7 +7,6 @@
|
|||
#ifdef _WIN32
|
||||
# include <windows.h>
|
||||
# include <shellapi.h>
|
||||
# include <atlstr.h>
|
||||
#endif /* _WIN32 */
|
||||
|
||||
using namespace icinga;
|
||||
|
@ -84,6 +83,8 @@ BOOST_AUTO_TEST_CASE(validateutf8)
|
|||
BOOST_AUTO_TEST_CASE(EscapeCreateProcessArg)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
using convert = std::wstring_convert<std::codecvt<wchar_t, char, std::mbstate_t>, wchar_t>;
|
||||
|
||||
std::vector<std::string> testdata = {
|
||||
R"(foobar)",
|
||||
R"(foo bar)",
|
||||
|
@ -98,11 +99,11 @@ BOOST_AUTO_TEST_CASE(EscapeCreateProcessArg)
|
|||
// Prepend some fake exec name as the first argument is handled differently.
|
||||
std::string escaped = "some.exe " + Utility::EscapeCreateProcessArg(t);
|
||||
int argc;
|
||||
std::shared_ptr<LPWSTR> argv(CommandLineToArgvW(CA2W(escaped.c_str()), &argc), LocalFree);
|
||||
std::shared_ptr<LPWSTR> argv(CommandLineToArgvW(convert{}.from_bytes(escaped.c_str()).data(), &argc), LocalFree);
|
||||
BOOST_CHECK_MESSAGE(argv != nullptr, "CommandLineToArgvW() should not return nullptr for " << t);
|
||||
BOOST_CHECK_MESSAGE(argc == 2, "CommandLineToArgvW() should find 2 arguments for " << t);
|
||||
if (argc >= 2) {
|
||||
std::string unescaped = CW2A(argv.get()[1]);
|
||||
std::string unescaped = convert{}.to_bytes(argv.get()[1]);
|
||||
BOOST_CHECK_MESSAGE(unescaped == t,
|
||||
"CommandLineToArgvW() should return original value for " << t << " (got: " << unescaped << ")");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue