FreeRDP/winpr/libwinpr/path/test/TestPathIsUNCEx.c

53 lines
1015 B
C
Raw Normal View History

2012-10-02 00:49:34 +04:00
#include <stdio.h>
#include <winpr/crt.h>
#include <winpr/path.h>
#include <winpr/tchar.h>
#include <winpr/winpr.h>
static const TCHAR testServer[] = _T("server\\share\\path\\file");
static const TCHAR testPathUNC[] = _T("\\\\server\\share\\path\\file");
static const TCHAR testPathNotUNC[] = _T("C:\\share\\path\\file");
int TestPathIsUNCEx(int argc, char* argv[])
{
BOOL status;
2022-04-28 00:26:28 +03:00
LPCTSTR Server;
2012-10-02 00:49:34 +04:00
TCHAR Path[PATHCCH_MAX_CCH];
2021-07-29 11:18:52 +03:00
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
2012-10-02 00:49:34 +04:00
/* Path is UNC */
_tcscpy(Path, testPathUNC);
2022-04-28 00:26:28 +03:00
status = PathIsUNCEx(Path, &Server);
2012-10-02 00:49:34 +04:00
if (!status)
{
2022-04-28 00:26:28 +03:00
_tprintf(_T("PathIsUNCEx status: 0x%d\n"), status);
2012-10-02 00:49:34 +04:00
return -1;
}
if (_tcscmp(Server, testServer) != 0)
{
_tprintf(_T("Server Name Mismatch: Actual: %s, Expected: %s\n"), Server, testServer);
return -1;
}
/* Path is not UNC */
_tcscpy(Path, testPathNotUNC);
2022-04-28 00:26:28 +03:00
status = PathIsUNCEx(Path, &Server);
2012-10-02 00:49:34 +04:00
if (status)
{
2019-11-06 17:24:51 +03:00
_tprintf(_T("PathIsUNCEx status: 0x%08") _T(PRIX32) _T("\n"), status);
2012-10-02 00:49:34 +04:00
return -1;
}
return 0;
}