possible. "gcov -b" should report 100% coverage of lines and
branches in llx.c and llx.h. "valgrind --leak-check=yes
--show-reachable=yes" should give a clean report.
possible. "gcov -b" should report 100% coverage of lines and
branches in llx.c and llx.h. "valgrind --leak-check=yes
--show-reachable=yes" should give a clean report.
}
/* If OK is not true, prints a message about failure on the
current source file and the given LINE and terminates. */
static void
}
/* If OK is not true, prints a message about failure on the
current source file and the given LINE and terminates. */
static void
{
printf ("Check failed in %s test at %s, line %d\n",
test_name, __FILE__, line);
{
printf ("Check failed in %s test at %s, line %d\n",
test_name, __FILE__, line);
AUX for each element in LIST. */
static void UNUSED
print_pred (struct llx_list *list,
AUX for each element in LIST. */
static void UNUSED
print_pred (struct llx_list *list,
printf (" %d", predicate (x, aux));
printf ("\n");
}
/* Prints the CNT numbers in VALUES. */
static void UNUSED
printf (" %d", predicate (x, aux));
printf ("\n");
}
/* Prints the CNT numbers in VALUES. */
static void UNUSED
/* Compares the `x' values in A and B and returns a strcmp-type
return value. Verifies that AUX points to aux_data. */
static int
/* Compares the `x' values in A and B and returns a strcmp-type
return value. Verifies that AUX points to aux_data. */
static int
/* Returns true if the bit in *PATTERN indicated by `x in
*ELEMENT is set, false otherwise. */
static bool
/* Returns true if the bit in *PATTERN indicated by `x in
*ELEMENT is set, false otherwise. */
static bool
{
*elemp = xnmalloc (n + 1, sizeof *elemp);
(*elemp)[n] = llx_null (list);
}
{
*elemp = xnmalloc (n + 1, sizeof *elemp);
(*elemp)[n] = llx_null (list);
}
if (values != NULL)
*values = xnmalloc (n, sizeof *values);
}
/* Copies the CNT values of `x' from LIST into VALUES[]. */
static void
if (values != NULL)
*values = xnmalloc (n, sizeof *values);
}
/* Copies the CNT values of `x' from LIST into VALUES[]. */
static void
{
size_t i;
allocate_elements (n, list, elems, elemp, values);
{
size_t i;
allocate_elements (n, list, elems, elemp, values);
{
size_t i;
allocate_elements (n, list, elems, elemp, values);
{
size_t i;
allocate_elements (n, list, elems, elemp, values);
{
memcpy (tmp, array + j * size, size);
memcpy (array + j * size, array + i * size, size);
{
memcpy (tmp, array + j * size, size);
memcpy (array + j * size, array + i * size, size);
{
size_t i;
allocate_elements (n, list, elems, elemp, values);
{
size_t i;
allocate_elements (n, list, elems, elemp, values);
}
/* Frees LIST, the N elements of ELEMS, ELEMP, and VALUES. */
}
/* Frees LIST, the N elements of ELEMS, ELEMP, and VALUES. */
llx_destroy (list, NULL, NULL, &llx_malloc_mgr);
for (i = 0; i < n; i++)
free (elems[i]);
llx_destroy (list, NULL, NULL, &llx_malloc_mgr);
for (i = 0; i < n; i++)
free (elems[i]);
{
values[i] = elems[i]->x = i;
llx_push_tail (&list, elems[i], &llx_malloc_mgr);
{
values[i] = elems[i]->x = i;
llx_push_tail (&list, elems[i], &llx_malloc_mgr);
{
struct element *e = llx_pop_tail (&list, &llx_malloc_mgr);
check (e->x == max_elems - i - 1);
{
struct element *e = llx_pop_tail (&list, &llx_malloc_mgr);
check (e->x == max_elems - i - 1);
allocate_ascending (cnt, &list, &elems, &elemp, NULL);
extra.x = -1;
allocate_ascending (cnt, &list, &elems, &elemp, NULL);
extra.x = -1;
allocate_ascending (cnt, &list, &elems, &elemp, &values);
check_list_contents (&list, values, cnt);
allocate_ascending (cnt, &list, &elems, &elemp, &values);
check_list_contents (&list, values, cnt);
- for (i = 0; i < cnt; i++)
- for (j = 0; j < cnt; j++)
- for (k = 0; k < 2; k++)
+ for (i = 0; i < cnt; i++)
+ for (j = 0; j < cnt; j++)
+ for (k = 0; k < 2; k++)
free_elements (cnt, &list, elems, elemp, values);
}
free_elements (cnt, &list, elems, elemp, values);
}
{
const int max_elems = 8;
int cnt, a0, a1, b0, b1, r;
{
const int max_elems = 8;
int cnt, a0, a1, b0, b1, r;
for (cnt = 0; cnt <= max_elems; cnt++)
for (r0 = 0; r0 <= cnt; r0++)
for (r1 = r0; r1 <= cnt; r1++)
for (cnt = 0; cnt <= max_elems; cnt++)
for (r0 = 0; r0 <= cnt; r0++)
for (r1 = r0; r1 <= cnt; r1++)
allocate_elements (cnt, &list, &elems, &elemp, &values);
remaining = 0;
allocate_elements (cnt, &list, &elems, &elemp, &values);
remaining = 0;
for (cnt = 0; cnt <= max_elems; cnt++)
for (r0 = 0; r0 <= cnt; r0++)
for (r1 = r0; r1 <= cnt; r1++)
for (cnt = 0; cnt <= max_elems; cnt++)
for (r0 = 0; r0 <= cnt; r0++)
for (r1 = r0; r1 <= cnt; r1++)
allocate_ascending (cnt, &list, &elems, &elemp, &values);
remaining = 0;
allocate_ascending (cnt, &list, &elems, &elemp, &values);
remaining = 0;
allocate_ascending (cnt, &list, &elems, &elemp, &values);
match = -1;
allocate_ascending (cnt, &list, &elems, &elemp, &values);
match = -1;
for (i = 0; i <= cnt; i++)
{
struct llx *llx1 = llx_find_adjacent_equal (elemp[i], llx_null (&list),
for (i = 0; i <= cnt; i++)
{
struct llx *llx1 = llx_find_adjacent_equal (elemp[i], llx_null (&list),
-test_count_if_helper (int r0, int r1, int eq_pat, struct llx **elemp)
+test_count_if_helper (int r0, int r1, int eq_pat, struct llx **elemp)
{
struct llx *min = llx_min (elemp[r0], elemp[r1],
compare_elements, &aux_data);
struct llx *max = llx_max (elemp[r0], elemp[r1],
compare_elements, &aux_data);
{
struct llx *min = llx_min (elemp[r0], elemp[r1],
compare_elements, &aux_data);
struct llx *max = llx_max (elemp[r0], elemp[r1],
compare_elements, &aux_data);
for (cnt_a = 0; cnt_a <= max_elems; cnt_a++)
for (pat_a = 0; pat_a <= 1 << cnt_a; pat_a++)
for (cnt_b = 0; cnt_b <= max_elems; cnt_b++)
for (cnt_a = 0; cnt_a <= max_elems; cnt_a++)
for (pat_a = 0; pat_a <= 1 << cnt_a; pat_a++)
for (cnt_b = 0; cnt_b <= max_elems; cnt_b++)
{
struct llx_list list_a, list_b;
struct element **elems_a, **elems_b;
{
struct llx_list list_a, list_b;
struct element **elems_a, **elems_b;
compare_elements, &aux_data);
check (a_ordering == b_ordering);
compare_elements, &aux_data);
check (a_ordering == b_ordering);
free_elements (cnt_a, &list_a, elems_a, elemp_a, values_a);
free_elements (cnt_b, &list_b, elems_b, elemp_b, values_b);
free_elements (cnt_a, &list_a, elems_a, elemp_a, values_a);
free_elements (cnt_b, &list_b, elems_b, elemp_b, values_b);
/* Appends the `x' value in element E to the array pointed to by
NEXT_OUTPUT, and advances NEXT_OUTPUT to the next position. */
static void
/* Appends the `x' value in element E to the array pointed to by
NEXT_OUTPUT, and advances NEXT_OUTPUT to the next position. */
static void
llx_apply (elemp[r0], elemp[r1], apply_func, &next_output);
check_list_contents (&list, values, cnt);
llx_destroy (&list, NULL, NULL, &llx_malloc_mgr);
llx_apply (elemp[r0], elemp[r1], apply_func, &next_output);
check_list_contents (&list, values, cnt);
llx_destroy (&list, NULL, NULL, &llx_malloc_mgr);
check (r1 - r0 == next_output - output);
for (j = 0; j < r1 - r0; j++)
check (output[j] == r0 + j);
check (r1 - r0 == next_output - output);
for (j = 0; j < r1 - r0; j++)
check (output[j] == r0 + j);
output = next_output = xnmalloc (cnt, sizeof *output);
llx_destroy (&list, apply_func, &next_output, &llx_malloc_mgr);
output = next_output = xnmalloc (cnt, sizeof *output);
llx_destroy (&list, apply_func, &next_output, &llx_malloc_mgr);
/* Tests llx_next_permutation and llx_prev_permutation when the
permuted values have no duplicates. */
static void
/* Tests llx_next_permutation and llx_prev_permutation when the
permuted values have no duplicates. */
static void
perm_cnt = 1;
extract_values (&list, old_values, cnt);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
perm_cnt = 1;
extract_values (&list, old_values, cnt);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
{
extract_values (&list, new_values, cnt);
check (lexicographical_compare_3way (new_values, cnt,
{
extract_values (&list, new_values, cnt);
check (lexicographical_compare_3way (new_values, cnt,
llx_reverse (llx_head (&list), llx_null (&list));
extract_values (&list, old_values, cnt);
while (llx_prev_permutation (llx_head (&list), llx_null (&list),
llx_reverse (llx_head (&list), llx_null (&list));
extract_values (&list, old_values, cnt);
while (llx_prev_permutation (llx_head (&list), llx_null (&list),
{
extract_values (&list, new_values, cnt);
check (lexicographical_compare_3way (new_values, cnt,
{
extract_values (&list, new_values, cnt);
check (lexicographical_compare_3way (new_values, cnt,
/* Tests llx_next_permutation and llx_prev_permutation when the
permuted values contain duplicates. */
static void
/* Tests llx_next_permutation and llx_prev_permutation when the
permuted values contain duplicates. */
static void
allocate_elements (cnt, &list, &elems, &elemp, &values);
value = 0;
allocate_elements (cnt, &list, &elems, &elemp, &values);
value = 0;
permutation_cnt = 1;
extract_values (&list, old_values, cnt);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
permutation_cnt = 1;
extract_values (&list, old_values, cnt);
while (llx_next_permutation (llx_head (&list), llx_null (&list),
{
extract_values (&list, new_values, cnt);
check (lexicographical_compare_3way (new_values, cnt,
{
extract_values (&list, new_values, cnt);
check (lexicographical_compare_3way (new_values, cnt,
llx_reverse (llx_head (&list), llx_null (&list));
extract_values (&list, old_values, cnt);
while (llx_prev_permutation (llx_head (&list), llx_null (&list),
llx_reverse (llx_head (&list), llx_null (&list));
extract_values (&list, old_values, cnt);
while (llx_prev_permutation (llx_head (&list), llx_null (&list),
{
extract_values (&list, new_values, cnt);
check (lexicographical_compare_3way (new_values, cnt,
{
extract_values (&list, new_values, cnt);
check (lexicographical_compare_3way (new_values, cnt,
{
const int max_elems = 8;
const int max_fillxer = 3;
int merge_cnt, pattern, pfx, gap, sfx, order;
{
const int max_elems = 8;
const int max_fillxer = 3;
int merge_cnt, pattern, pfx, gap, sfx, order;
for (merge_cnt = 0; merge_cnt < max_elems; merge_cnt++)
for (pattern = 0; pattern <= (1 << merge_cnt); pattern++)
for (pfx = 0; pfx < max_fillxer; pfx++)
for (merge_cnt = 0; merge_cnt < max_elems; merge_cnt++)
for (pattern = 0; pattern <= (1 << merge_cnt); pattern++)
for (pfx = 0; pfx < max_fillxer; pfx++)
{
const int max_elems = 8;
int cnt, merge_pat, inc_pat, order;
{
const int max_elems = 8;
int cnt, merge_pat, inc_pat, order;
for (cnt = 0; cnt <= max_elems; cnt++)
for (merge_pat = 0; merge_pat <= (1 << cnt); merge_pat++)
for (inc_pat = 0; inc_pat <= (1 << cnt); inc_pat++)
for (cnt = 0; cnt <= max_elems; cnt++)
for (merge_pat = 0; merge_pat <= (1 << cnt); merge_pat++)
for (inc_pat = 0; inc_pat <= (1 << cnt); inc_pat++)
allocate_elements (cnt, &list, &elems, &elemp, &values);
j = 0;
allocate_elements (cnt, &list, &elems, &elemp, &values);
j = 0;
extract_values (&list, perm_values, cnt);
llx_init (&perm_list);
for (j = 0; j < cnt; j++)
extract_values (&list, perm_values, cnt);
llx_init (&perm_list);
for (j = 0; j < cnt; j++)
perm_elems[j]->x = perm_values[j];
llx_push_tail (&perm_list, perm_elems[j], &llx_malloc_mgr);
}
perm_elems[j]->x = perm_values[j];
llx_push_tail (&perm_list, perm_elems[j], &llx_malloc_mgr);
}
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
j = 0;
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
j = 0;
{
struct llx_list perm_list;
extract_values (&list, perm_values, cnt);
llx_init (&perm_list);
for (i = 0; i < cnt; i++)
{
struct llx_list perm_list;
extract_values (&list, perm_values, cnt);
llx_init (&perm_list);
for (i = 0; i < cnt; i++)
perm_elems[i]->x = perm_values[i];
perm_elems[i]->y = i;
llx_push_tail (&perm_list, perm_elems[i], &llx_malloc_mgr);
perm_elems[i]->x = perm_values[i];
perm_elems[i]->y = i;
llx_push_tail (&perm_list, perm_elems[i], &llx_malloc_mgr);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
allocate_elements (cnt, &list, &elems, NULL, &values);
j = unique_values = 0;
allocate_elements (cnt, &list, &elems, NULL, &values);
j = unique_values = 0;
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
j = unique_cnt = 0;
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
j = unique_cnt = 0;
{
struct llx_list perm_list;
extract_values (&list, perm_values, cnt);
llx_init (&perm_list);
for (i = 0; i < cnt; i++)
{
struct llx_list perm_list;
extract_values (&list, perm_values, cnt);
llx_init (&perm_list);
for (i = 0; i < cnt; i++)
perm_elems[i]->x = perm_values[i];
perm_elems[i]->y = i;
llx_push_tail (&perm_list, perm_elems[i], &llx_malloc_mgr);
perm_elems[i]->x = perm_values[i];
perm_elems[i]->y = i;
llx_push_tail (&perm_list, perm_elems[i], &llx_malloc_mgr);
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
free (unique_values);
free_elements (cnt, &list, elems, NULL, values);
free_elements (cnt, NULL, perm_elems, NULL, perm_values);
free (unique_values);
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
j = 0;
allocate_elements (cnt, NULL, &perm_elems, NULL, &perm_values);
j = 0;
{
struct llx_list perm_list;
extract_values (&list, perm_values, cnt);
llx_init (&perm_list);
for (i = 0; i < cnt; i++)
{
struct llx_list perm_list;
extract_values (&list, perm_values, cnt);
llx_init (&perm_list);
for (i = 0; i < cnt; i++)
perm_elems[i]->x = perm_values[i];
perm_elems[i]->y = i;
llx_insert_ordered (llx_head (&perm_list),
perm_elems[i]->x = perm_values[i];
perm_elems[i]->y = i;
llx_insert_ordered (llx_head (&perm_list),
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
check (llx_is_sorted (llx_head (&perm_list), llx_null (&perm_list),
compare_elements_x_y, &aux_data));
llx_destroy (&perm_list, NULL, NULL, &llx_malloc_mgr);
allocate_ascending (cnt, &list, &elems, &elemp, &values);
/* Check that llx_find_partition works okay in every
allocate_ascending (cnt, &list, &elems, &elemp, &values);
/* Check that llx_find_partition works okay in every
- check (llx_push_head (&list, NULL, &llx_null_mgr) == NULL);
- check (llx_push_tail (&list, NULL, &llx_null_mgr) == NULL);
- check (llx_insert (llx_null (&list), NULL, &llx_null_mgr) == NULL);
+ check (llx_push_head (&list, NULL, &llx_null_mgr) == NULL);
+ check (llx_push_tail (&list, NULL, &llx_null_mgr) == NULL);
+ check (llx_insert (llx_null (&list), NULL, &llx_null_mgr) == NULL);
{
run_test (test_push_pop, "push/pop");
run_test (test_insert_remove, "insert/remove");
{
run_test (test_push_pop, "push/pop");
run_test (test_insert_remove, "insert/remove");