diff options
Diffstat (limited to 'tests/test-inttostr.c')
-rw-r--r-- | tests/test-inttostr.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/test-inttostr.c b/tests/test-inttostr.c index 981b224ac0..cb71b2b81e 100644 --- a/tests/test-inttostr.c +++ b/tests/test-inttostr.c @@ -28,10 +28,6 @@ #include "macros.h" #define STREQ(a, b) (strcmp (a, b) == 0) -#define FMT(T) (TYPE_SIGNED (T) ? "%jd" : "%ju") -#define CAST_VAL(T,V) (TYPE_SIGNED (T) ? (intmax_t) (V) : (uintmax_t) (V)) -#define V_min(T) (CAST_VAL (T, TYPE_MINIMUM (T))) -#define V_max(T) (CAST_VAL (T, TYPE_MAXIMUM (T))) #define IS_TIGHT(T) (_GL_SIGNED_TYPE_OR_EXPR (T) == TYPE_SIGNED (T)) #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9) @@ -49,11 +45,19 @@ char const *p; \ ASSERT (buf); \ *buf = '\0'; \ - ASSERT (snprintf (ref, sizeof ref, FMT (T), V_min (T)) < sizeof ref); \ + ASSERT \ + ((TYPE_SIGNED (T) \ + ? snprintf (ref, sizeof ref, "%jd", (intmax_t) TYPE_MINIMUM (T)) \ + : snprintf (ref, sizeof ref, "%ju", (uintmax_t) TYPE_MINIMUM (T))) \ + < sizeof ref); \ ASSERT (STREQ ((p = Fn (TYPE_MINIMUM (T), buf)), ref)); \ /* Ensure that INT_BUFSIZE_BOUND is tight for signed types. */ \ ASSERT (! TYPE_SIGNED (T) || (p == buf && *p == '-')); \ - ASSERT (snprintf (ref, sizeof ref, FMT (T), V_max (T)) < sizeof ref); \ + ASSERT \ + ((TYPE_SIGNED (T) \ + ? snprintf (ref, sizeof ref, "%jd", (intmax_t) TYPE_MAXIMUM (T)) \ + : snprintf (ref, sizeof ref, "%ju", (uintmax_t) TYPE_MAXIMUM (T))) \ + < sizeof ref); \ ASSERT (STREQ ((p = Fn (TYPE_MAXIMUM (T), buf)), ref)); \ /* For unsigned types, the bound is not always tight. */ \ ASSERT (! IS_TIGHT (T) || TYPE_SIGNED (T) \ |