mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-08-17 07:28:57 +00:00
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.
33 lines
642 B
C
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");
|
|
}
|
|
|