~ubuntu-branches/ubuntu/vivid/freerdp/vivid

« back to all changes in this revision

Viewing changes to winpr/libwinpr/path/test/TestPathCchAddBackslash.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-11-11 12:20:50 UTC
  • mfrom: (1.2.5)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20141111122050-7z628f4ab38qxad5
Tags: upstream-1.1.0~git20140921.1.440916e+dfsg1
ImportĀ upstreamĀ versionĀ 1.1.0~git20140921.1.440916e+dfsg1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
8
static const TCHAR testPathBackslash[] = _T("C:\\Program Files\\");
 
9
static const TCHAR testPathNoBackslash[] = _T("C:\\Program Files");
 
10
 
 
11
int TestPathCchAddBackslash(int argc, char* argv[])
 
12
{
 
13
        HRESULT status;
 
14
        TCHAR Path[PATHCCH_MAX_CCH];
 
15
 
 
16
        _tcscpy(Path, testPathNoBackslash);
 
17
 
 
18
        /* Add a backslash to a path without a trailing backslash, expect S_OK */
 
19
 
 
20
        status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH);
 
21
 
 
22
        if (status != S_OK)
 
23
        {
 
24
                _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), (int) status);
 
25
                return -1;
 
26
        }
 
27
 
 
28
        if (_tcscmp(Path, testPathBackslash) != 0)
 
29
        {
 
30
                _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
 
31
                return -1;
 
32
        }
 
33
 
 
34
        /* Add a backslash to a path with a trailing backslash, expect S_FALSE */
 
35
 
 
36
        _tcscpy(Path, testPathBackslash);
 
37
 
 
38
        status = PathCchAddBackslash(Path, PATHCCH_MAX_CCH);
 
39
 
 
40
        if (status != S_FALSE)
 
41
        {
 
42
                _tprintf(_T("PathCchAddBackslash status: 0x%08X\n"), (int) status);
 
43
                return -1;
 
44
        }
 
45
 
 
46
        if (_tcscmp(Path, testPathBackslash) != 0)
 
47
        {
 
48
                _tprintf(_T("Path Mismatch: Actual: %s, Expected: %s\n"), Path, testPathBackslash);
 
49
                return -1;
 
50
        }
 
51
 
 
52
        return 0;
 
53
}
 
54