#include <assert.h>
#include <stdio.h>

#define SPTREE_TYPE int
#define SPTREE_CMP(a, b) ((b) - (a))
#define SPTREE_NAME ints
#include <conts/sptree.h>

int main()
{
	struct ints ints = ints_create();
	for (int i = 0; i < 1000000; ++i) {
		ints_insert(&ints, i);
	}
	assert(ints_len(&ints) == 1000000);

	for (int i = 0; i < 1000000; ++i) {
		int *v = ints_find(&ints, i);
		assert(v && *v == i);
	}

	int i = 0;
	foreach(ints, iter, &ints) {
		/* since my trees are ordered, this must hold, although you
		 * might consider it an implementation detail that shouldn't be
		 * relied on */
		assert(iter && *iter == i);
		i++;
	}

	for (int i = 0; i < 1000000; ++i) {
		ints_remove(&ints, i);
	}

	assert(ints_len(&ints) == 0);
	ints_destroy(&ints);
}