int TestCmdLine(int argc, char* argv[])
{
int status;
+ int ret = -1;
DWORD flags;
long width = 0;
long height = 0;
flags = COMMAND_LINE_SIGIL_SLASH | COMMAND_LINE_SEPARATOR_COLON | COMMAND_LINE_SIGIL_PLUS_MINUS;
testArgc = string_list_length(testArgv);
command_line = string_list_copy(testArgv);
+
+ if (!command_line)
+ {
+ printf("Argument duplication failed (not enough memory?)\n");
+ return ret;
+ }
+
status = CommandLineParseArgumentsA(testArgc, command_line, args, flags, NULL, NULL, NULL);
if (status != 0)
{
printf("CommandLineParseArgumentsA failure: %d\n", status);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "w");
if (strcmp("1024", arg->Value) != 0)
{
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "h");
if (strcmp("768", arg->Value) != 0)
{
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "f");
if (arg->Value)
{
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "admin");
if (!arg->Value)
{
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "multimon");
if (!arg->Value)
{
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "v");
if (strcmp("localhost:3389", arg->Value) != 0)
{
printf("CommandLineFindArgumentA: unexpected %s value %s\n", arg->Name, arg->Value);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "fonts");
if (!arg->Value)
{
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "wallpaper");
if (arg->Value)
{
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
- return -1;
+ goto out;
}
arg = CommandLineFindArgumentA(args, "help");
if (arg->Value)
{
printf("CommandLineFindArgumentA: unexpected %s value\n", arg->Name);
- return -1;
+ goto out;
}
arg = args;
width = strtol(arg->Value, NULL, 0);
if (errno != 0)
- return -1;
+ goto out;
}
CommandLineSwitchCase(arg, "h")
{
height = strtol(arg->Value, NULL, 0);
if (errno != 0)
- return -1;
+ goto out;
}
CommandLineSwitchDefault(arg)
{
if ((width != 1024) || (height != 768))
{
printf("Unexpected width and height: Actual: (%ldx%ld), Expected: (1024x768)\n", width, height);
- return -1;
+ goto out;
}
+ ret = 0;
- return 0;
+out:
+ string_list_free(command_line);
+ return ret;
}