aboutsummaryrefslogtreecommitdiffstats
path: root/test/rspamd_heap_test.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-10 13:43:47 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-10 13:44:07 +0100
commitbb517fb0e1a031fbee9e25632ada43e371b4b42a (patch)
treebc11034a525c266257538c097d0e374c61449695 /test/rspamd_heap_test.c
parentdb6676684a4a8f961e8ada8f627d4b178e0e1669 (diff)
downloadrspamd-bb517fb0e1a031fbee9e25632ada43e371b4b42a.tar.gz
rspamd-bb517fb0e1a031fbee9e25632ada43e371b4b42a.zip
[Minor] Improve tests for heap
Diffstat (limited to 'test/rspamd_heap_test.c')
-rw-r--r--test/rspamd_heap_test.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/test/rspamd_heap_test.c b/test/rspamd_heap_test.c
index db508fcb7..634c648d2 100644
--- a/test/rspamd_heap_test.c
+++ b/test/rspamd_heap_test.c
@@ -19,6 +19,9 @@
#include "heap.h"
#include "ottery.h"
+static const niter = 100500;
+static const nrem = 100;
+
static inline
struct rspamd_min_heap_elt *
new_elt (guint pri)
@@ -54,14 +57,19 @@ rspamd_heap_test_func (void)
rspamd_min_heap_destroy (heap);
heap = rspamd_min_heap_create (128);
- for (i = 0; i < 100500; i ++) {
+ for (i = 0; i < niter; i ++) {
elt = new_elt (ottery_rand_uint32 () % G_MAXINT32 + 1);
rspamd_min_heap_push (heap, elt);
}
+ for (i = 0; i < nrem; i ++) {
+ elt = rspamd_min_heap_index (heap, ottery_rand_uint32 () % niter);
+ rspamd_min_heap_remove_elt (heap, elt);
+ }
+
prev = 0;
- for (i = 0; i < 100500; i ++) {
+ for (i = 0; i < niter - nrem; i ++) {
elt = rspamd_min_heap_pop (heap);
if (prev != 0) {