https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b6aaf5e332dfd340124411d09352ccd637b350dd

commit b6aaf5e332dfd340124411d09352ccd637b350dd
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Thu Feb 2 10:09:00 2023 +0900
Commit:     GitHub <[email protected]>
CommitDate: Thu Feb 2 10:09:00 2023 +0900

    [SHELL32_APITEST] Add CommandLineToArgvW testcase (#5013)
    
    CORE-17787
---
 modules/rostests/apitests/shell32/CMakeLists.txt   |  1 +
 .../apitests/shell32/CommandLineToArgvW.cpp        | 63 ++++++++++++++++++++++
 modules/rostests/apitests/shell32/testlist.c       |  2 +
 3 files changed, 66 insertions(+)

diff --git a/modules/rostests/apitests/shell32/CMakeLists.txt 
b/modules/rostests/apitests/shell32/CMakeLists.txt
index 16b020510f3..53c87297d89 100644
--- a/modules/rostests/apitests/shell32/CMakeLists.txt
+++ b/modules/rostests/apitests/shell32/CMakeLists.txt
@@ -7,6 +7,7 @@ list(APPEND SOURCE
     CheckEscapes.cpp
     CIDLData.cpp
     CMyComputer.cpp
+    CommandLineToArgvW.cpp
     CShellDesktop.cpp
     CShellLink.cpp
     CUserNotification.cpp
diff --git a/modules/rostests/apitests/shell32/CommandLineToArgvW.cpp 
b/modules/rostests/apitests/shell32/CommandLineToArgvW.cpp
new file mode 100644
index 00000000000..03495b602e9
--- /dev/null
+++ b/modules/rostests/apitests/shell32/CommandLineToArgvW.cpp
@@ -0,0 +1,63 @@
+/*
+ * PROJECT:     ReactOS API tests
+ * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE:     Test for CommandLineToArgvW
+ * COPYRIGHT:   Copyright 2023 Katayama Hirofumi MZ 
([email protected])
+ */
+
+#include "shelltest.h"
+#include <atlstr.h>
+
+static VOID
+DoEntry(INT lineno, LPCWSTR cmdline, INT expected_argc, ...)
+{
+    va_list va;
+    va_start(va, expected_argc);
+
+    INT real_argc;
+    LPWSTR *real_argv = CommandLineToArgvW(cmdline, &real_argc);
+
+    INT common = min(expected_argc, real_argc);
+    for (INT i = 1; i < common; ++i)
+    {
+        CStringA str1 = wine_dbgstr_w(va_arg(va, LPCWSTR));
+        CStringA str2 = wine_dbgstr_w(real_argv[i]);
+        ok(str1 == str2, "Line %d: %s != %s\n", lineno, (LPCSTR)str1, 
(LPCSTR)str2);
+    }
+
+    INT diff = abs(expected_argc - real_argc);
+    while (diff-- > 0)
+    {
+        ok(expected_argc == real_argc,
+           "Line %d: expected_argc %d and real_argc %d are different\n",
+           lineno, expected_argc, real_argc);
+    }
+
+    LocalFree(real_argv);
+    va_end(va);
+}
+
+START_TEST(CommandLineToArgvW)
+{
+    DoEntry(__LINE__, L"", 1);
+    DoEntry(__LINE__, L"test.exe", 1);
+    DoEntry(__LINE__, L"test.exe ", 1);
+    DoEntry(__LINE__, L"test.exe\t", 1);
+    DoEntry(__LINE__, L"test.exe\r", 1);
+    DoEntry(__LINE__, L"test.exe\n", 1);
+    DoEntry(__LINE__, L"\"This is a test.exe\"", 1);
+    DoEntry(__LINE__, L"\"This is a test.exe\" ", 1);
+    DoEntry(__LINE__, L"\"This is a test.exe\"\t", 1);
+    DoEntry(__LINE__, L"\"This is a test.exe\"\r", 2, L"\r");
+    DoEntry(__LINE__, L"\"This is a test.exe\"\n", 2, L"\n");
+    DoEntry(__LINE__, L"test.exe a", 2, L"a");
+    DoEntry(__LINE__, L"test.exe\ta", 2, L"a");
+    DoEntry(__LINE__, L"test.exe\ra", 2, L"a");
+    DoEntry(__LINE__, L"test.exe\na", 2, L"a");
+    DoEntry(__LINE__, L"test.exe a b c", 4, L"a", L"b", L"c");
+    DoEntry(__LINE__, L"test.exe a b \"c", 4, L"a", L"b", L"c");
+    DoEntry(__LINE__, L"test.exe \"a b\" \"c d\"", 3, L"a b", L"c d");
+    DoEntry(__LINE__, L"test.exe \"a \" d\"", 3, L"a ", L"d");
+    DoEntry(__LINE__, L"test.exe \"0 1\"\" 2", 3, L"0 1\"", L"2");
+    DoEntry(__LINE__, L"test.exe \"0 1\"\"\" 2", 2, L"0 1\" 2");
+}
diff --git a/modules/rostests/apitests/shell32/testlist.c 
b/modules/rostests/apitests/shell32/testlist.c
index ac5dd174e40..1fdf7ca44d2 100644
--- a/modules/rostests/apitests/shell32/testlist.c
+++ b/modules/rostests/apitests/shell32/testlist.c
@@ -9,6 +9,7 @@ extern void func_CFSFolder(void);
 extern void func_CheckEscapes(void);
 extern void func_CIDLData(void);
 extern void func_CMyComputer(void);
+extern void func_CommandLineToArgvW(void);
 extern void func_CShellDesktop(void);
 extern void func_CShellLink(void);
 extern void func_CUserNotification(void);
@@ -41,6 +42,7 @@ const struct test winetest_testlist[] =
     { "CheckEscapes", func_CheckEscapes },
     { "CIDLData", func_CIDLData },
     { "CMyComputer", func_CMyComputer },
+    { "CommandLineToArgvW", func_CommandLineToArgvW },
     { "CShellDesktop", func_CShellDesktop },
     { "CShellLink", func_CShellLink },
     { "CUserNotification", func_CUserNotification },

Reply via email to