From 6f9f2471f81185201fc1b17c4062b1153810bbb3 Mon Sep 17 00:00:00 2001 From: Laurent Huberdeau Date: Tue, 13 Aug 2024 17:29:10 -0400 Subject: [PATCH] Add test for multiple inclusions --- .../preprocessor/include/multiple-include.c | 37 +++++++++++++++++++ .../include/multiple-include.golden | 1 + .../preprocessor/include/multiple-include.h | 8 ++++ 3 files changed, 46 insertions(+) create mode 100644 tests/_all/preprocessor/include/multiple-include.c create mode 100644 tests/_all/preprocessor/include/multiple-include.golden create mode 100644 tests/_all/preprocessor/include/multiple-include.h diff --git a/tests/_all/preprocessor/include/multiple-include.c b/tests/_all/preprocessor/include/multiple-include.c new file mode 100644 index 00000000..596e343d --- /dev/null +++ b/tests/_all/preprocessor/include/multiple-include.c @@ -0,0 +1,37 @@ +// tests for #include "" directives + +// putchar +#include + +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" +#include "multiple-include.h" + +void putint_aux(int n) { + if (n <= -10) putint_aux(n / 10); + putchar('0' - (n % 10)); +} + +void putint(int n) { + if (n < 0) { + putchar('-'); + putint_aux(n); + } else { + putint_aux(-n); + } + + putchar('\n'); +} + +void main() { + putint(CONSTANT1); +} diff --git a/tests/_all/preprocessor/include/multiple-include.golden b/tests/_all/preprocessor/include/multiple-include.golden new file mode 100644 index 00000000..d00491fd --- /dev/null +++ b/tests/_all/preprocessor/include/multiple-include.golden @@ -0,0 +1 @@ +1 diff --git a/tests/_all/preprocessor/include/multiple-include.h b/tests/_all/preprocessor/include/multiple-include.h new file mode 100644 index 00000000..56c3edbb --- /dev/null +++ b/tests/_all/preprocessor/include/multiple-include.h @@ -0,0 +1,8 @@ +// tests for #include "" directives + +#ifndef MULTI_INCLUDE +#define MULTI_INCLUDE + +int CONSTANT1 = 1; + +#endif