ReactOS 0.4.16-dev-197-g92996da
CommandLineToArgvW.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Test for CommandLineToArgvW
5 * COPYRIGHT: Copyright 2023 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
6 */
7
8#include "shelltest.h"
9#include <atlstr.h>
10
11static VOID
12DoEntry(INT lineno, LPCWSTR cmdline, INT expected_argc, ...)
13{
14 va_list va;
15 va_start(va, expected_argc);
16
17 INT real_argc;
18 LPWSTR *real_argv = CommandLineToArgvW(cmdline, &real_argc);
19
20 INT common = min(expected_argc, real_argc);
21 for (INT i = 1; i < common; ++i)
22 {
24 CStringA str2 = wine_dbgstr_w(real_argv[i]);
25 ok(str1 == str2, "Line %d: %s != %s\n", lineno, (LPCSTR)str1, (LPCSTR)str2);
26 }
27
28 INT diff = abs(expected_argc - real_argc);
29 while (diff-- > 0)
30 {
31 ok(expected_argc == real_argc,
32 "Line %d: expected_argc %d and real_argc %d are different\n",
33 lineno, expected_argc, real_argc);
34 }
35
36 LocalFree(real_argv);
37 va_end(va);
38}
39
41{
42 DoEntry(__LINE__, L"", 1);
43 DoEntry(__LINE__, L"test.exe", 1);
44 DoEntry(__LINE__, L"test.exe ", 1);
45 DoEntry(__LINE__, L"test.exe\t", 1);
46 DoEntry(__LINE__, L"test.exe\r", 1);
47 DoEntry(__LINE__, L"test.exe\n", 1);
48 DoEntry(__LINE__, L"test.exe\v", 1);
49 DoEntry(__LINE__, L"test.exe\f", 1);
50 DoEntry(__LINE__, L"test.exe\u3000", 1);
51 DoEntry(__LINE__, L"\"This is a test.exe\"", 1);
52 DoEntry(__LINE__, L"\"This is a test.exe\" ", 1);
53 DoEntry(__LINE__, L"\"This is a test.exe\"\t", 1);
54 DoEntry(__LINE__, L"\"This is a test.exe\"\r", 2, L"\r");
55 DoEntry(__LINE__, L"\"This is a test.exe\"\n", 2, L"\n");
56 DoEntry(__LINE__, L"\"This is a test.exe\"\v", 2, L"\v");
57 DoEntry(__LINE__, L"\"This is a test.exe\"\f", 2, L"\f");
58 DoEntry(__LINE__, L"\"This is a test.exe\"\u3000", 2, L"\u3000");
59 DoEntry(__LINE__, L"test.exe a", 2, L"a");
60 DoEntry(__LINE__, L"test.exe\ta", 2, L"a");
61 DoEntry(__LINE__, L"test.exe\ra", 2, L"a");
62 DoEntry(__LINE__, L"test.exe\na", 2, L"a");
63 DoEntry(__LINE__, L"test.exe\va", 2, L"a");
64 DoEntry(__LINE__, L"test.exe\fa", 2, L"a");
65 DoEntry(__LINE__, L"test.exe\u3000" L"a", 1);
66 DoEntry(__LINE__, L"test.exe a", 2, L"a");
67 DoEntry(__LINE__, L"test.exe \ta", 2, L"a");
68 DoEntry(__LINE__, L"test.exe \ra", 2, L"\ra");
69 DoEntry(__LINE__, L"test.exe \na", 2, L"\na");
70 DoEntry(__LINE__, L"test.exe \va", 2, L"\va");
71 DoEntry(__LINE__, L"test.exe \fa", 2, L"\fa");
72 DoEntry(__LINE__, L"test.exe a ", 2, L"a");
73 DoEntry(__LINE__, L"test.exe a\t", 2, L"a");
74 DoEntry(__LINE__, L"test.exe a\r", 2, L"a\r");
75 DoEntry(__LINE__, L"test.exe a\n", 2, L"a\n");
76 DoEntry(__LINE__, L"test.exe a\v", 2, L"a\v");
77 DoEntry(__LINE__, L"test.exe a\f", 2, L"a\f");
78 DoEntry(__LINE__, L"test.exe \"a\" ", 2, L"a");
79 DoEntry(__LINE__, L"test.exe \"a\"\t", 2, L"a");
80 DoEntry(__LINE__, L"test.exe \"a\"\r", 2, L"a\r");
81 DoEntry(__LINE__, L"test.exe \"a\"\n", 2, L"a\n");
82 DoEntry(__LINE__, L"test.exe \"a\"\v", 2, L"a\v");
83 DoEntry(__LINE__, L"test.exe \"a\"\f", 2, L"a\f");
84 DoEntry(__LINE__, L"test.exe \u3000" L"a", 2, L"\u3000" L"a");
85 DoEntry(__LINE__, L"test.exe \"a b\"", 2, L"a b");
86 DoEntry(__LINE__, L"test.exe \"a\tb\"", 2, L"a\tb");
87 DoEntry(__LINE__, L"test.exe \"a\rb\"", 2, L"a\rb");
88 DoEntry(__LINE__, L"test.exe \"a\nb\"", 2, L"a\nb");
89 DoEntry(__LINE__, L"test.exe \"a\vb\"", 2, L"a\vb");
90 DoEntry(__LINE__, L"test.exe \"a\fb\"", 2, L"a\fb");
91 DoEntry(__LINE__, L"test.exe \"a\u3000" L"b\"", 2, L"a\u3000" L"b");
92 DoEntry(__LINE__, L"test.exe a b c", 4, L"a", L"b", L"c");
93 DoEntry(__LINE__, L"test.exe a b \"c", 4, L"a", L"b", L"c");
94 DoEntry(__LINE__, L"test.exe \"a b\" \"c d\"", 3, L"a b", L"c d");
95 DoEntry(__LINE__, L"test.exe \"a \" d\"", 3, L"a ", L"d");
96 DoEntry(__LINE__, L"test.exe \"0 1\"\" 2", 3, L"0 1\"", L"2");
97 DoEntry(__LINE__, L"test.exe \"0 1\"\"\" 2", 2, L"0 1\" 2");
98}
static VOID DoEntry(INT lineno, LPCWSTR cmdline, INT expected_argc,...)
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
#define va_arg(ap, T)
Definition: acmsvcex.h:89
#define ok(value,...)
Definition: atltest.h:57
#define START_TEST(x)
Definition: atltest.h:75
#define abs(i)
Definition: fconv.c:206
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
#define wine_dbgstr_w
Definition: kernel32.h:34
#define min(a, b)
Definition: monoChain.cc:55
#define L(x)
Definition: ntvdm.h:50
LPWSTR *WINAPI CommandLineToArgvW(LPCWSTR lpCmdline, int *numargs)
Definition: shell32_main.c:79
TCHAR * cmdline
Definition: stretchblt.cpp:32
int32_t INT
Definition: typedefs.h:58
const char * LPCSTR
Definition: xmlstorage.h:183
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185