void ConsoleArgumentsTests::ArgSplittingTests()

in src/host/ut_host/ConsoleArgumentsTests.cpp [63:264]


void ConsoleArgumentsTests::ArgSplittingTests()
{
    std::wstring commandline;

    commandline = L"conhost.exe --headless this is the commandline";
    ArgTestsRunner(L"#1 look for a valid commandline",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"this is the commandline", // clientCommandLine,
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    true, // headless
                                    true, // createServerHandle
                                    0, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?

    commandline = L"conhost.exe \"this is the commandline\"";
    ArgTestsRunner(L"#2 a commandline with quotes",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"\"this is the commandline\"", // clientCommandLine
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    false, // headless
                                    true, // createServerHandle
                                    0, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?

    commandline = L"conhost.exe --headless \"--vtmode bar this is the commandline\"";
    ArgTestsRunner(L"#3 quotes on an arg",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"\"--vtmode bar this is the commandline\"", // clientCommandLine
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    true, // headless
                                    true, // createServerHandle
                                    0, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?

    commandline = L"conhost.exe --headless   --server    0x4       this      is the    commandline";
    ArgTestsRunner(L"#4 Many spaces",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"this is the commandline", // clientCommandLine
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    true, // headless
                                    false, // createServerHandle
                                    0x4, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?

    commandline = L"conhost.exe --headless\t--vtmode\txterm\tthis\tis\tthe\tcommandline";
    ArgTestsRunner(L"#5\ttab\tdelimit",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"this is the commandline", // clientCommandLine
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"xterm", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    true, // headless
                                    true, // createServerHandle
                                    0, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?

    commandline = L"conhost.exe --headless\\ foo\\ --outpipe\\ bar\\ this\\ is\\ the\\ commandline";
    ArgTestsRunner(L"#6 back-slashes won't escape spaces",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"--headless\\ foo\\ --outpipe\\ bar\\ this\\ is\\ the\\ commandline", // clientCommandLine
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    false, // headless
                                    true, // createServerHandle
                                    0, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?

    commandline = L"conhost.exe --headless\\\tfoo\\\t--outpipe\\\tbar\\\tthis\\\tis\\\tthe\\\tcommandline";
    ArgTestsRunner(L"#7 back-slashes won't escape tabs (but the tabs are still converted to spaces)",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"--headless\\ foo\\ --outpipe\\ bar\\ this\\ is\\ the\\ commandline", // clientCommandLine
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    false, // headless
                                    true, // createServerHandle
                                    0, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?

    commandline = L"conhost.exe --vtmode a\\\\\\\\\"b c\" d e";
    ArgTestsRunner(L"#8 Combo of backslashes and quotes from msdn",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"d e", // clientCommandLine
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"a\\\\b c", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    false, // headless
                                    true, // createServerHandle
                                    0, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?

    commandline = L"conhost.exe this is the commandline";
    ArgTestsRunner(L"#9 commandline no quotes",
                   commandline,
                   INVALID_HANDLE_VALUE,
                   INVALID_HANDLE_VALUE,
                   ConsoleArguments(commandline,
                                    L"this is the commandline", // clientCommandLine
                                    INVALID_HANDLE_VALUE,
                                    INVALID_HANDLE_VALUE,
                                    L"", // vtMode
                                    0, // width
                                    0, // height
                                    false, // forceV1
                                    false, // forceNoHandoff
                                    false, // headless
                                    true, // createServerHandle
                                    0, // serverHandle
                                    0, // signalHandle
                                    false, // inheritCursor
                                    false), // runAsComServer
                   true); // successful parse?
}