4 #include <winpr/thread.h>
6 static const char* test_args_line_1 =
"app.exe abc d e";
8 static const char* test_args_list_1[] = {
"app.exe",
"abc",
"d",
"e", NULL };
10 static const char* test_args_line_2 =
"app.exe abc \t def";
12 static const char* test_args_list_2[] = {
"app.exe",
"abc",
"def", NULL };
14 static const char* test_args_line_3 =
"app.exe \"abc\" d e";
16 static const char* test_args_list_3[] = {
"app.exe",
"abc",
"d",
"e", NULL };
18 static const char* test_args_line_4 =
"app.exe a\\\\b d\"e f\"g h";
20 static const char* test_args_list_4[] = {
"app.exe",
"a\\\\b",
"de fg",
"h", NULL };
22 static const char* test_args_line_5 =
"app.exe a\\\\\\\"b c d";
24 static const char* test_args_list_5[] = {
"app.exe",
"a\\\"b",
"c",
"d", NULL };
26 static const char* test_args_line_6 =
"app.exe a\\\\\\\\\"b c\" d e";
28 static const char* test_args_list_6[] = {
"app.exe",
"a\\\\b c",
"d",
"e", NULL };
30 static const char* test_args_line_7 =
"app.exe a\\\\\\\\\"b c\" d e f\\\\\\\\\"g h\" i j";
32 static const char* test_args_list_7[] = {
"app.exe",
"a\\\\b c",
"d",
"e",
33 "f\\\\g h",
"i",
"j", NULL };
35 static int test_command_line_parsing_case(
const char* line,
const char** list)
43 printf(
"Parsing: %s\n", line);
45 pArgs = CommandLineToArgvA(line, &numArgs);
47 printf(
"pNumArgs: %d\n", numArgs);
49 for (
int i = 0; i < numArgs; i++)
51 printf(
"argv[%d] = %s\n", i, pArgs[i]);
59 int TestThreadCommandLineToArgv(
int argc,
char* argv[])
65 test_command_line_parsing_case(test_args_line_1, test_args_list_1);
66 test_command_line_parsing_case(test_args_line_2, test_args_list_2);
67 test_command_line_parsing_case(test_args_line_3, test_args_list_3);
68 test_command_line_parsing_case(test_args_line_4, test_args_list_4);
69 test_command_line_parsing_case(test_args_line_5, test_args_list_5);
70 test_command_line_parsing_case(test_args_line_6, test_args_list_6);
71 test_command_line_parsing_case(test_args_line_7, test_args_list_7);