From e4fc7a0feca596d18098c08598a97f388617e89f Mon Sep 17 00:00:00 2001 From: mrdudz Date: Tue, 21 Jul 2020 15:30:35 +0200 Subject: [PATCH] reworked pptest3 into an exectutable test and moved to test/val --- test/val/pptest3.c | 44 +++++++++++++++++++++++++++++++++++++ testcode/compiler/pptest3.c | 16 -------------- 2 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 test/val/pptest3.c delete mode 100644 testcode/compiler/pptest3.c diff --git a/test/val/pptest3.c b/test/val/pptest3.c new file mode 100644 index 000000000..b48677703 --- /dev/null +++ b/test/val/pptest3.c @@ -0,0 +1,44 @@ + +/* preprocessor test #3 */ + +#include +#include +#include + +char *x1 = "123"; +char *x2 = "456"; +FILE *s; +char *str = "789"; + +#define str(s) # s +#define xstr(s) str(s) +#define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \ + x ## s, x ## t) +#define INCFILE(n) vers ## n // Comment +#define glue(a,b) a ## b +#define xglue(a,b) glue(a,b) +#define HIGHLOW "hello" +#define LOW LOW ", world" + +int main(void) { + s = stdout; + + debug (1, 2); + + fputs (str (strncmp("abc\0d", "abc", '\4') // Comment + == 0) str (: @\n), s); + + str = glue (HIGH, LOW); + printf("str: %s\n", str); + if (strcmp(str, "hello") != 0) { + return EXIT_FAILURE; + } + + str = xglue (HIGH, LOW); + printf("str: %s\n", str); + if (strcmp(str, "hello, world") != 0) { + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} diff --git a/testcode/compiler/pptest3.c b/testcode/compiler/pptest3.c deleted file mode 100644 index 62aa7f705..000000000 --- a/testcode/compiler/pptest3.c +++ /dev/null @@ -1,16 +0,0 @@ -#define str(s) # s -#define xstr(s) str(s) -#define debug(s, t) printf("x" # s "= %d, x" # t "= %s", \ - x ## s, x ## t) -#define INCFILE(n) vers ## n // Comment -#define glue(a,b) a ## b -#define xglue(a,b) glue(a,b) -#define HIGHLOW "hello" -#define LOW LOW ", world" - -debug (1, 2); -fputs (str (strncmp("abc\0d", "abc", '\4') // Comment - == 0) str (: @\n), s); -glue (HIGH, LOW); -xglue (HIGH, LOW); -