/me slaps GCCLin.
[reactos.git] / rostests / apitests / shlwapi / PathIsUNC.c
1 /*
2 * Copyright 2017 Jared Smudde
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19 /* Documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773712(v=vs.85).aspx */
20
21 #include <apitest.h>
22
23 static BOOL (WINAPI *pPathIsUNC)(PCWSTR);
24
25 #define CALL_ISUNC(exp, str) \
26 do { \
27 BOOL ret = pPathIsUNC((str)); \
28 ok(ret == (exp), "Expected %ls to be %d, was %d\n", (str), (exp), ret); \
29 } while (0)
30
31 START_TEST(isuncpath)
32 {
33 HMODULE hDll = LoadLibraryA("shlwapi.dll");
34
35 pPathIsUNC = (void*)GetProcAddress(hDll, "PathIsUNCW");
36 if (!hDll || !pPathIsUNC)
37 {
38 skip("shlwapi.dll or export PathIsUNCW not found! Tests will be skipped\n");
39 return;
40 }
41
42 CALL_ISUNC(TRUE, L"\\\\path1\\path2");
43 CALL_ISUNC(TRUE, L"\\\\path1");
44 CALL_ISUNC(FALSE, L"reactos\\path4\\path5");
45 CALL_ISUNC(TRUE, L"\\\\");
46 CALL_ISUNC(TRUE, L"\\\\?\\UNC\\path1\\path2");
47 CALL_ISUNC(TRUE, L"\\\\?\\UNC\\path1");
48 CALL_ISUNC(TRUE, L"\\\\?\\UNC\\");
49 CALL_ISUNC(FALSE, L"\\path1");
50 CALL_ISUNC(FALSE, L"path1");
51 CALL_ISUNC(FALSE, L"c:\\path1");
52
53 /* MSDN says FALSE but the test shows TRUE on Windows 2003, but returns FALSE on Windows 7 */
54 CALL_ISUNC(TRUE, L"\\\\?\\c:\\path1");
55
56 CALL_ISUNC(TRUE, L"\\\\path1\\");
57 CALL_ISUNC(FALSE, L"//");
58 CALL_ISUNC(FALSE, L"////path1");
59 CALL_ISUNC(FALSE, L"////path1//path2");
60 CALL_ISUNC(FALSE, L"reactos//path3//path4");
61 CALL_ISUNC(TRUE, L"\\\\reactos\\?");
62 CALL_ISUNC(TRUE, L"\\\\reactos\\\\");
63 CALL_ISUNC(FALSE, (wchar_t*)NULL);
64 CALL_ISUNC(FALSE, L" ");
65
66 /* The test shows TRUE on Windows 2003, but returns FALSE on Windows 7 */
67 CALL_ISUNC(TRUE, L"\\\\?\\");
68 }