1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
#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 = 0;
LPTSTR PathOut = NULL;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
/* Base Path: Backslash, More Path: No Backslash */
status = PathAllocCombine(testBasePathBackslash, testMorePathNoBackslash, 0, &PathOut);
if (status != S_OK)
{
_tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
return -1;
}
if (_tcscmp(PathOut, testPathOut) != 0)
{
_tprintf(_T("Path Mismatch 1: Actual: %s, Expected: %s\n"), PathOut, testPathOut);
return -1;
}
free(PathOut);
/* Base Path: Backslash, More Path: Backslash */
status = PathAllocCombine(testBasePathBackslash, testMorePathBackslash, 0, &PathOut);
if (status != S_OK)
{
_tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
return -1;
}
if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0)
{
_tprintf(_T("Path Mismatch 2: Actual: %s, Expected: %s\n"), PathOut,
testPathOutMorePathBackslash);
return -1;
}
free(PathOut);
/* Base Path: No Backslash, More Path: Backslash */
status = PathAllocCombine(testBasePathNoBackslash, testMorePathBackslash, 0, &PathOut);
if (status != S_OK)
{
_tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
return -1;
}
if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0)
{
_tprintf(_T("Path Mismatch 3: Actual: %s, Expected: %s\n"), PathOut,
testPathOutMorePathBackslash);
return -1;
}
free(PathOut);
/* Base Path: No Backslash, More Path: No Backslash */
status = PathAllocCombine(testBasePathNoBackslash, testMorePathNoBackslash, 0, &PathOut);
if (status != S_OK)
{
_tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
return -1;
}
if (_tcscmp(PathOut, testPathOut) != 0)
{
_tprintf(_T("Path Mismatch 4: Actual: %s, Expected: %s\n"), PathOut, testPathOut);
return -1;
}
free(PathOut);
return 0;
}
|