diff options
author | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-08-22 15:27:17 +0300 |
---|---|---|
committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2025-08-22 15:27:17 +0300 |
commit | b0d619e2c9595f4ec05463e87be9d0d3423c0a70 (patch) | |
tree | dfcda5da356b660fadb8b133772c926c08908cbb /tests/map.c | |
parent | 7774ae2f8c2dca9ab2d93082856f031e78a1b5f0 (diff) | |
download | conts-b0d619e2c9595f4ec05463e87be9d0d3423c0a70.tar.gz conts-b0d619e2c9595f4ec05463e87be9d0d3423c0a70.zip |
use covsrv for coverage testing
Diffstat (limited to 'tests/map.c')
-rw-r--r-- | tests/map.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/map.c b/tests/map.c index 6c42787..a370413 100644 --- a/tests/map.c +++ b/tests/map.c @@ -1,20 +1,38 @@ #include <assert.h> #include <stdio.h> +#include "test.h" +/* required defs */ #define MAP_KEY int #define MAP_TYPE int #define MAP_HASH(a) CONTS_MAP_NO_HASH(a) #define MAP_CMP(a, b) ((a) - (b)) #define MAP_NAME ints + +/* optional defs */ +#define MAP_MALLOC mallocc +#define MAP_CALLOC callocc +#define MAP_REALLOC reallocc +#define MAP_FREE free + #include <conts/map.h> int main() { +#if defined(COVERAGE) + assert(!covsrv_init()); + atexit(covsrv_destroy); +#endif + /* heuristic, but if we know how many elements we'll need, we should * give it to the create function. */ struct ints ints = ints_create(0); for (int i = 0; i < 1000000; ++i) { - ints_insert(&ints, i, i); + if (!ints_insert(&ints, i, i)) { + fprintf(stderr, "failed inserting %d\n", i); + ints_destroy(&ints); + return -1; + } } assert(ints_len(&ints) == 1000000); |