summaryrefslogtreecommitdiffstats
path: root/winpr/libwinpr/clipboard/test/TestUri.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
commita9bcc81f821d7c66f623779fa5147e728eb3c388 (patch)
tree98676963bcdd537ae5908a067a8eb110b93486a6 /winpr/libwinpr/clipboard/test/TestUri.c
parentInitial commit. (diff)
downloadfreerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.tar.xz
freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.zip
Adding upstream version 3.3.0+dfsg1.upstream/3.3.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--winpr/libwinpr/clipboard/test/TestUri.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/winpr/libwinpr/clipboard/test/TestUri.c b/winpr/libwinpr/clipboard/test/TestUri.c
new file mode 100644
index 0000000..c1cccd3
--- /dev/null
+++ b/winpr/libwinpr/clipboard/test/TestUri.c
@@ -0,0 +1,69 @@
+
+#include <stdio.h>
+#include <string.h>
+#include <memory.h>
+#include <stdlib.h>
+#include <winpr/winpr.h>
+#include "winpr/wlog.h"
+
+#include "../clipboard.h"
+
+#define WINPR_TAG(tag) "com.winpr." tag
+#define TAG WINPR_TAG("clipboard.posix")
+
+int TestUri(int argc, char* argv[])
+{
+ int nRet = 0;
+ const char* input[] = { /*uri, file or NULL*/
+ "file://root/a.txt",
+ NULL,
+ "file:a.txt",
+ NULL,
+ "file:///c:/windows/a.txt",
+ "c:/windows/a.txt",
+ "file:c:/windows/a.txt",
+ "c:/windows/a.txt",
+ "file:c|/windows/a.txt",
+ "c:/windows/a.txt",
+ "file:///root/a.txt",
+ "/root/a.txt",
+ "file:/root/a.txt",
+ "/root/a.txt"
+ };
+
+ const size_t nLen = ARRAYSIZE(input);
+
+ WINPR_UNUSED(argc);
+ WINPR_UNUSED(argv);
+
+ printf("input length:%" PRIuz "\n", nLen / 2);
+
+ for (size_t i = 0; i < nLen; i += 2)
+ {
+ const char* in = input[i];
+ const char* cmp = input[i + 1];
+ int bTest = 0;
+ char* name = parse_uri_to_local_file(in, strlen(in));
+ if (name)
+ {
+ bTest = !strcmp(name, cmp);
+ if (!bTest)
+ {
+ printf("Test error: input: %s; Expected value: %s; output: %s\n", in, cmp, name);
+ nRet++;
+ }
+ free(name);
+ }
+ else
+ {
+ if (cmp)
+ {
+ printf("Test error: input: %s; Expected value: %s; output: %s\n", in, cmp, name);
+ nRet++;
+ }
+ }
+ }
+
+ printf("TestUri return value: %d\n", nRet);
+ return nRet;
+}