libwinpr-path: start writing tests
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Mon, 1 Oct 2012 20:49:34 +0000 (16:49 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Mon, 1 Oct 2012 20:49:34 +0000 (16:49 -0400)
27 files changed:
winpr/include/winpr/error.h
winpr/include/winpr/path.h
winpr/libwinpr/path/CMakeLists.txt
winpr/libwinpr/path/test/.gitignore [new file with mode: 0644]
winpr/libwinpr/path/test/CMakeLists.txt [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathAllocCanonicalize.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathAllocCombine.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchAddBackslash.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchAddExtension.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchAppend.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchAppendEx.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchCanonicalize.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchCombine.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchCombineEx.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchFindExtension.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchIsRoot.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchRemoveExtension.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchRenameExtension.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchSkipRoot.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchStripPrefix.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathCchStripToRoot.c [new file with mode: 0644]
winpr/libwinpr/path/test/TestPathIsUNCEx.c [new file with mode: 0644]

index 21f5f05..58ffc31 100644 (file)
@@ -25,6 +25,9 @@
 
 #ifndef _WIN32
 
+#define S_OK                                                                           ((HRESULT) 0L)
+#define S_FALSE                                                                                ((HRESULT) 1L)
+
 /* System Error Codes (0-499) */
 
 #define ERROR_SUCCESS                                                                  0x00000000
index edcb903..432c12c 100644 (file)
 #define WINPR_PATH_H
 
 #include <winpr/winpr.h>
+#include <winpr/tchar.h>
 #include <winpr/wtypes.h>
 
+//#define HAVE_PATHCCH_H       1
+
+#ifdef HAVE_PATHCCH_H
+
+#include <Pathcch.h>
+
+#else
+
+#define PATHCCH_ALLOW_LONG_PATHS       0x00000001 /* Allow building of \\?\ paths if longer than MAX_PATH */
+
+#define VOLUME_PREFIX                  _T("\\\\?\\Volume")
+#define VOLUME_PREFIX_LEN              ((sizeof(VOLUME_PREFIX) / sizeof(TCHAR)) - 1)
+
+/*
+ * Maximum number of characters we support using the "\\?\" syntax
+ * (0x7FFF + 1 for NULL terminator)
+ */
+
+#define PATHCCH_MAX_CCH                        0x8000
+
 WINPR_API HRESULT PathCchAddBackslashA(PSTR pszPath, size_t cchPath);
 WINPR_API HRESULT PathCchAddBackslashW(PWSTR pszPath, size_t cchPath);
 
@@ -137,4 +158,6 @@ WINPR_API HRESULT PathCchRemoveFileSpecW(PWSTR pszPath, size_t cchPath);
 #define PathCchRemoveFileSpec          PathCchRemoveFileSpecA
 #endif
 
+#endif
+
 #endif /* WINPR_PATH_H */
index 1caa734..0c19c75 100644 (file)
@@ -36,3 +36,7 @@ else()
 endif()
 
 set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")
+
+if(BUILD_TESTING)
+       add_subdirectory(test)
+endif()
diff --git a/winpr/libwinpr/path/test/.gitignore b/winpr/libwinpr/path/test/.gitignore
new file mode 100644 (file)
index 0000000..7c43324
--- /dev/null
@@ -0,0 +1,3 @@
+TestPath
+TestPath.c
+
diff --git a/winpr/libwinpr/path/test/CMakeLists.txt b/winpr/libwinpr/path/test/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b8eb05f
--- /dev/null
@@ -0,0 +1,48 @@
+
+set(MODULE_NAME "TestPath")
+set(MODULE_PREFIX "TEST_PATH")
+
+set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
+
+set(${MODULE_PREFIX}_TESTS
+       TestPathCchAddBackslash.c
+       TestPathCchRemoveBackslash.c
+       TestPathCchAddBackslashEx.c
+       TestPathCchRemoveBackslashEx.c
+       TestPathCchAddExtension.c
+       TestPathCchAppend.c
+       TestPathCchAppendEx.c
+       TestPathCchCanonicalize.c
+       TestPathCchCanonicalizeEx.c
+       TestPathAllocCanonicalize.c
+       TestPathCchCombine.c
+       TestPathCchCombineEx.c
+       TestPathAllocCombine.c
+       TestPathCchFindExtension.c
+       TestPathCchRenameExtension.c
+       TestPathCchRemoveExtension.c
+       TestPathCchIsRoot.c
+       TestPathIsUNCEx.c
+       TestPathCchSkipRoot.c
+       TestPathCchStripToRoot.c
+       TestPathCchStripPrefix.c
+       TestPathCchRemoveFileSpec.c)
+
+create_test_sourcelist(${MODULE_PREFIX}_SRCS
+       ${${MODULE_PREFIX}_DRIVER}
+       ${${MODULE_PREFIX}_TESTS})
+
+add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
+
+if(WIN32)
+       target_link_libraries(${MODULE_NAME} Pathcch)
+else()
+       target_link_libraries(${MODULE_NAME} winpr-path)
+endif()
+
+foreach(test ${${MODULE_PREFIX}_TESTS})
+       get_filename_component(TestName ${test} NAME_WE)
+       add_test(${TestName} ${EXECUTABLE_OUTPUT_PATH}/${MODULE_NAME} ${TestName})
+endforeach()
+
+set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test")
diff --git a/winpr/libwinpr/path/test/TestPathAllocCanonicalize.c b/winpr/libwinpr/path/test/TestPathAllocCanonicalize.c
new file mode 100644 (file)
index 0000000..81f6014
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathAllocCanonicalize(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathAllocCombine.c b/winpr/libwinpr/path/test/TestPathAllocCombine.c
new file mode 100644 (file)
index 0000000..a2fd2b0
--- /dev/null
@@ -0,0 +1,94 @@
+
+#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;
+       LPTSTR PathOut;
+
+       /* Base Path: Backslash, More Path: No Backslash */
+
+       status = PathAllocCombine(testBasePathBackslash, testMorePathNoBackslash, 0, &PathOut);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(PathOut, testPathOut) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOut);
+               return -1;
+       }
+
+       HeapFree(GetProcessHeap(), 0, PathOut);
+
+       /* Base Path: Backslash, More Path: Backslash */
+
+       status = PathAllocCombine(testBasePathBackslash, testMorePathBackslash, 0, &PathOut);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOutMorePathBackslash);
+               return -1;
+       }
+
+       HeapFree(GetProcessHeap(), 0, PathOut);
+
+       /* Base Path: No Backslash, More Path: Backslash */
+
+       status = PathAllocCombine(testBasePathNoBackslash, testMorePathBackslash, 0, &PathOut);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(PathOut, testPathOutMorePathBackslash) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOutMorePathBackslash);
+               return -1;
+       }
+
+       HeapFree(GetProcessHeap(), 0, PathOut);
+
+       /* Base Path: No Backslash, More Path: No Backslash */
+
+       status = PathAllocCombine(testBasePathNoBackslash, testMorePathNoBackslash, 0, &PathOut);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathAllocCombine status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(PathOut, testPathOut) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), PathOut, testPathOut);
+               return -1;
+       }
+
+       HeapFree(GetProcessHeap(), 0, PathOut);
+
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslash.c b/winpr/libwinpr/path/test/TestPathCchAddBackslash.c
new file mode 100644 (file)
index 0000000..b237b6b
--- /dev/null
@@ -0,0 +1,54 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+static const TCHAR testPathBackslash[] = _T("C:\\Program Files\\");
+static const TCHAR testPathNoBackslash[] = _T("C:\\Program Files");
+
+int TestPathCchAddBackslash(int argc, char* argv[])
+{
+       HRESULT status;
+       TCHAR Path[PATHCCH_MAX_CCH];
+
+       _tcscpy(Path, testPathNoBackslash);
+
+       /* Add a backslash to a path without a trailing backslash, expect S_OK */
+
+       status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathBackslash) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
+               return -1;
+       }
+
+       /* Add a backslash to a path with a trailing backslash, expect S_FALSE */
+
+       _tcscpy(Path, testPathBackslash);
+
+       status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH);
+
+       if (status != S_FALSE)
+       {
+               _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathBackslash) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
+               return -1;
+       }
+
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c b/winpr/libwinpr/path/test/TestPathCchAddBackslashEx.c
new file mode 100644 (file)
index 0000000..9fe39be
--- /dev/null
@@ -0,0 +1,56 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+static const TCHAR testPathBackslash[] = _T("C:\\Program Files\\");
+static const TCHAR testPathNoBackslash[] = _T("C:\\Program Files");
+
+int TestPathCchAddBackslashEx(int argc, char* argv[])
+{
+       HRESULT status;
+       LPTSTR pszEnd;
+       size_t cchRemaining;
+       TCHAR Path[PATHCCH_MAX_CCH];
+
+       _tcscpy(Path, testPathNoBackslash);
+
+       /* Add a backslash to a path without a trailing backslash, expect S_OK */
+
+       status = PathCchAddBackslashEx(Path, sizeof(Path) / sizeof(TCHAR), &pszEnd, &cchRemaining);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathBackslash) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
+               return -1;
+       }
+
+       /* Add a backslash to a path with a trailing backslash, expect S_FALSE */
+
+       _tcscpy(Path, testPathBackslash);
+
+       status = PathCchAddBackslashEx(Path, sizeof(Path) / sizeof(TCHAR), &pszEnd, &cchRemaining);
+
+       if (status != S_FALSE)
+       {
+               _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathBackslash) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
+               return -1;
+       }
+
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchAddExtension.c b/winpr/libwinpr/path/test/TestPathCchAddExtension.c
new file mode 100644 (file)
index 0000000..ef766cf
--- /dev/null
@@ -0,0 +1,92 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+static const TCHAR testExtDot[] = _T(".exe");
+static const TCHAR testExtNoDot[] = _T("exe");
+static const TCHAR testPathNoExtension[] = _T("C:\\Windows\\System32\\cmd");
+static const TCHAR testPathExtension[] = _T("C:\\Windows\\System32\\cmd.exe");
+
+int TestPathCchAddExtension(int argc, char* argv[])
+{
+       HRESULT status;
+       TCHAR Path[PATHCCH_MAX_CCH];
+       
+       /* Path: no extension, Extension: dot */
+
+       _tcscpy(Path, testPathNoExtension);
+
+       status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot);
+       
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathExtension) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension);
+               return -1;
+       }
+
+       /* Path: no extension, Extension: no dot */
+
+       _tcscpy(Path, testPathNoExtension);
+
+       status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtNoDot);
+       
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathExtension) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension);
+               return -1;
+       }
+
+       /* Path: extension, Extension: dot */
+
+       _tcscpy(Path, testPathExtension);
+
+       status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot);
+       
+       if (status != S_FALSE)
+       {
+               _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathExtension) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension);
+               return -1;
+       }
+
+       /* Path: extension, Extension: no dot */
+
+       _tcscpy(Path, testPathExtension);
+
+       status = PathCchAddExtension(Path, PATHCCH_MAX_CCH, testExtDot);
+       
+       if (status != S_FALSE)
+       {
+               _tprintf(_T("PathCchAddExtension status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathExtension) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathExtension);
+               return -1;
+       }
+
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchAppend.c b/winpr/libwinpr/path/test/TestPathCchAppend.c
new file mode 100644 (file)
index 0000000..76053c3
--- /dev/null
@@ -0,0 +1,93 @@
+
+#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");
+
+int TestPathCchAppend(int argc, char* argv[])
+{
+       HRESULT status;
+       TCHAR Path[PATHCCH_MAX_CCH];
+
+       /* Base Path: Backslash, More Path: No Backslash */
+
+       _tcscpy(Path, testBasePathBackslash);
+
+       status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathNoBackslash);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchAppend status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathOut) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut);
+               return -1;
+       }
+
+       /* Base Path: Backslash, More Path: Backslash */
+
+       _tcscpy(Path, testBasePathBackslash);
+
+       status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathBackslash);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchAppend status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathOut) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut);
+               return -1;
+       }
+
+       /* Base Path: No Backslash, More Path: Backslash */
+
+       _tcscpy(Path, testBasePathNoBackslash);
+
+       status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathBackslash);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchAppend status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathOut) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut);
+               return -1;
+       }
+
+       /* Base Path: No Backslash, More Path: No Backslash */
+
+       _tcscpy(Path, testBasePathNoBackslash);
+
+       status = PathCchAppend(Path, PATHCCH_MAX_CCH, testMorePathNoBackslash);
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchAppend status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathOut) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathOut);
+               return -1;
+       }
+
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchAppendEx.c b/winpr/libwinpr/path/test/TestPathCchAppendEx.c
new file mode 100644 (file)
index 0000000..6f040fa
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchAppendEx(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchCanonicalize.c b/winpr/libwinpr/path/test/TestPathCchCanonicalize.c
new file mode 100644 (file)
index 0000000..7c5b868
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchCanonicalize(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c b/winpr/libwinpr/path/test/TestPathCchCanonicalizeEx.c
new file mode 100644 (file)
index 0000000..13c4d37
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchCanonicalizeEx(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchCombine.c b/winpr/libwinpr/path/test/TestPathCchCombine.c
new file mode 100644 (file)
index 0000000..bfe1e86
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchCombine(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchCombineEx.c b/winpr/libwinpr/path/test/TestPathCchCombineEx.c
new file mode 100644 (file)
index 0000000..5c3d0b8
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchCombineEx(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchFindExtension.c b/winpr/libwinpr/path/test/TestPathCchFindExtension.c
new file mode 100644 (file)
index 0000000..35ce6b5
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchFindExtension(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchIsRoot.c b/winpr/libwinpr/path/test/TestPathCchIsRoot.c
new file mode 100644 (file)
index 0000000..a4e48da
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchIsRoot(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c b/winpr/libwinpr/path/test/TestPathCchRemoveBackslash.c
new file mode 100644 (file)
index 0000000..a7c00ec
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchRemoveBackslash(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c b/winpr/libwinpr/path/test/TestPathCchRemoveBackslashEx.c
new file mode 100644 (file)
index 0000000..903341a
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchRemoveBackslashEx(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveExtension.c b/winpr/libwinpr/path/test/TestPathCchRemoveExtension.c
new file mode 100644 (file)
index 0000000..f52ea8f
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchRemoveExtension(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c b/winpr/libwinpr/path/test/TestPathCchRemoveFileSpec.c
new file mode 100644 (file)
index 0000000..192894e
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchRemoveFileSpec(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchRenameExtension.c b/winpr/libwinpr/path/test/TestPathCchRenameExtension.c
new file mode 100644 (file)
index 0000000..a1816cb
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchRenameExtension(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchSkipRoot.c b/winpr/libwinpr/path/test/TestPathCchSkipRoot.c
new file mode 100644 (file)
index 0000000..4e83ef5
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchSkipRoot(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchStripPrefix.c b/winpr/libwinpr/path/test/TestPathCchStripPrefix.c
new file mode 100644 (file)
index 0000000..7163c13
--- /dev/null
@@ -0,0 +1,61 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+/**
+ * Naming Files, Paths, and Namespaces:
+ * http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247/
+ */
+
+static const TCHAR testPathPrefixFileNamespace[] = _T("\\\\?\\C:\\Program Files\\");
+static const TCHAR testPathNoPrefixFileNamespace[] = _T("C:\\Program Files\\");
+
+static const TCHAR testPathPrefixDeviceNamespace[] = _T("\\\\?\\GLOBALROOT");
+
+int TestPathCchStripPrefix(int argc, char* argv[])
+{
+       HRESULT status;
+       TCHAR Path[PATHCCH_MAX_CCH];
+
+       /* Path with prefix (File Namespace) */
+
+       _tcscpy(Path, testPathPrefixFileNamespace);
+
+       status = PathCchStripPrefix(Path, sizeof(testPathPrefixFileNamespace) / sizeof(TCHAR));
+
+       if (status != S_OK)
+       {
+               _tprintf(_T("PathCchStripPrefix status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathNoPrefixFileNamespace) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathNoPrefixFileNamespace);
+               return -1;
+       }
+
+       /* Path with prefix (Device Namespace) */
+
+       _tcscpy(Path, testPathPrefixDeviceNamespace);
+
+       status = PathCchStripPrefix(Path, sizeof(testPathPrefixDeviceNamespace) / sizeof(TCHAR));
+
+       if (status != S_FALSE)
+       {
+               _tprintf(_T("PathCchStripPrefix status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Path, testPathPrefixDeviceNamespace) != 0)
+       {
+               _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathPrefixDeviceNamespace);
+               return -1;
+       }
+
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathCchStripToRoot.c b/winpr/libwinpr/path/test/TestPathCchStripToRoot.c
new file mode 100644 (file)
index 0000000..cc6e13c
--- /dev/null
@@ -0,0 +1,12 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+int TestPathCchStripToRoot(int argc, char* argv[])
+{
+       return 0;
+}
+
diff --git a/winpr/libwinpr/path/test/TestPathIsUNCEx.c b/winpr/libwinpr/path/test/TestPathIsUNCEx.c
new file mode 100644 (file)
index 0000000..3cea934
--- /dev/null
@@ -0,0 +1,50 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/path.h>
+#include <winpr/tchar.h>
+#include <winpr/winpr.h>
+
+static const TCHAR testServer[] = _T("server\\share\\path\\file");
+static const TCHAR testPathUNC[] = _T("\\\\server\\share\\path\\file");
+static const TCHAR testPathNotUNC[] = _T("C:\\share\\path\\file");
+
+int TestPathIsUNCEx(int argc, char* argv[])
+{
+       BOOL status;
+       LPTSTR Server;
+       TCHAR Path[PATHCCH_MAX_CCH];
+
+       /* Path is UNC */
+
+       _tcscpy(Path, testPathUNC);
+
+       status = PathIsUNCEx(Path, &Server);
+
+       if (!status)
+       {
+               _tprintf(_T("PathIsUNCEx status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       if (_tcscmp(Server, testServer) != 0)
+       {
+               _tprintf(_T("Server Name Mismatch: Actual: %s, Expected: %s\n"), Server, testServer);
+               return -1;
+       }
+
+       /* Path is not UNC */
+
+       _tcscpy(Path, testPathNotUNC);
+
+       status = PathIsUNCEx(Path, &Server);
+
+       if (status)
+       {
+               _tprintf(_T("PathIsUNCEx status: 0x%08X\n"), status);
+               return -1;
+       }
+
+       return 0;
+}
+