summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-list_util.c29
-rw-r--r--tests/test-symtab.c23
-rw-r--r--tests/test-vector.c88
3 files changed, 71 insertions, 69 deletions
diff --git a/tests/test-list_util.c b/tests/test-list_util.c
index fc81a562..c4e88502 100644
--- a/tests/test-list_util.c
+++ b/tests/test-list_util.c
@@ -1,4 +1,5 @@
#include <zebra.h>
+#include "misc.h"
#include <list_util.h>
#include <string.h>
@@ -20,10 +21,10 @@ static void test_ddl(void);
} while (0)
static void
-test_assert_fail(const char* true, const char* message, const char* func,
+test_assert_fail(const char* truth, const char* message, const char* func,
int line)
{
- printf("*** %s %d: (%s) not true: %s\n", func, line, true, message) ;
+ printf("*** %s %d: (%s) not true: %s\n", func, line, truth, message) ;
} ;
@@ -253,12 +254,12 @@ test_ssl(void)
this = base ;
first = base->next ;
ret = ssl_del(base, this, next) ;
- test_assert(ret == 0, "ssl_del did not return 0") ;
+ test_assert(ret == true, "ssl_del did not return true") ;
test_assert(first == base, "ssl_del of first item failed") ;
this = other->base ;
ret = ssl_del(other->base, this, other_next) ;
- test_assert(ret == 0, "ssl_del did not return 0") ;
+ test_assert(ret == true, "ssl_del did not return true") ;
test_assert(first == other->base, "ssl_del of first item failed") ;
printf("\n") ;
@@ -271,9 +272,9 @@ test_ssl(void)
*/
printf(" Deleting arbitrary items") ;
ret = ssl_del(base, del, next) ;
- test_assert(ret == 0, "ssl_del did not return 0") ;
+ test_assert(ret == true, "ssl_del did not return true") ;
ret = ssl_del(ssl_parent.base, other_del, other_next) ;
- test_assert(ret == 0, "ssl_del did not return 0") ;
+ test_assert(ret == true, "ssl_del did not return true") ;
printf("\n") ;
/* Deletion of items from arbitrary place in list
@@ -282,9 +283,9 @@ test_ssl(void)
*/
printf(" Deleting non-existant items") ;
ret = ssl_del(base, &dummy, next) ;
- test_assert(ret == -1, "ssl_del did not return -1") ;
+ test_assert(ret == false, "ssl_del did not return false") ;
ret = ssl_del(other->base, &dummy, other_next) ;
- test_assert(ret == -1, "ssl_del did not return -1") ;
+ test_assert(ret == false, "ssl_del did not return false") ;
printf("\n") ;
/* Deletion of NULL items
@@ -296,10 +297,10 @@ test_ssl(void)
this = NULL ;
ret = ssl_del(base, this, next) ;
- test_assert(ret == 0, "ssl_del did not return 0") ;
+ test_assert(ret == false, "ssl_del did not return false") ;
ret = ssl_del(ssl_parent.base, this, other_next) ;
- test_assert(ret == 0, "ssl_del did not return 0") ;
+ test_assert(ret == false, "ssl_del did not return false") ;
printf("\n") ;
@@ -567,21 +568,21 @@ test_ssl(void)
test_assert(other->base == NULL, "ssl_del of first and only item failed") ;
ret = ssl_del(base, del, next) ;
- test_assert(ret == -1, "ssl_del did not return -1") ;
+ test_assert(ret == false, "ssl_del did not return false") ;
test_assert(base == NULL, "ssl_del on empty list") ;
ret = ssl_del(other->base, other_del, other_next) ;
- test_assert(ret == -1, "ssl_del did not return -1") ;
+ test_assert(ret == false, "ssl_del did not return false") ;
test_assert(other->base == NULL, "ssl_del on empty list") ;
this = NULL ;
ret = ssl_del(base, this, next) ;
- test_assert(ret == 0, "ssl_del did not return 0") ;
+ test_assert(ret == false, "ssl_del did not return false") ;
test_assert(base == NULL, "ssl_del on empty list") ;
ret = ssl_del(other->base, this, other_next) ;
- test_assert(ret == 0, "ssl_del did not return 0") ;
+ test_assert(ret == false, "ssl_del did not return false") ;
test_assert(other->base == NULL, "ssl_del on empty list") ;
printf("\n") ;
diff --git a/tests/test-symtab.c b/tests/test-symtab.c
index ed83e607..a4b0bcf2 100644
--- a/tests/test-symtab.c
+++ b/tests/test-symtab.c
@@ -56,24 +56,25 @@ test_symbol_table_init_new(void)
assert_true(table != NULL, "table == NULL");
/* expect to not find */
- sym = symbol_lookup(table, name, 0);
+ sym = symbol_lookup(table, name, no_add);
assert_true(sym == NULL, "sym != NULL");
/* add */
- sym = symbol_lookup(table, name, 1);
+ sym = symbol_lookup(table, name, add);
symbol_set_value(sym, value);
assert_true(sym != NULL, "sym == NULL");
- assert_true(strcmp(symbol_get_name(sym), name) == 0, "strcmp(symbol_get_name(sym), name) != 0");
+ assert_true(strcmp(symbol_get_name(sym), name) == 0,
+ "strcmp(symbol_get_name(sym), name) != 0");
/* find */
- sym2 = symbol_lookup(table, name, 0);
+ sym2 = symbol_lookup(table, name, no_add);
assert_true(sym == sym2, "sym != sym2");
assert_true(symbol_get_value(sym) == value, "symbol_get_value(sym) != value");
old_value = symbol_delete(sym);
assert_true(value == old_value, "value != old_value");
- while ((old_value = symbol_table_ream(table, 1)) != NULL)
+ while ((old_value = symbol_table_ream(table, keep_it)) != NULL)
{
}
@@ -98,7 +99,7 @@ test_symbol_table_lookup(void)
for (i = 0; i < len; ++i)
{
sprintf(buf, "%d-name", i);
- sym = symbol_lookup(table, buf, 1);
+ sym = symbol_lookup(table, buf, add);
assert_true(sym != NULL, "add: sym == NULL");
assert_true(strcmp(symbol_get_name(sym), buf) == 0,
"strcmp(symbol_get_name(sym), buf) != 0");
@@ -114,7 +115,7 @@ test_symbol_table_lookup(void)
for (i = 0; i < len; ++i)
{
sprintf(buf, "%d-name", i);
- sym = symbol_lookup(table, buf, 0);
+ sym = symbol_lookup(table, buf, no_add);
assert_true(sym != NULL, "find: sym == NULL");
assert_true(strcmp(symbol_get_name(sym), buf) == 0,
"strcmp(symbol_get_name(sym), buf) != 0");
@@ -162,12 +163,12 @@ test_call_back(void)
/* add */
symbol_table_set_value_call_back(table, call_back_function_set);
- sym = symbol_lookup(table, name, 1);
+ sym = symbol_lookup(table, name, add);
symbol_set_value(sym, value);
/* change */
symbol_table_set_value_call_back(table, call_back_function_change);
- sym = symbol_lookup(table, name, 1);
+ sym = symbol_lookup(table, name, add);
symbol_set_value(sym, new_value);
/* delete */
@@ -216,7 +217,7 @@ test_ref(void)
table = symbol_table_init_new(table, NULL, 0, 0, NULL, NULL);
/* add */
- sym = symbol_lookup(table, name, 1);
+ sym = symbol_lookup(table, name, add);
symbol_set_value(sym, value);
/* create references, in reverse order so that walk in order */
@@ -272,7 +273,7 @@ test_ref_heavy(void)
table = symbol_table_init_new(table, NULL, 0, 0, NULL, NULL);
/* add */
- sym = symbol_lookup(table, name, 1);
+ sym = symbol_lookup(table, name, add);
symbol_set_value(sym, value);
/* create references, in reverse order so that walk in order */
diff --git a/tests/test-vector.c b/tests/test-vector.c
index f3b314db..7d2121cc 100644
--- a/tests/test-vector.c
+++ b/tests/test-vector.c
@@ -424,12 +424,12 @@ void
do_test_insert(const int rider)
{
vector v = NULL;
- const vector_index len = 100;
- const vector_index ins = 50;
- vector_index i;
+ const vector_length_t len = 100;
+ const vector_index_t ins = 50;
+ vector_index_t i;
char buf[10];
- vector_index check_end = len + 1;
- vector_index check_ins = ins;
+ vector_length_t check_end = len + 1;
+ vector_index_t check_ins = ins;
int check_shift = 1;
switch(rider)
@@ -563,9 +563,9 @@ test_vector_bsearch(void)
const int len = 2000;
char buf[20];
char target[20];
- vector_index target_index = 0;
+ vector_index_t target_index = 0;
int result;
- vector_index index;
+ vector_index_t index;
printf("test_vector_bsearch\n");
@@ -614,14 +614,14 @@ void
do_test_move_item_here(const int rider)
{
vector v = NULL;
- const vector_index len = 100;
- const vector_index ins = 50;
- const vector_index src = 70;
- vector_index i;
+ const vector_length_t len = 100;
+ const vector_index_t ins = 50;
+ const vector_index_t src = 70;
+ vector_index_t i;
char buf[10];
- vector_index check_dest = 0;
- vector_index check_src = 0;
- vector_index check_end = 0;
+ vector_index_t check_dest = 0;
+ vector_index_t check_src = 0;
+ vector_index_t check_end = 0;
int check_shift = 0;
p_vector_item dest_item = NULL;
@@ -711,10 +711,10 @@ void
test_vector_part_reverse(void)
{
vector v = NULL;
- const vector_index len = 100;
- const vector_index rstart = 50;
- const vector_index rstop = 70;
- vector_index i;
+ const vector_length_t len = 100;
+ const vector_index_t rstart = 50;
+ const vector_index_t rstop = 70;
+ vector_index_t i;
char buf[10];
printf("test_vector_part_reverse\n");
@@ -770,8 +770,8 @@ test_vector_copy_here(void)
{
vector v1 = NULL;
vector v2 = NULL;
- vector_index i;
- const vector_index len = 100;
+ vector_index_t i;
+ const vector_length_t len = 100;
char buf[10];
printf("test_vector_copy_here\n");
@@ -809,8 +809,8 @@ test_vector_move_here(void)
{
vector v1 = NULL;
vector v2 = NULL;
- vector_index i;
- const vector_index len = 100;
+ vector_index_t i;
+ const vector_length_t len = 100;
char buf[10];
printf("test_vector_move_here\n");
@@ -851,8 +851,8 @@ test_vector_copy_append(void)
{
vector v1 = NULL;
vector v2 = NULL;
- vector_index i;
- const vector_index len = 100;
+ vector_index_t i;
+ const vector_length_t len = 100;
char buf[10];
printf("test_vector_copy_append\n");
@@ -900,8 +900,8 @@ test_vector_move_append(void)
{
vector v1 = NULL;
vector v2 = NULL;
- vector_index i;
- const vector_index len = 100;
+ vector_index_t i;
+ const vector_length_t len = 100;
char buf[10];
printf("test_vector_move_append\n");
@@ -949,10 +949,10 @@ void
test_vector_insert(void)
{
vector v = NULL;
- vector_index i;
- const vector_index len = 100;
- const vector_index istart = 50;
- const vector_index istop = 70;
+ vector_index_t i;
+ const vector_length_t len = 100;
+ const vector_index_t istart = 50;
+ const vector_index_t istop = 70;
char buf[10];
printf("test_vector_insert\n");
@@ -1004,10 +1004,10 @@ void
test_vector_delete(void)
{
vector v = NULL;
- vector_index i;
- const vector_index len = 100;
- const vector_index dstart = 50;
- const vector_index dstop = 70;
+ vector_index_t i;
+ const vector_length_t len = 100;
+ const vector_index_t dstart = 50;
+ const vector_index_t dstop = 70;
char buf[10];
printf("test_vector_delete\n");
@@ -1060,9 +1060,9 @@ void
test_vector_discard(void)
{
vector v = NULL;
- vector_index i;
- const vector_index len = 100;
- const vector_index dstart = 50;
+ vector_index_t i;
+ const vector_length_t len = 100;
+ const vector_index_t dstart = 50;
char buf[10];
printf("test_vector_discard\n");
@@ -1110,12 +1110,12 @@ test_vector_sak(void)
vector v1 = NULL;
vector v2 = NULL;
vector v3 = NULL;
- vector_index i;
- const vector_index len = 100;
- const vector_index sstart = 60;
- const vector_index sstop = 70;
- const vector_index dstart = 40;
- const vector_index dstop = 50;
+ vector_index_t i;
+ const vector_length_t len = 100;
+ const vector_index_t sstart = 60;
+ const vector_index_t sstop = 70;
+ const vector_index_t dstart = 40;
+ const vector_index_t dstop = 50;
char buf[10];
printf("test_vector_sak\n");
@@ -1132,7 +1132,7 @@ test_vector_sak(void)
}
v1 = vector_sak(1, v1, v2, dstart, dstop - dstart,
- v3, sstart, sstop - sstart, 0);
+ v3, sstart, sstop - sstart, 0);
assert_true(v1 != NULL, "v1 == NULL");
assert_true(vector_end(v1) == (dstop - dstart),