From: Hermès Bélusca-Maïto Date: Fri, 13 Jan 2017 00:06:12 +0000 (+0000) Subject: [SHLWAPI_APITEST]: New test for PathIsUNC function, by Jared Smudde. Thanks! X-Git-Tag: ReactOS-0.4.4-FOSDEM2017~8^2~72 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=c785b8f07751cfe0a153d1bbbcabc4b26a9ee24f [SHLWAPI_APITEST]: New test for PathIsUNC function, by Jared Smudde. Thanks! ROSTESTS-256 #resolve svn path=/trunk/; revision=73527 --- diff --git a/rostests/apitests/CMakeLists.txt b/rostests/apitests/CMakeLists.txt index 81e2f9610a1..ff582efdd9e 100644 --- a/rostests/apitests/CMakeLists.txt +++ b/rostests/apitests/CMakeLists.txt @@ -26,6 +26,7 @@ add_subdirectory(powrprof) add_subdirectory(sdk) add_subdirectory(setupapi) add_subdirectory(shell32) +add_subdirectory(shlwapi) add_subdirectory(spoolss) add_subdirectory(psapi) add_subdirectory(user32) diff --git a/rostests/apitests/shlwapi/CMakeLists.txt b/rostests/apitests/shlwapi/CMakeLists.txt new file mode 100644 index 00000000000..f447e0e22a2 --- /dev/null +++ b/rostests/apitests/shlwapi/CMakeLists.txt @@ -0,0 +1,5 @@ + +add_executable(shlwapi_apitest PathIsUNC.c testlist.c) +set_module_type(shlwapi_apitest win32cui) +add_importlibs(shlwapi_apitest msvcrt kernel32) +add_cd_file(TARGET shlwapi_apitest DESTINATION reactos/bin FOR all) diff --git a/rostests/apitests/shlwapi/PathIsUNC.c b/rostests/apitests/shlwapi/PathIsUNC.c new file mode 100644 index 00000000000..a8309acb5b0 --- /dev/null +++ b/rostests/apitests/shlwapi/PathIsUNC.c @@ -0,0 +1,68 @@ +/* + * Copyright 2017 Jared Smudde + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +/* Documentation: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773712(v=vs.85).aspx */ + +#include + +static BOOL (WINAPI *pPathIsUNC)(PCWSTR); + +#define CALL_ISUNC(exp, str) \ +do { \ + BOOL ret = pPathIsUNC((str)); \ + ok(ret == (exp), "Expected %S to be %d, was %d\n", (str), (exp), ret); \ +} while (0) + +START_TEST(isuncpath) +{ + HMODULE hDll = LoadLibraryA("shlwapi.dll"); + + pPathIsUNC = (void*)GetProcAddress(hDll, "PathIsUNCW"); + if (!hDll || !pPathIsUNC) + { + skip("shlwapi.dll or export PathIsUNCW not found! Tests will be skipped\n"); + return; + } + + CALL_ISUNC(TRUE, L"\\\\path1\\path2"); + CALL_ISUNC(TRUE, L"\\\\path1"); + CALL_ISUNC(FALSE, L"reactos\\path4\\path5"); + CALL_ISUNC(TRUE, L"\\\\"); + CALL_ISUNC(TRUE, L"\\\\?\\UNC\\path1\\path2"); + CALL_ISUNC(TRUE, L"\\\\?\\UNC\\path1"); + CALL_ISUNC(TRUE, L"\\\\?\\UNC\\"); + CALL_ISUNC(FALSE, L"\\path1"); + CALL_ISUNC(FALSE, L"path1"); + CALL_ISUNC(FALSE, L"c:\\path1"); + + /* MSDN says FALSE but the test shows TRUE on Windows 2003, but returns FALSE on Windows 7 */ + CALL_ISUNC(TRUE, L"\\\\?\\c:\\path1"); + + CALL_ISUNC(TRUE, L"\\\\path1\\"); + CALL_ISUNC(FALSE, L"//"); + CALL_ISUNC(FALSE, L"////path1"); + CALL_ISUNC(FALSE, L"////path1//path2"); + CALL_ISUNC(FALSE, L"reactos//path3//path4"); + CALL_ISUNC(TRUE, L"\\\\reactos\\?"); + CALL_ISUNC(TRUE, L"\\\\reactos\\\\"); + CALL_ISUNC(FALSE, NULL); + CALL_ISUNC(FALSE, L" "); + + /* The test shows TRUE on Windows 2003, but returns FALSE on Windows 7 */ + CALL_ISUNC(TRUE, L"\\\\?\\"); +} diff --git a/rostests/apitests/shlwapi/testlist.c b/rostests/apitests/shlwapi/testlist.c new file mode 100644 index 00000000000..1aba16cbb60 --- /dev/null +++ b/rostests/apitests/shlwapi/testlist.c @@ -0,0 +1,10 @@ +#define STANDALONE +#include + +extern void func_isuncpath(void); + +const struct test winetest_testlist[] = +{ + { "PathIsUNC", func_isuncpath }, + { 0, 0 } +};