summaryrefslogtreecommitdiff
path: root/gnulib-tests/test-inttostr.c
diff options
context:
space:
mode:
Diffstat (limited to 'gnulib-tests/test-inttostr.c')
-rw-r--r--gnulib-tests/test-inttostr.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/gnulib-tests/test-inttostr.c b/gnulib-tests/test-inttostr.c
index ea5b2956..cb71b2b8 100644
--- a/gnulib-tests/test-inttostr.c
+++ b/gnulib-tests/test-inttostr.c
@@ -1,5 +1,5 @@
/* Test inttostr functions, and incidentally, INT_BUFSIZE_BOUND
- Copyright (C) 2010-2014 Free Software Foundation, Inc.
+ Copyright (C) 2010-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -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) \