Beispiel #1
0
void
stress_test_alist(int amt)
{
	alist al;
	int i;
	gendata x, y;

	al = alist_create();
	assert(alist_empty(al));

	printf("Creating an association list with %d items...\n", amt);
	for (i = 0; i < amt; ++i) {
		x.num = y.num = i;
		al = alist_insert_uniq(al, x, y, num_eq);

		assert(!alist_empty(al));

		alist_lookup(al, x, num_eq, &y);
		assert(x.num == y.num);
	}

	y.ptr = NULL;
	printf("Walking an association list of %d items...\n", amt);
	alist_walk(al, walker, y);

	printf("Deleting %d items from the association list...\n", amt);
	for (i = 0; i < amt; ++i) {
		/* Inserting an item that's already there should fail */
		x.num = i;
		y.num = i;			/* Value does not matter */
		assert(alist_insert_uniq(al, x, y, num_eq) == NULL);

		al = alist_delete(al, x, num_eq, NULL, NULL);
	}
	assert(alist_empty(al));
	alist_destroy(al, NULL, NULL);
}
Beispiel #2
0
int stack_empty(stack_t* stack) {
  return alist_empty(stack);
}