Mercurial > molko
diff extern/libdt/dt.h @ 422:b0579ae033ed
core: use err.h in (action|drawable)-stack
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 15 Oct 2022 13:48:40 +0200 |
parents | 1bf7d6669f0a |
children |
line wrap: on
line diff
--- a/extern/libdt/dt.h Thu Oct 13 20:56:42 2022 +0200 +++ b/extern/libdt/dt.h Sat Oct 15 13:48:40 2022 +0200 @@ -21,6 +21,7 @@ #include <inttypes.h> #include <math.h> +#include <stddef.h> #include <stdint.h> #include <stdio.h> #include <string.h> @@ -115,12 +116,30 @@ dt_nchecks - nchecks, dt_nfailures - nfailures); \ } while (0) +#define DT_RUN_EX(f, init, fini, ...) \ +do { \ + const size_t nchecks = dt_nchecks; \ + const size_t nfailures = dt_nfailures; \ + \ + ++ dt_ntests; \ + \ + printf("== test " #f " ==\n"); \ + init(__VA_ARGS__); \ + f(__VA_ARGS__); \ + fini(__VA_ARGS__); \ + \ + printf("\n%zu checks, %zu failures\n\n", \ + dt_nchecks - nchecks, dt_nfailures - nfailures); \ +} while (0) + #define DT_SUMMARY() \ do { \ printf("summary: %zu tests, %zu checks, %zu failures\n", \ dt_ntests, dt_nchecks, dt_nfailures); \ } while (0) +#define DT_EXIT() (dt_nfailures != 0) + /* Aliases for basic types. */ #define DT_EQ_CHAR(x, y) DT_EQ(x, y, char, "%c") #define DT_EQ_SHORT(x, y) DT_EQ(x, y, short, "%hd") @@ -133,6 +152,8 @@ #define DT_EQ_ULLONG(x, y) DT_EQ(x, y, unsigned long long, "%llu") #define DT_EQ_INTMAX(x, y) DT_EQ(x, y, intmax_t, "%jd") #define DT_EQ_UINTMAX(x, y) DT_EQ(x, y, uintmax_t, "%ju") +#define DT_EQ_SIZE(x, y) DT_EQ(x, y, size_t, "%zu") +#define DT_EQ_PTRDIFF(x, y) DT_EQ(x, y, ptrdiff_t, "%td") /* Aliases for fixed size integers. */ #define DT_EQ_INT8(x, y) DT_EQ(x, y, int8_t, PRId8)