3 #include <winpr/path.h>
4 #include <winpr/tchar.h>
5 #include <winpr/winpr.h>
7 static const char testPathExtension[] =
"C:\\Windows\\System32\\cmd.exe";
9 int TestPathCchFindExtension(
int argc,
char* argv[])
20 hr = PathCchFindExtensionA(NULL,
sizeof(testPathExtension), &pszExt);
24 "PathCchFindExtensionA unexpectedly succeeded with pszPath = NULL. result: 0x%08" PRIX32
30 hr = PathCchFindExtensionA(testPathExtension, 0, &pszExt);
33 printf(
"PathCchFindExtensionA unexpectedly succeeded with cchPath = 0. result: 0x%08" PRIX32
39 hr = PathCchFindExtensionA(testPathExtension,
sizeof(testPathExtension), NULL);
43 "PathCchFindExtensionA unexpectedly succeeded with ppszExt = NULL. result: 0x%08" PRIX32
51 hr = PathCchFindExtensionA(
"c:\\45.789", 9, &pszExt);
54 printf(
"PathCchFindExtensionA unexpectedly succeeded with unterminated pszPath. result: "
64 hr = PathCchFindExtensionA(pszTmp, 1, &pszExt);
67 printf(
"PathCchFindExtensionA failed with an empty terminated string. result: 0x%08" PRIX32
75 printf(
"PathCchFindExtensionA failed with an empty terminated string: pszExt pointer "
83 pszTmp =
"c:\\4.678\\";
84 hr = PathCchFindExtensionA(pszTmp, 10, &pszExt);
87 printf(
"PathCchFindExtensionA failed with a directory path. result: 0x%08" PRIX32
"\n", hr);
92 if (pszExt != &pszTmp[9])
94 printf(
"PathCchFindExtensionA failed with a directory path: pszExt pointer mismatch\n");
101 if (PathCchFindExtensionA(testPathExtension,
sizeof(testPathExtension), &pszExt) != S_OK)
103 printf(
"PathCchFindExtensionA failure: expected S_OK\n");
107 if (!pszExt || strcmp(pszExt,
".exe") != 0)
109 printf(
"PathCchFindExtensionA failure: unexpected extension\n");
113 printf(
"Extension: %s\n", pszExt);