4 #include <winpr/path.h>
5 #include <winpr/tchar.h>
6 #include <winpr/winpr.h>
8 static const TCHAR testPathBackslash[] = _T(
"C:\\Program Files\\");
9 static const TCHAR testPathNoBackslash[] = _T(
"C:\\Program Files");
11 int TestPathCchAddBackslash(
int argc,
char* argv[])
14 TCHAR Path[PATHCCH_MAX_CCH] = { 0 };
25 _tcsncpy(Path, testPathNoBackslash, ARRAYSIZE(Path));
29 status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH);
33 _tprintf(_T(
"PathCchAddBackslash status: 0x%08") _T(PRIX32) _T(
"\n"), status);
37 if (_tcsncmp(Path, testPathBackslash, ARRAYSIZE(Path)) != 0)
39 _tprintf(_T(
"Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
45 _tcsncpy(Path, testPathBackslash, ARRAYSIZE(Path));
47 status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH);
49 if (status != S_FALSE)
51 _tprintf(_T(
"PathCchAddBackslash status: 0x%08") _T(PRIX32) _T(
"\n"), status);
55 if (_tcsncmp(Path, testPathBackslash, ARRAYSIZE(Path)) != 0)
57 _tprintf(_T(
"Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
63 status = PathCchAddBackslash(NULL, PATHCCH_MAX_CCH);
65 if (SUCCEEDED(status))
67 _tprintf(_T(
"PathCchAddBackslash unexpectedly succeded with null buffer. Status: 0x%08") _T(
75 _tcsncpy(Path, _T(
"C:\\tmp"), ARRAYSIZE(Path));
77 status = PathCchAddBackslash(Path, 7);
79 if (SUCCEEDED(status))
81 _tprintf(_T(
"PathCchAddBackslash unexpectedly succeded with insufficient buffer size. ")
82 _T(
"Status: 0x%08") _T(PRIX32) _T(
"\n"),
89 _tcsncpy(Path, _T(
"C:\\tmp"), ARRAYSIZE(Path));
91 status = PathCchAddBackslash(Path, 8);
95 _tprintf(_T(
"PathCchAddBackslash failed with status: 0x%08") _T(PRIX32) _T(
"\n"), status);