diff options
author | cebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru> | 2008-09-22 01:08:41 +0400 |
---|---|---|
committer | cebka@mailsupport.rambler.ru <cebka@mailsupport.rambler.ru> | 2008-09-22 01:08:41 +0400 |
commit | 2b65ae425b9dca345bea158471b358d3c17b9704 (patch) | |
tree | 24c7a23ae4297547f7293db0b1b95b89bfb0eae5 /test/rspamd_mem_pool_test.c | |
parent | 82e2d7ab53eb60bdc52d2e736b097d68d489aa9c (diff) | |
download | rspamd-2b65ae425b9dca345bea158471b358d3c17b9704.tar.gz rspamd-2b65ae425b9dca345bea158471b358d3c17b9704.zip |
* Optimize memory pools allocator
* Add test case for memory pools
Diffstat (limited to 'test/rspamd_mem_pool_test.c')
-rw-r--r-- | test/rspamd_mem_pool_test.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/rspamd_mem_pool_test.c b/test/rspamd_mem_pool_test.c new file mode 100644 index 000000000..5b2bf3721 --- /dev/null +++ b/test/rspamd_mem_pool_test.c @@ -0,0 +1,27 @@ +#include "../mem_pool.h" +#include "tests.h" + +#include <stdio.h> +#include <glib.h> + +#define TEST_BUF "test bufffer" +#define TEST2_BUF "test bufffertest bufffer" + +void +rspamd_mem_pool_test_func () +{ + memory_pool_t *pool; + char *tmp, *tmp2; + + pool = memory_pool_new (sizeof (TEST_BUF)); + tmp = memory_pool_alloc (pool, sizeof (TEST_BUF)); + tmp2 = memory_pool_alloc (pool, sizeof (TEST_BUF) * 2); + + snprintf (tmp, sizeof (TEST_BUF), "%s", TEST_BUF); + snprintf (tmp2, sizeof (TEST_BUF) * 2, "%s", TEST2_BUF); + + g_assert (strncmp (tmp, TEST_BUF, sizeof (TEST_BUF)) == 0); + g_assert (strncmp (tmp2, TEST2_BUF, sizeof (TEST2_BUF)) == 0); + + memory_pool_delete (pool); +} |