FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
TestPathAllocCombine.c
1
2#include <stdio.h>
3#include <winpr/crt.h>
4#include <winpr/path.h>
5#include <winpr/tchar.h>
6#include <winpr/winpr.h>
7
8static const TCHAR testBasePathBackslash[] = _T("C:\\Program Files\\");
9static const TCHAR testBasePathNoBackslash[] = _T("C:\\Program Files");
10static const TCHAR testMorePathBackslash[] = _T("\\Microsoft Visual Studio 11.0");
11static const TCHAR testMorePathNoBackslash[] = _T("Microsoft Visual Studio 11.0");
12static const TCHAR testPathOut[] = _T("C:\\Program Files\\Microsoft Visual Studio 11.0");
13static const TCHAR testPathOutMorePathBackslash[] = _T("C:\\Microsoft Visual Studio 11.0");
14
15int TestPathAllocCombine(int argc, char* argv[])
16{
17 HRESULT status = 0;
18 LPTSTR PathOut = NULL;
19
20 WINPR_UNUSED(argc);
21 WINPR_UNUSED(argv);
22
23 /* Base Path: Backslash, More Path: No Backslash */
24
25 status = PathAllocCombine(testBasePathBackslash, testMorePathNoBackslash, 0, &PathOut);
26
27 if (status != S_OK)
28 {
29 _tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
30 return -1;
31 }
32
33 if (_tcscmp(PathOut, testPathOut) != 0)
34 {
35 _tprintf(_T("Path Mismatch 1: Actual: %s, Expected: %s\n"), PathOut, testPathOut);
36 return -1;
37 }
38
39 free(PathOut);
40
41 /* Base Path: Backslash, More Path: Backslash */
42
43 status = PathAllocCombine(testBasePathBackslash, testMorePathBackslash, 0, &PathOut);
44
45 if (status != S_OK)
46 {
47 _tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
48 return -1;
49 }
50
51 if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0)
52 {
53 _tprintf(_T("Path Mismatch 2: Actual: %s, Expected: %s\n"), PathOut,
54 testPathOutMorePathBackslash);
55 return -1;
56 }
57
58 free(PathOut);
59
60 /* Base Path: No Backslash, More Path: Backslash */
61
62 status = PathAllocCombine(testBasePathNoBackslash, testMorePathBackslash, 0, &PathOut);
63
64 if (status != S_OK)
65 {
66 _tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
67 return -1;
68 }
69
70 if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0)
71 {
72 _tprintf(_T("Path Mismatch 3: Actual: %s, Expected: %s\n"), PathOut,
73 testPathOutMorePathBackslash);
74 return -1;
75 }
76
77 free(PathOut);
78
79 /* Base Path: No Backslash, More Path: No Backslash */
80
81 status = PathAllocCombine(testBasePathNoBackslash, testMorePathNoBackslash, 0, &PathOut);
82
83 if (status != S_OK)
84 {
85 _tprintf(_T("PathAllocCombine status: 0x%08") _T(PRIX32) _T("\n"), status);
86 return -1;
87 }
88
89 if (_tcscmp(PathOut, testPathOut) != 0)
90 {
91 _tprintf(_T("Path Mismatch 4: Actual: %s, Expected: %s\n"), PathOut, testPathOut);
92 return -1;
93 }
94
95 free(PathOut);
96
97 return 0;
98}