summaryrefslogtreecommitdiff
path: root/tests/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/map.c')
-rw-r--r--tests/map.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/map.c b/tests/map.c
new file mode 100644
index 0000000..e9362ab
--- /dev/null
+++ b/tests/map.c
@@ -0,0 +1,33 @@
+#include <assert.h>
+#include <stdio.h>
+
+#define MAP_KEY int
+#define MAP_TYPE int
+#define MAP_CMP(a, b) ((a) - (b))
+#define MAP_NAME ints
+#include <conts/map.h>
+
+int main()
+{
+ struct ints ints = ints_create();
+ for (int i = 0; i < 1000000; ++i) {
+ ints_insert(&ints, i, i);
+ }
+ assert(ints_len(&ints) == 1000000);
+
+ for (int i = 0; i < 1000000; ++i) {
+ int *v = ints_find(&ints, i);
+ assert(v && *v == i);
+ }
+
+ foreach(ints, iter, &ints) {
+ assert(iter->key == iter->data);
+ }
+
+ for (int i = 0; i < 1000000; ++i) {
+ ints_remove(&ints, i);
+ }
+
+ assert(ints_len(&ints) == 0);
+ ints_destroy(&ints);
+}