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 testBasePathBackslash[] = _T("C:\\Program Files\\");
|
|
|
|
static const TCHAR testBasePathNoBackslash[] = _T("C:\\Program Files");
|
|
|
|
static const TCHAR testMorePathBackslash[] = _T("\\Microsoft Visual Studio 11.0");
|
|
|
|
static const TCHAR testMorePathNoBackslash[] = _T("Microsoft Visual Studio 11.0");
|
|
|
|
static const TCHAR testPathOut[] = _T("C:\\Program Files\\Microsoft Visual Studio 11.0");
|
|
|
|
static const TCHAR testPathOutMorePathBackslash[] = _T("C:\\Microsoft Visual Studio 11.0");
|
|
|
|
|
|
|
|
int TestPathAllocCombine(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
HRESULT status;
|
|
|
|
LPTSTR PathOut;
|
|
|
|
|
2021-07-29 11:18:52 +03:00
|
|
|
WINPR_UNUSED(argc);
|
|
|
|
WINPR_UNUSED(argv);
|
|
|
|
|
2012-10-02 00:49:34 +04:00
|
|
|
/* Base Path: Backslash, More Path: No Backslash */
|
|
|
|
|
|
|
|
status = PathAllocCombine(testBasePathBackslash, testMorePathNoBackslash, 0, &PathOut);
|
|
|
|
|
|
|
|
if (status != S_OK)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
_tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
|
2012-10-02 00:49:34 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcscmp(PathOut, testPathOut) != 0)
|
|
|
|
{
|
2012-10-05 19:40:33 +04:00
|
|
|
_tprintf(_T("Path Mismatch 1: Actual: %s, Expected: %s\n"), PathOut, testPathOut);
|
2012-10-02 00:49:34 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-12-20 15:29:48 +03:00
|
|
|
free(PathOut);
|
2012-10-02 00:49:34 +04:00
|
|
|
|
|
|
|
/* Base Path: Backslash, More Path: Backslash */
|
|
|
|
|
|
|
|
status = PathAllocCombine(testBasePathBackslash, testMorePathBackslash, 0, &PathOut);
|
|
|
|
|
|
|
|
if (status != S_OK)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
_tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
|
2012-10-02 00:49:34 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
_tprintf(_T("Path Mismatch 2: Actual: %s, Expected: %s\n"), PathOut,
|
|
|
|
testPathOutMorePathBackslash);
|
2012-10-02 00:49:34 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-12-20 15:29:48 +03:00
|
|
|
free(PathOut);
|
2012-10-02 00:49:34 +04:00
|
|
|
|
|
|
|
/* Base Path: No Backslash, More Path: Backslash */
|
|
|
|
|
|
|
|
status = PathAllocCombine(testBasePathNoBackslash, testMorePathBackslash, 0, &PathOut);
|
|
|
|
|
|
|
|
if (status != S_OK)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
_tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
|
2012-10-02 00:49:34 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
_tprintf(_T("Path Mismatch 3: Actual: %s, Expected: %s\n"), PathOut,
|
|
|
|
testPathOutMorePathBackslash);
|
2012-10-02 00:49:34 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-12-20 15:29:48 +03:00
|
|
|
free(PathOut);
|
2012-10-02 00:49:34 +04:00
|
|
|
|
|
|
|
/* Base Path: No Backslash, More Path: No Backslash */
|
|
|
|
|
|
|
|
status = PathAllocCombine(testBasePathNoBackslash, testMorePathNoBackslash, 0, &PathOut);
|
|
|
|
|
|
|
|
if (status != S_OK)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
_tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
|
2012-10-02 00:49:34 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_tcscmp(PathOut, testPathOut) != 0)
|
|
|
|
{
|
2012-10-05 19:40:33 +04:00
|
|
|
_tprintf(_T("Path Mismatch 4: Actual: %s, Expected: %s\n"), PathOut, testPathOut);
|
2012-10-02 00:49:34 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2021-12-20 15:29:48 +03:00
|
|
|
free(PathOut);
|
2012-10-02 00:49:34 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|