ORCA-C/Tests/Conformance/c99macros.c
Stephen Heumann 6ead1d4caf Add a set of new tests for C95/C99/C11 features that we now support.
These are currently only run by the new DOIT3 test-running script.

Note that these tests are designed to be applicable to most implementations of C95/C99/C11, not just ORCA/C. They do make certain assumptions not guaranteed by the standards (e.g. power of 2 types and some properties of IEEE-like FP), but in general those assumptions should be true for most 'normal' systems.
2021-08-22 17:32:56 -05:00

33 lines
642 B
C

/*
* Test macros with variable arguments and empty macro arguments (C99).
*/
#include <stdio.h>
#include <string.h>
#define a(x) (x + 5)
#define print(fmt, ...) sprintf(str, fmt, __VA_ARGS__)
char str[100];
int main(void) {
if (a() != a(0))
goto Fail;
print("%i %s", 123, "hi");
if (strcmp(str, "123 hi") != 0)
goto Fail;
print("%u %s %x", 123, "hi", 0xA8);
if (strcmp(str, "123 hi a8") != 0)
goto Fail;
printf ("Passed Conformance Test c99macros\n");
return 0;
Fail:
printf ("Failed Conformance Test c99macros\n");
}