Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
fc3868a0
Commit
fc3868a0
authored
Dec 04, 2012
by
Detlef Riekenberg
Committed by
Alexandre Julliard
Dec 05, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell32/tests: Add tests for DoEnvironmentSubstA/W.
parent
1708adeb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
152 additions
and
0 deletions
+152
-0
shellpath.c
dlls/shell32/tests/shellpath.c
+152
-0
No files found.
dlls/shell32/tests/shellpath.c
View file @
fc3868a0
...
...
@@ -2495,6 +2495,157 @@ static void test_knownFolders(void)
CoUninitialize
();
}
static
void
test_DoEnvironmentSubst
(
void
)
{
WCHAR
expectedW
[
MAX_PATH
];
WCHAR
bufferW
[
MAX_PATH
];
CHAR
expectedA
[
MAX_PATH
];
CHAR
bufferA
[
MAX_PATH
];
DWORD
res
;
DWORD
res2
;
DWORD
len
;
INT
i
;
static
const
WCHAR
does_not_existW
[]
=
{
'%'
,
'D'
,
'O'
,
'E'
,
'S'
,
'_'
,
'N'
,
'O'
,
'T'
,
'_'
,
'E'
,
'X'
,
'I'
,
'S'
,
'T'
,
'%'
,
0
};
static
const
CHAR
does_not_existA
[]
=
"%DOES_NOT_EXIST%"
;
static
const
CHAR
*
names
[]
=
{
/* interactive apps and services (works on all windows versions) */
"%ALLUSERSPROFILE%"
,
"%APPDATA%"
,
"%LOCALAPPDATA%"
,
"%NUMBER_OF_PROCESSORS%"
,
"%OS%"
,
"%PROCESSOR_ARCHITECTURE%"
,
"%PROCESSOR_IDENTIFIER%"
,
"%PROCESSOR_LEVEL%"
,
"%PROCESSOR_REVISION%"
,
"%ProgramFiles%"
,
"%SystemDrive%"
,
"%SystemRoot%"
,
"%USERPROFILE%"
,
"%windir%"
,
/* todo_wine: "%COMPUTERNAME%", "%ProgramData%", "%PUBLIC%", */
/* replace more than one var is allowed */
"%HOMEDRIVE%%HOMEPATH%"
,
"%OS% %windir%"
};
/* always the last entry in the table */
for
(
i
=
0
;
i
<
(
sizeof
(
names
)
/
sizeof
(
LPSTR
));
i
++
)
{
memset
(
bufferA
,
'#'
,
MAX_PATH
-
1
);
bufferA
[
MAX_PATH
-
1
]
=
0
;
lstrcpyA
(
bufferA
,
names
[
i
]);
MultiByteToWideChar
(
CP_ACP
,
0
,
bufferA
,
MAX_PATH
,
bufferW
,
sizeof
(
bufferW
)
/
sizeof
(
WCHAR
));
res2
=
ExpandEnvironmentStringsA
(
names
[
i
],
expectedA
,
MAX_PATH
);
res
=
DoEnvironmentSubstA
(
bufferA
,
MAX_PATH
);
/* is the space for the terminating 0 included? */
if
(
!
i
&&
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
(
lstrlenA
(
bufferA
))))
{
win_skip
(
"DoEnvironmentSubstA/W are broken on NT 4
\n
"
);
return
;
}
ok
(
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
res2
),
"%d: got %d/%d (expected TRUE/%d)
\n
"
,
i
,
HIWORD
(
res
),
LOWORD
(
res
),
res2
);
ok
(
!
lstrcmpA
(
bufferA
,
expectedA
),
"%d: got %s (expected %s)
\n
"
,
i
,
bufferA
,
expectedA
);
res2
=
ExpandEnvironmentStringsW
(
bufferW
,
expectedW
,
MAX_PATH
);
res
=
DoEnvironmentSubstW
(
bufferW
,
MAX_PATH
);
ok
(
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
res2
),
"%d: got %d/%d (expected TRUE/%d)
\n
"
,
i
,
HIWORD
(
res
),
LOWORD
(
res
),
res2
);
ok
(
!
lstrcmpW
(
bufferW
,
expectedW
),
"%d: got %s (expected %s)
\n
"
,
i
,
wine_dbgstr_w
(
bufferW
),
wine_dbgstr_w
(
expectedW
));
}
i
--
;
/* reuse data in the last table entry */
len
=
LOWORD
(
res
);
/* needed length */
/* one character extra is fine */
memset
(
bufferA
,
'#'
,
MAX_PATH
-
1
);
bufferA
[
len
+
2
]
=
0
;
lstrcpyA
(
bufferA
,
names
[
i
]);
MultiByteToWideChar
(
CP_ACP
,
0
,
bufferA
,
MAX_PATH
,
bufferW
,
sizeof
(
bufferW
)
/
sizeof
(
WCHAR
));
res2
=
ExpandEnvironmentStringsA
(
bufferA
,
expectedA
,
MAX_PATH
);
res
=
DoEnvironmentSubstA
(
bufferA
,
len
+
1
);
ok
(
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
res2
),
"+1: got %d/%d (expected TRUE/%d)
\n
"
,
HIWORD
(
res
),
LOWORD
(
res
),
res2
);
ok
(
!
lstrcmpA
(
bufferA
,
expectedA
),
"+1: got %s (expected %s)
\n
"
,
bufferA
,
expectedA
);
res2
=
ExpandEnvironmentStringsW
(
bufferW
,
expectedW
,
MAX_PATH
);
res
=
DoEnvironmentSubstW
(
bufferW
,
len
+
1
);
ok
(
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
res2
),
"+1: got %d/%d (expected TRUE/%d)
\n
"
,
HIWORD
(
res
),
LOWORD
(
res
),
res2
);
ok
(
!
lstrcmpW
(
bufferW
,
expectedW
),
"+1: got %s (expected %s)
\n
"
,
wine_dbgstr_w
(
bufferW
),
wine_dbgstr_w
(
expectedW
));
/* minimal buffer length (result string and terminating 0) */
memset
(
bufferA
,
'#'
,
MAX_PATH
-
1
);
bufferA
[
len
+
2
]
=
0
;
lstrcpyA
(
bufferA
,
names
[
i
]);
MultiByteToWideChar
(
CP_ACP
,
0
,
bufferA
,
MAX_PATH
,
bufferW
,
sizeof
(
bufferW
)
/
sizeof
(
WCHAR
));
/* ANSI version failed without an extra byte, as documented on msdn */
res
=
DoEnvironmentSubstA
(
bufferA
,
len
);
ok
(
!
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
len
),
" 0: got %d/%d (expected FALSE/%d)
\n
"
,
HIWORD
(
res
),
LOWORD
(
res
),
len
);
ok
(
!
lstrcmpA
(
bufferA
,
names
[
i
]),
" 0: got %s (expected %s)
\n
"
,
bufferA
,
names
[
i
]);
/* DoEnvironmentSubstW works as expected */
res2
=
ExpandEnvironmentStringsW
(
bufferW
,
expectedW
,
MAX_PATH
);
res
=
DoEnvironmentSubstW
(
bufferW
,
len
);
ok
(
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
res2
),
" 0: got %d/%d (expected TRUE/%d)
\n
"
,
HIWORD
(
res
),
LOWORD
(
res
),
res2
);
ok
(
!
lstrcmpW
(
bufferW
,
expectedW
),
" 0: got %s (expected %s)
\n
"
,
wine_dbgstr_w
(
bufferW
),
wine_dbgstr_w
(
expectedW
));
/* buffer to small */
/* result: FALSE / provided buffer length / the buffer is untouched */
memset
(
bufferA
,
'#'
,
MAX_PATH
-
1
);
bufferA
[
len
+
2
]
=
0
;
lstrcpyA
(
bufferA
,
names
[
i
]);
MultiByteToWideChar
(
CP_ACP
,
0
,
bufferA
,
MAX_PATH
,
bufferW
,
sizeof
(
bufferW
)
/
sizeof
(
WCHAR
));
res
=
DoEnvironmentSubstA
(
bufferA
,
len
-
1
);
ok
(
!
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
(
len
-
1
)),
"-1: got %d/%d (expected FALSE/%d)
\n
"
,
HIWORD
(
res
),
LOWORD
(
res
),
len
-
1
);
ok
(
!
lstrcmpA
(
bufferA
,
names
[
i
]),
"-1: got %s (expected %s)
\n
"
,
bufferA
,
names
[
i
]);
lstrcpyW
(
expectedW
,
bufferW
);
res
=
DoEnvironmentSubstW
(
bufferW
,
len
-
1
);
ok
(
!
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
(
len
-
1
)),
"-1: got %d/%d (expected FALSE/%d)
\n
"
,
HIWORD
(
res
),
LOWORD
(
res
),
len
-
1
);
ok
(
!
lstrcmpW
(
bufferW
,
expectedW
),
"-1: got %s (expected %s)
\n
"
,
wine_dbgstr_w
(
bufferW
),
wine_dbgstr_w
(
expectedW
));
/* unknown variable */
/* result: TRUE / string length including terminating 0 / the buffer is untouched */
memset
(
bufferA
,
'#'
,
MAX_PATH
-
1
);
bufferA
[
MAX_PATH
-
1
]
=
0
;
lstrcpyA
(
bufferA
,
does_not_existA
);
MultiByteToWideChar
(
CP_ACP
,
0
,
bufferA
,
MAX_PATH
,
bufferW
,
sizeof
(
bufferW
)
/
sizeof
(
WCHAR
));
res2
=
lstrlenA
(
does_not_existA
)
+
1
;
res
=
DoEnvironmentSubstA
(
bufferA
,
MAX_PATH
);
ok
(
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
res2
),
"%d: got %d/%d (expected TRUE/%d)
\n
"
,
i
,
HIWORD
(
res
),
LOWORD
(
res
),
res2
);
ok
(
!
lstrcmpA
(
bufferA
,
does_not_existA
),
"%d: got %s (expected %s)
\n
"
,
i
,
bufferA
,
does_not_existA
);
res
=
DoEnvironmentSubstW
(
bufferW
,
MAX_PATH
);
ok
(
HIWORD
(
res
)
&&
(
LOWORD
(
res
)
==
res2
),
"%d: got %d/%d (expected TRUE/%d)
\n
"
,
i
,
HIWORD
(
res
),
LOWORD
(
res
),
res2
);
ok
(
!
lstrcmpW
(
bufferW
,
does_not_existW
),
"%d: got %s (expected %s)
\n
"
,
i
,
wine_dbgstr_w
(
bufferW
),
wine_dbgstr_w
(
does_not_existW
));
if
(
0
)
{
/* NULL crashes on windows */
res
=
DoEnvironmentSubstA
(
NULL
,
MAX_PATH
);
res
=
DoEnvironmentSubstW
(
NULL
,
MAX_PATH
);
}
}
START_TEST
(
shellpath
)
{
if
(
!
init
())
return
;
...
...
@@ -2522,5 +2673,6 @@ START_TEST(shellpath)
test_NonExistentPath
();
test_SHGetFolderPathEx
();
test_knownFolders
();
test_DoEnvironmentSubst
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment