2013-08-15 08:01:42 +04:00
|
|
|
|
|
|
|
#include <winpr/crt.h>
|
|
|
|
#include <winpr/stream.h>
|
|
|
|
#include <winpr/collections.h>
|
|
|
|
|
|
|
|
int TestBufferPool(int argc, char* argv[])
|
|
|
|
{
|
2013-09-17 01:59:29 +04:00
|
|
|
DWORD PoolSize;
|
2013-08-15 08:01:42 +04:00
|
|
|
int BufferSize;
|
|
|
|
wBufferPool* pool;
|
|
|
|
BYTE* Buffers[10];
|
2019-02-07 16:37:23 +03:00
|
|
|
int DefaultSize = 1234;
|
2013-08-15 08:01:42 +04:00
|
|
|
|
2013-09-17 01:59:29 +04:00
|
|
|
pool = BufferPool_New(TRUE, -1, 16);
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!pool)
|
|
|
|
return -1;
|
2013-08-15 08:01:42 +04:00
|
|
|
|
2013-09-17 01:59:29 +04:00
|
|
|
Buffers[0] = BufferPool_Take(pool, DefaultSize);
|
|
|
|
Buffers[1] = BufferPool_Take(pool, DefaultSize);
|
2013-08-15 08:01:42 +04:00
|
|
|
Buffers[2] = BufferPool_Take(pool, 2048);
|
2015-05-18 12:28:00 +03:00
|
|
|
if (!Buffers[0] || !Buffers[1] || !Buffers[2])
|
|
|
|
return -1;
|
2013-08-15 08:01:42 +04:00
|
|
|
|
|
|
|
BufferSize = BufferPool_GetBufferSize(pool, Buffers[0]);
|
|
|
|
|
|
|
|
if (BufferSize != DefaultSize)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("BufferPool_GetBufferSize failure: Actual: %d Expected: %" PRIu32 "\n", BufferSize,
|
|
|
|
DefaultSize);
|
2013-08-15 08:01:42 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BufferSize = BufferPool_GetBufferSize(pool, Buffers[1]);
|
|
|
|
|
|
|
|
if (BufferSize != DefaultSize)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("BufferPool_GetBufferSize failure: Actual: %d Expected: %" PRIu32 "\n", BufferSize,
|
|
|
|
DefaultSize);
|
2013-08-15 08:01:42 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BufferSize = BufferPool_GetBufferSize(pool, Buffers[2]);
|
|
|
|
|
|
|
|
if (BufferSize != 2048)
|
|
|
|
{
|
2016-12-14 00:47:08 +03:00
|
|
|
printf("BufferPool_GetBufferSize failure: Actual: %d Expected: 2048\n", BufferSize);
|
2013-08-15 08:01:42 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BufferPool_Return(pool, Buffers[1]);
|
|
|
|
|
|
|
|
PoolSize = BufferPool_GetPoolSize(pool);
|
|
|
|
|
|
|
|
if (PoolSize != 2)
|
|
|
|
{
|
2019-11-06 17:24:51 +03:00
|
|
|
printf("BufferPool_GetPoolSize failure: Actual: %" PRIu32 " Expected: 2\n", PoolSize);
|
2013-08-15 08:01:42 +04:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
BufferPool_Clear(pool);
|
|
|
|
|
|
|
|
BufferPool_Free(pool);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|