Author: mjansen
Date: Tue Feb  7 10:35:35 2017
New Revision: 73745

URL: http://svn.reactos.org/svn/reactos?rev=73745&view=rev
Log:
[CRT_APITEST] Add additional test for __getmainargs

Modified:
    trunk/rostests/apitests/crt/__getmainargs.c

Modified: trunk/rostests/apitests/crt/__getmainargs.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/__getmainargs.c?rev=73745&r1=73744&r2=73745&view=diff
==============================================================================
--- trunk/rostests/apitests/crt/__getmainargs.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/__getmainargs.c [iso-8859-1] Tue Feb  7 
10:35:35 2017
@@ -28,6 +28,7 @@
 ok_argsA_imp(const char* input_args, const char* arg1, const char* arg2, const 
char* arg3)
 {
     int argc = 0, mode = 0;
+    int expect_count = arg3 == NULL ? (arg2 == NULL ? 2 : 3) : 4;
     char** argv, **env;
 
     /* Remove cached argv, setup our input as program argument. */
@@ -37,20 +38,25 @@
     /* 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)
+    winetest_ok(argc == expect_count, "Wrong value for argc, expected: %d, 
got: %d\n", expect_count, argc);
+    if(argc != expect_count)
         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);
+    if (expect_count > 2)
+    {
+        winetest_ok_str(argv[2], arg2);
+        if (expect_count > 3)
+            winetest_ok_str(argv[3], arg3);
+    }
 }
 
 void
 ok_argsW_imp(const wchar_t* input_args, const wchar_t* arg1, const wchar_t* 
arg2, const wchar_t* arg3)
 {
     int argc = 0, mode = 0;
+    int expect_count = arg3 == NULL ? (arg2 == NULL ? 2 : 3) : 4;
     wchar_t** argv, **env;
 
     /* Remove cached wargv, setup our input as program argument. */
@@ -60,14 +66,18 @@
     /* Process the commandline stored in _wcmdln */
     __wgetmainargs(&argc, &argv, &env, 0, &mode);
 
-    winetest_ok(argc == 4, "Wrong value for argc, expected: 4, got: %d\n", 
argc);
-    if(argc != 4)
+    winetest_ok(argc == expect_count, "Wrong value for argc, expected: %d, 
got: %d\n", expect_count, argc);
+    if(argc != expect_count)
         return;
 
     winetest_ok_wstr(argv[0], L"test.exe");
     winetest_ok_wstr(argv[1], arg1);
-    winetest_ok_wstr(argv[2], arg2);
-    winetest_ok_wstr(argv[3], arg3);
+    if (expect_count > 2)
+    {
+        winetest_ok_wstr(argv[2], arg2);
+        if (expect_count > 3)
+            winetest_ok_wstr(argv[3], arg3);
+    }
 }
 
 START_TEST(__getmainargs)
@@ -85,6 +95,7 @@
     ok_argsA("test.exe a  \"b\\  \"\"\"  c\" d", "a", "b\\  \"  c", "d");
     ok_argsA("test.exe a  \"b\\  \"\"\"  \"c  \"\"\"\" d", "a", "b\\  \"  c", 
"\" d");
     ok_argsA("test.exe a b c  ", "a", "b", "c");
+    ok_argsA("test.exe \"a b c\"", "a b c", NULL, NULL);
 
     ok_argsW(L"test.exe \"a b c\" d e", L"a b c", L"d", L"e");
     ok_argsW(L"test.exe \"ab\\\"c\" \"\\\\\" d", L"ab\"c", L"\\", L"d");
@@ -99,4 +110,5 @@
     ok_argsW(L"test.exe a  \"b\\  \"\"\"  c\" d", L"a", L"b\\  \"  c", L"d");
     ok_argsW(L"test.exe a  \"b\\  \"\"\"  \"c  \"\"\"\" d", L"a", L"b\\  \"  
c", L"\" d");
     ok_argsW(L"test.exe a b c  ", L"a", L"b", L"c");
+    ok_argsW(L"test.exe \"a b c\"", L"a b c", NULL, NULL);
 }


Reply via email to