From 5940254d9363ed8de9ba79a65cb074ec5aa4e69f Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 27 Oct 2024 16:17:32 +0200 Subject: initial containers --- tests/htrie.c | 22 ++++++++++++++++++++++ tests/vec.c | 19 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/htrie.c create mode 100644 tests/vec.c (limited to 'tests') diff --git a/tests/htrie.c b/tests/htrie.c new file mode 100644 index 0000000..2c70b38 --- /dev/null +++ b/tests/htrie.c @@ -0,0 +1,22 @@ +#include + +#define HTRIE_TYPE int +#define HTRIE_KEY int +#define HTRIE_HASH conts_inthash +#define HTRIE_CMP(a, b) ((a) - (b)) +#define HTRIE_NAME ints +#include + +int main() +{ + struct ints ints = ints_create(); + for (int i = 0; i < 1000000; ++i) { + ints_insert(&ints, i, i); + } + + for (int i = 0; i < 1000000; ++i) { + int *v = ints_at(&ints, i); + assert(v && *v == i); + } + ints_destroy(&ints); +} diff --git a/tests/vec.c b/tests/vec.c new file mode 100644 index 0000000..4bc06e7 --- /dev/null +++ b/tests/vec.c @@ -0,0 +1,19 @@ +#include + +#define VEC_TYPE int +#define VEC_NAME ints +#include + +int main() +{ + struct ints ints = ints_create(0); + for (int i = 0; i < 1000000; ++i) { + ints_append(&ints, i); + } + + for (int i = 0; i < 1000000; ++i) { + int *v = ints_at(&ints, i); + assert(v && *v == i); + } + ints_destroy(&ints); +} -- cgit v1.2.3