summaryrefslogtreecommitdiffstats
path: root/winpr/libwinpr/utils/test/TestBufferPool.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/utils/test/TestBufferPool.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 'winpr/libwinpr/utils/test/TestBufferPool.c')
-rw-r--r--winpr/libwinpr/utils/test/TestBufferPool.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/winpr/libwinpr/utils/test/TestBufferPool.c b/winpr/libwinpr/utils/test/TestBufferPool.c
new file mode 100644
index 0000000..d954caa
--- /dev/null
+++ b/winpr/libwinpr/utils/test/TestBufferPool.c
@@ -0,0 +1,68 @@
+
+#include <winpr/crt.h>
+#include <winpr/stream.h>
+#include <winpr/collections.h>
+
+int TestBufferPool(int argc, char* argv[])
+{
+ DWORD PoolSize = 0;
+ int BufferSize = 0;
+ wBufferPool* pool = NULL;
+ BYTE* Buffers[10];
+ int DefaultSize = 1234;
+
+ WINPR_UNUSED(argc);
+ WINPR_UNUSED(argv);
+
+ pool = BufferPool_New(TRUE, -1, 16);
+ if (!pool)
+ return -1;
+
+ Buffers[0] = BufferPool_Take(pool, DefaultSize);
+ Buffers[1] = BufferPool_Take(pool, DefaultSize);
+ Buffers[2] = BufferPool_Take(pool, 2048);
+ if (!Buffers[0] || !Buffers[1] || !Buffers[2])
+ return -1;
+
+ BufferSize = BufferPool_GetBufferSize(pool, Buffers[0]);
+
+ if (BufferSize != DefaultSize)
+ {
+ printf("BufferPool_GetBufferSize failure: Actual: %d Expected: %" PRIu32 "\n", BufferSize,
+ DefaultSize);
+ return -1;
+ }
+
+ BufferSize = BufferPool_GetBufferSize(pool, Buffers[1]);
+
+ if (BufferSize != DefaultSize)
+ {
+ printf("BufferPool_GetBufferSize failure: Actual: %d Expected: %" PRIu32 "\n", BufferSize,
+ DefaultSize);
+ return -1;
+ }
+
+ BufferSize = BufferPool_GetBufferSize(pool, Buffers[2]);
+
+ if (BufferSize != 2048)
+ {
+ printf("BufferPool_GetBufferSize failure: Actual: %d Expected: 2048\n", BufferSize);
+ return -1;
+ }
+
+ BufferPool_Return(pool, Buffers[1]);
+
+ PoolSize = BufferPool_GetPoolSize(pool);
+
+ if (PoolSize != 2)
+ {
+ printf("BufferPool_GetPoolSize failure: Actual: %" PRIu32 " Expected: 2\n", PoolSize);
+ return -1;
+ }
+
+ BufferPool_Clear(pool);
+
+ BufferPool_Free(pool);
+
+ return 0;
+}