Index: apitests/crt/__getmainargs.c =================================================================== --- apitests/crt/__getmainargs.c (nonexistent) +++ apitests/crt/__getmainargs.c (working copy) @@ -0,0 +1,57 @@ +/* + * PROJECT: ReactOS api tests + * LICENSE: GPLv2+ - See COPYING in the top level directory + * PURPOSE: Test for __getmainargs + * PROGRAMMER: Yaroslav Veremenko + */ + +#include +#include +#include + +const char **__p__acmdln(void); +void __getmainargs(int* argc, char*** argv, char*** env, int expand_wildcards, int* new_mode); + +#define winetest_ok_str(x, y) \ + winetest_ok(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x) +#define ok_args (winetest_set_location(__FILE__, __LINE__), 0) ? (void)0 : ok_args_imp + + +void +ok_args_imp(const char* input_args, /*char** argv,*/ const char* arg1, const char* arg2, const char* arg3) +{ + int argc = 0, mode = 0; + char** argv, **env; + + /* Remove cached argv, setup our input as program argument. */ + *__p___argv() = NULL; + *__p__acmdln() = input_args; + + /* Process the commandline stored in _acmdln */ + __getmainargs(&argc, &argv, &env, 0, &mode); + + winetest_ok(argc == 4, "Wrong value for argc, expected: 4, got: %d\n", argc); + if(argc != 4) + return; + + winetest_ok_str(argv[0], "test.exe"); + winetest_ok_str(argv[1], arg1); + winetest_ok_str(argv[2], arg2); + winetest_ok_str(argv[3], arg3); +} + +START_TEST(__getmainargs) +{ + ok_args("test.exe \"a b c\" d e", "a b c", "d", "e"); + ok_args("test.exe \"ab\\\"c\" \"\\\\\" d", "ab\"c", "\\", "d"); + ok_args("test.exe a\\\\\\b d\"e f\"g h", "a\\\\\\b", "de fg", "h"); + ok_args("test.exe a\\\\\\\"b c d", "a\\\"b", "c", "d"); + ok_args("test.exe a\\\\\\\\\"b c\" d e", "a\\\\b c", "d", "e"); + ok_args("test.exe a b \"\"", "a", "b", ""); + ok_args("test.exe a \"\" b", "a", "", "b"); + ok_args("test.exe a \"b\"\" c", "a", "b\"", "c"); + ok_args("test.exe a \"b\\\"\" c", "a", "b\"", "c"); + ok_args("test.exe a \" b\\ \"\" c", "a", " b\\ \"", "c"); + ok_args("test.exe a \"b\\ \"\"\" c\" d", "a", "b\\ \" c", "d"); + ok_args("test.exe a \"b\\ \"\"\" \"c \"\"\"\" d", "a", "b\\ \" c", "\" d"); +} Property changes on: apitests/crt/__getmainargs.c ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: apitests/crt/msvcrt_crt_apitest.cmake =================================================================== --- apitests/crt/msvcrt_crt_apitest.cmake (revision 72035) +++ apitests/crt/msvcrt_crt_apitest.cmake (working copy) @@ -66,7 +66,7 @@ # __doserrno.c # __fpecode.c # __get_app_type.c -# __getmainargs.c + __getmainargs.c # __initenv # __iob_func.c # __isascii.c Index: apitests/crt/testlist.c =================================================================== --- apitests/crt/testlist.c (revision 72035) +++ apitests/crt/testlist.c (working copy) @@ -25,6 +25,7 @@ extern void func_wcsnlen(void); extern void func_wcstombs(void); extern void func_wcstoul(void); +extern void func___getmainargs(void); extern void func_static_construct(void); extern void func_static_init(void); @@ -50,6 +51,7 @@ #endif #if defined(TEST_STATIC_CRT) #elif defined(TEST_MSVCRT) + { "__getmainargs", func___getmainargs }, { "_vscprintf", func__vscprintf }, { "_vscwprintf", func__vscwprintf },