From 30ff2bdc6b9f65933369d0ddde1e5fba4d44bdce Mon Sep 17 00:00:00 2001 From: cosineblast <55855728+cosineblast@users.noreply.github.com> Date: Wed, 17 Jan 2024 15:05:27 -0300 Subject: [PATCH] Add pragma once tests --- test/val/pragma-once-sample-link.h | 1 + test/val/pragma-once-sample.h | 21 +++++++++++++++++++++ test/val/pragma-once-test.c | 27 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 120000 test/val/pragma-once-sample-link.h create mode 100644 test/val/pragma-once-sample.h create mode 100644 test/val/pragma-once-test.c diff --git a/test/val/pragma-once-sample-link.h b/test/val/pragma-once-sample-link.h new file mode 120000 index 000000000..d19d8c541 --- /dev/null +++ b/test/val/pragma-once-sample-link.h @@ -0,0 +1 @@ +pragma-once-sample.h \ No newline at end of file diff --git a/test/val/pragma-once-sample.h b/test/val/pragma-once-sample.h new file mode 100644 index 000000000..477c7c8bd --- /dev/null +++ b/test/val/pragma-once-sample.h @@ -0,0 +1,21 @@ +/* +** !!DESCRIPTION!! Simple #pragma once directive tests +** !!ORIGIN!! cc65 regression tests +** !!LICENCE!! Public Domain +*/ + +#ifdef FILE_INCLUDED + +#error "This file should not have been included twice" +#define INCLUDED_TWICE + +#else + +#define FILE_INCLUDED + +#endif + + +/* a pragma once directive should work regardless of where it is located in + the file, as long as it is seen by the preprocessor */ +#pragma once diff --git a/test/val/pragma-once-test.c b/test/val/pragma-once-test.c new file mode 100644 index 000000000..e85f19bbb --- /dev/null +++ b/test/val/pragma-once-test.c @@ -0,0 +1,27 @@ +/* +** !!DESCRIPTION!! Simple #pragma once directive tests +** !!ORIGIN!! cc65 regression tests +** !!LICENCE!! Public Domain +*/ + + +#include "pragma-once-sample.h" +#include "pragma-once-sample.h" +#include "pragma-once-sample-link.h" + +/* pragma-once-sample-link.h is a symlink to pragma-once-sample. */ + + +#include + + +int main() { + +#ifdef INCLUDED_TWICE + printf("pragma-once-sample.h included more than once\n"); + return 1; +#else + printf("pragma-once-sample included once\n"); + return 0; +#endif +}