From 3e96b85b22de8b5b4444ce67eed90d6a2182b2bc Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 27 Aug 2012 15:02:13 -0700 Subject: [PATCH] Implement pool test. --- libguac/tests/client/layer_pool.c | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/libguac/tests/client/layer_pool.c b/libguac/tests/client/layer_pool.c index bccf125c..88cf8785 100644 --- a/libguac/tests/client/layer_pool.c +++ b/libguac/tests/client/layer_pool.c @@ -35,9 +35,51 @@ * * ***** END LICENSE BLOCK ***** */ +#include + +#include "client.h" #include "client_suite.h" void test_layer_pool() { + guac_client* client; + + int i; + int seen[GUAC_BUFFER_POOL_INITIAL_SIZE] = {0}; + + guac_layer* layer; + + /* Get client */ + client = guac_client_alloc(); + CU_ASSERT_PTR_NOT_NULL_FATAL(client); + + /* Fill pool */ + for (i=0; iindex > 0); + CU_ASSERT(layer->index < GUAC_BUFFER_POOL_INITIAL_SIZE); + + /* This should be a layer we have not seen yet */ + CU_ASSERT_FALSE(seen[layer->index]); + seen[layer->index] = 1; + + guac_client_free_layer(client, layer); + + } + + /* Now that pool is filled, we should get a previously seen layer */ + layer = guac_client_alloc_layer(client); + + CU_ASSERT(layer->index > 0); + CU_ASSERT(layer->index < GUAC_BUFFER_POOL_INITIAL_SIZE); + CU_ASSERT_TRUE(seen[layer->index]); + + /* Free client */ + guac_client_free(client); + }