summaryrefslogtreecommitdiffstats
path: root/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.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/environment/test/TestEnvironmentGetEnvironmentStrings.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/environment/test/TestEnvironmentGetEnvironmentStrings.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c b/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c
new file mode 100644
index 0000000..c596399
--- /dev/null
+++ b/winpr/libwinpr/environment/test/TestEnvironmentGetEnvironmentStrings.c
@@ -0,0 +1,43 @@
+
+#include <stdio.h>
+#include <winpr/crt.h>
+#include <winpr/tchar.h>
+#include <winpr/environment.h>
+
+int TestEnvironmentGetEnvironmentStrings(int argc, char* argv[])
+{
+ int r = -1;
+ TCHAR* p = NULL;
+ size_t length = 0;
+ LPTCH lpszEnvironmentBlock = NULL;
+
+ WINPR_UNUSED(argc);
+ WINPR_UNUSED(argv);
+
+ lpszEnvironmentBlock = GetEnvironmentStrings();
+
+ p = lpszEnvironmentBlock;
+
+ while (p[0] && p[1])
+ {
+ const int rc = _sntprintf(NULL, 0, _T("%s\n"), p);
+ if (rc < 1)
+ {
+ _tprintf(_T("test failed: return %d\n"), rc);
+ goto fail;
+ }
+ length = _tcslen(p);
+ if (length != (size_t)(rc - 1))
+ {
+ _tprintf(_T("test failed: length %") _T(PRIuz) _T(" != %d [%s]\n"), length, rc - 1, p);
+ goto fail;
+ }
+ p += (length + 1);
+ }
+
+ r = 0;
+fail:
+ FreeEnvironmentStrings(lpszEnvironmentBlock);
+
+ return r;
+}