FreeRDP
TestUri.c
1
2
#include <stdio.h>
3
#include <string.h>
4
#include <memory.h>
5
#include <stdlib.h>
6
#include <winpr/winpr.h>
7
#include "winpr/wlog.h"
8
9
#include "../clipboard.h"
10
11
#define WINPR_TAG(tag) "com.winpr."
tag
12
#define TAG WINPR_TAG("clipboard.posix"
)
13
14
int
TestUri(
int
argc,
char
* argv[])
15
{
16
int
nRet = 0;
17
const
char
* input[] = {
/*uri, file or NULL*/
18
"file://root/a.txt"
,
19
NULL,
20
"file:a.txt"
,
21
NULL,
22
"file:///c:/windows/a.txt"
,
23
"c:/windows/a.txt"
,
24
"file:c:/windows/a.txt"
,
25
"c:/windows/a.txt"
,
26
"file:c|/windows/a.txt"
,
27
"c:/windows/a.txt"
,
28
"file:///root/a.txt"
,
29
"/root/a.txt"
,
30
"file:/root/a.txt"
,
31
"/root/a.txt"
32
};
33
34
const
size_t
nLen = ARRAYSIZE(input);
35
36
WINPR_UNUSED(argc);
37
WINPR_UNUSED(argv);
38
39
printf(
"input length:%"
PRIuz
"\n"
, nLen / 2);
40
41
for
(
size_t
i = 0; i < nLen; i += 2)
42
{
43
const
char
* in = input[i];
44
const
char
* cmp = input[i + 1];
45
int
bTest = 0;
46
char
* name = parse_uri_to_local_file(in, strlen(in));
47
if
(name && cmp)
48
{
49
bTest = !strcmp(name, cmp);
50
if
(!bTest)
51
{
52
printf(
"Test error: input: %s; Expected value: %s; output: %s\n"
, in, cmp, name);
53
nRet++;
54
}
55
free(name);
56
}
57
else
58
{
59
if
(cmp)
60
{
61
printf(
"Test error: input: %s; Expected value: %s; output: %s\n"
, in, cmp, name);
62
nRet++;
63
}
64
}
65
}
66
67
printf(
"TestUri return value: %d\n"
, nRet);
68
return
nRet;
69
}
winpr
libwinpr
clipboard
test
TestUri.c
Generated by
1.9.1