diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-list_util.c | 4 | ||||
-rw-r--r-- | tests/test-symtab.c | 23 | ||||
-rw-r--r-- | tests/test-vector.c | 88 |
3 files changed, 58 insertions, 57 deletions
diff --git a/tests/test-list_util.c b/tests/test-list_util.c index fc81a562..a3c6ad59 100644 --- a/tests/test-list_util.c +++ b/tests/test-list_util.c @@ -20,10 +20,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) ; } ; 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 b54ae9f9..a73e5637 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), |