diff --git a/test/test_INT_format.h.in b/test/test_INT_format.h.in index 72a62f259..a8ea26314 100644 --- a/test/test_INT_format.h.in +++ b/test/test_INT_format.h.in @@ -18,15 +18,13 @@ # define LANG "C " #endif -#define VALUE(T, U) \ - (@KWIML@_INT_##T)((@KWIML@_INT_##U)0xab << \ - ((sizeof(@KWIML@_INT_##T)-1)<<3)) \ +#define VALUE(T, U) (T)((U)0xab << ((sizeof(T)-1)<<3)) -#define TEST_C(C, V, PRI, T, U) \ +#define TEST_C_(C, V, PRI, T, U) \ { \ - @KWIML@_INT_##T const x = VALUE(T, U); \ - @KWIML@_INT_##T y = @KWIML@_INT_##C(V); \ - printf(LANG "@KWIML@_INT_" #C ":" \ + T const x = VALUE(T, U); \ + T y = C(V); \ + printf(LANG #C ":" \ " expression [%"@KWIML@_INT_PRI##PRI"]," \ " literal [%"@KWIML@_INT_PRI##PRI"]", x, y); \ if(x == y) \ @@ -40,9 +38,9 @@ } \ } -#define TEST_PRI(PRI, T, U, STR) \ +#define TEST_PRI_(PRI, T, U, STR) \ { \ - @KWIML@_INT_##T const x = VALUE(T, U); \ + T const x = VALUE(T, U); \ char const* str = STR; \ sprintf(buf, "%"@KWIML@_INT_PRI##PRI, x); \ printf(LANG "@KWIML@_INT_PRI" #PRI ":" \ @@ -58,11 +56,11 @@ } \ } -#define TEST_SCN(SCN, T, U, STR) TEST_SCN2(SCN, SCN, T, U, STR) -#define TEST_SCN2(PRI, SCN, T, U, STR) \ +#define TEST_SCN_(SCN, T, U, STR) TEST_SCN2_(SCN, SCN, T, U, STR) +#define TEST_SCN2_(PRI, SCN, T, U, STR) \ { \ - @KWIML@_INT_##T const x = VALUE(T, U); \ - @KWIML@_INT_##T y; \ + T const x = VALUE(T, U); \ + T y; \ char const* str = STR; \ if(sscanf(str, "%"@KWIML@_INT_SCN##SCN, &y) != 1) \ { \ @@ -82,10 +80,24 @@ } \ } -#define TEST(FMT, T, U, STR) TEST2(FMT, FMT, T, U, STR) -#define TEST2(PRI, SCN, T, U, STR) \ - TEST_PRI(PRI, T, U, STR) \ - TEST_SCN2(PRI, SCN, T, U, STR) +#define TEST_(FMT, T, U, STR) TEST2_(FMT, FMT, T, U, STR) +#define TEST2_(PRI, SCN, T, U, STR) \ + TEST_PRI_(PRI, T, U, STR) \ + TEST_SCN2_(PRI, SCN, T, U, STR) + +/* Concatenate T and U now to avoid expanding them. */ +#define TEST(FMT, T, U, STR) \ + TEST_(FMT, @KWIML@_INT_##T, @KWIML@_INT_##U, STR) +#define TEST2(PRI, SCN, T, U, STR) \ + TEST2_(PRI, SCN, @KWIML@_INT_##T, @KWIML@_INT_##U, STR) +#define TEST_C(C, V, PRI, T, U) \ + TEST_C_(@KWIML@_INT_##C, V, PRI, @KWIML@_INT_##T, @KWIML@_INT_##U) +#define TEST_PRI(PRI, T, U, STR) \ + TEST_PRI_(PRI, @KWIML@_INT_##T, @KWIML@_INT_##U, STR) +#define TEST_SCN(SCN, T, U, STR) \ + TEST_SCN_(SCN, @KWIML@_INT_##T, @KWIML@_INT_##U, STR) +#define TEST_SCN2(PRI, SCN, T, U, STR) \ + TEST_SCN2_(PRI, SCN, @KWIML@_INT_##T, @KWIML@_INT_##U, STR) static int test_INT_format(void) {