1 /*
2 * PROJECT: ReactOS api tests
3 * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later)
4 * PURPOSE: Tests for PathFileExistsDefExtAndAttributesW
5 * COPYRIGHT: Copyright 2024 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
6 */
7
8 #include <apitest.h>
9 #include <shlobj.h>
10 #include <shlwapi.h>
11 #include <shlwapi_undoc.h>
12
START_TEST(PathFileExistsDefExtAndAttributesW)13 START_TEST(PathFileExistsDefExtAndAttributesW)
14 {
15 WCHAR szPath[MAX_PATH];
16 DWORD attrs;
17 BOOL ret;
18
19 /* NULL check */
20 ret = PathFileExistsDefExtAndAttributesW(NULL, 0, NULL);
21 ok_int(ret, FALSE);
22
23 /* Not existent file */
24 lstrcpynW(szPath, L"Not Existent File.txt", _countof(szPath));
25 ret = PathFileExistsDefExtAndAttributesW(szPath, 0, NULL);
26 ok_int(ret, FALSE);
27
28 /* "Windows" directory */
29 GetWindowsDirectoryW(szPath, _countof(szPath));
30 ret = PathFileExistsDefExtAndAttributesW(szPath, 0, NULL);
31 ok_int(ret, TRUE);
32
33 /* "Windows" directory with attributes check */
34 attrs = 0;
35 ret = PathFileExistsDefExtAndAttributesW(szPath, 0, &attrs);
36 ok_int(ret, TRUE);
37 ok(attrs != 0 && attrs != INVALID_FILE_ATTRIBUTES, "attrs was 0x%lX\n", attrs);
38
39 /* Find notepad.exe */
40 SearchPathW(NULL, L"notepad.exe", NULL, _countof(szPath), szPath, NULL);
41 ret = PathFileExistsW(szPath);
42 ok_int(ret, TRUE);
43
44 /* Remove .exe */
45 PathRemoveExtensionW(szPath);
46 ret = PathFileExistsW(szPath);
47 ok_int(ret, FALSE);
48
49 /* Add .exe */
50 ret = PathFileExistsDefExtAndAttributesW(szPath, WHICH_EXE, NULL);
51 ok_int(ret, TRUE);
52 ret = PathFileExistsW(szPath);
53 ok_int(ret, TRUE);
54
55 /* notepad.cmd doesn't exist */
56 PathRemoveExtensionW(szPath);
57 ret = PathFileExistsDefExtAndAttributesW(szPath, WHICH_CMD, NULL);
58 ok_int(ret, FALSE);
59 ret = PathFileExistsW(szPath);
60 ok_int(ret, FALSE);
61 }
62