From c8024b10e05cd7245a7da83b4b6ae03ab22616c3 Mon Sep 17 00:00:00 2001 From: yuqing Date: Fri, 25 Dec 2015 16:32:04 +0800 Subject: [PATCH] test_skiplist.c --- src/tests/test_skiplist.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/tests/test_skiplist.c b/src/tests/test_skiplist.c index cc65491..b108dd8 100644 --- a/src/tests/test_skiplist.c +++ b/src/tests/test_skiplist.c @@ -66,6 +66,7 @@ static void test_delete() int i; int64_t start_time; int64_t end_time; + void *value; start_time = get_current_time_ms(); for (i=1; i<=COUNT; i++) { @@ -73,6 +74,21 @@ static void test_delete() } end_time = get_current_time_ms(); printf("delete time used: %"PRId64" ms\n", end_time - start_time); + + start_time = get_current_time_ms(); + for (i=1; i<=COUNT; i++) { + value = skiplist_find(&sl, &i); + assert(value == NULL); + } + end_time = get_current_time_ms(); + printf("find after delete time used: %"PRId64" ms\n", end_time - start_time); + + i = 0; + skiplist_iterator(&sl, &iterator); + while ((value=skiplist_next(&iterator)) != NULL) { + i++; + } + assert(i==0); } int main(int argc, char *argv[]) @@ -82,9 +98,6 @@ int main(int argc, char *argv[]) int index1; int index2; int result; - int64_t start_time; - int64_t end_time; - void *value; log_init(); numbers = (int *)malloc(sizeof(int) * COUNT); @@ -113,21 +126,6 @@ int main(int argc, char *argv[]) test_delete(); - start_time = get_current_time_ms(); - for (i=1; i<=COUNT; i++) { - value = skiplist_find(&sl, &i); - assert(value == NULL); - } - end_time = get_current_time_ms(); - printf("find after delete time used: %"PRId64" ms\n", end_time - start_time); - - i = 0; - skiplist_iterator(&sl, &iterator); - while ((value=skiplist_next(&iterator)) != NULL) { - i++; - } - assert(i==0); - test_insert(); test_delete();