diff options
author | Brad King <brad.king@kitware.com> | 2012-03-13 15:54:21 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-03-13 15:54:21 (GMT) |
commit | 15e96b0304f912bae3cfcde7a1b3d6ae3660ef9e (patch) | |
tree | a8a2e2af409a3730dac2e39a06efb56ccd60fc90 /Utilities | |
parent | 88720153a9126d950f92ef1c8ce5802997eb9c51 (diff) | |
parent | 289e5e6012053a356d6a7b9a9351c4b4127a50d9 (diff) | |
download | CMake-15e96b0304f912bae3cfcde7a1b3d6ae3660ef9e.zip CMake-15e96b0304f912bae3cfcde7a1b3d6ae3660ef9e.tar.gz CMake-15e96b0304f912bae3cfcde7a1b3d6ae3660ef9e.tar.bz2 |
Merge topic 'update-KWIML'
289e5e6 Merge branch 'upstream-kwiml' into update-KWIML
f94ae0e KWIML: Make test_INT robust to #define-d int#_t and INT#_C
Diffstat (limited to 'Utilities')
-rw-r--r-- | Utilities/KWIML/test/test_INT_format.h.in | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/Utilities/KWIML/test/test_INT_format.h.in b/Utilities/KWIML/test/test_INT_format.h.in index 72a62f2..a8ea263 100644 --- a/Utilities/KWIML/test/test_INT_format.h.in +++ b/Utilities/KWIML/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) { |