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 TestPathCchAddBackslashEx(
int argc,
char* argv[])
15 size_t cchRemaining = 0;
16 TCHAR Path[PATHCCH_MAX_CCH] = { 0 };
27 _tcsncpy(Path, testPathNoBackslash, ARRAYSIZE(Path));
31 status = PathCchAddBackslashEx(Path,
sizeof(Path) /
sizeof(TCHAR), &pszEnd, &cchRemaining);
35 _tprintf(_T(
"PathCchAddBackslash status: 0x%08") _T(PRIX32) _T(
"\n"), status);
39 if (_tcsncmp(Path, testPathBackslash, ARRAYSIZE(Path)) != 0)
41 _tprintf(_T(
"Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
47 _tcsncpy(Path, testPathBackslash, ARRAYSIZE(Path));
49 status = PathCchAddBackslashEx(Path,
sizeof(Path) /
sizeof(TCHAR), &pszEnd, &cchRemaining);
51 if (status != S_FALSE)
53 _tprintf(_T(
"PathCchAddBackslash status: 0x%08") _T(PRIX32) _T(
"\n"), status);
57 if (_tcsncmp(Path, testPathBackslash, ARRAYSIZE(Path)) != 0)
59 _tprintf(_T(
"Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
65 status = PathCchAddBackslashEx(NULL, PATHCCH_MAX_CCH, NULL, NULL);
67 if (SUCCEEDED(status))
70 _T(
"PathCchAddBackslashEx unexpectedly succeded with null buffer. Status: 0x%08") _T(
78 _tcsncpy(Path, _T(
"C:\\tmp"), ARRAYSIZE(Path));
80 status = PathCchAddBackslashEx(Path, 7, NULL, NULL);
82 if (SUCCEEDED(status))
84 _tprintf(_T(
"PathCchAddBackslashEx unexpectedly succeded with insufficient buffer size. ")
85 _T(
"Status: 0x%08") _T(PRIX32) _T(
"\n"),
92 _tcsncpy(Path, _T(
"C:\\tmp"), ARRAYSIZE(Path));
94 status = PathCchAddBackslashEx(Path, 8, NULL, NULL);
98 _tprintf(_T(
"PathCchAddBackslashEx failed with status: 0x%08") _T(PRIX32) _T(
"\n"), status);