ORCA-C/Tests/Conformance/c99bool.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

95 lines
1.7 KiB
C

/*
* Test of _Bool type and <stdbool.h> header (C99).
*/
#include <stdio.h>
#include <stdbool.h>
int main(void) {
_Bool a = true;
bool b = false;
if (true != 1 || false != 0)
goto Fail;
if (!a || b)
goto Fail;
if (!++a)
goto Fail;
if (!a)
goto Fail;
if (--a)
goto Fail;
if (--a != true)
goto Fail;
b = 0x80000000;
if (!b)
goto Fail;
b = 2 + 4 == 5;
if (b)
goto Fail;
a = 0.0001;
b = 0.0;
if (b || !a)
goto Fail;
a = (void*)0;
b = &a;
if (a || !b)
goto Fail;
struct {
bool a : 1;
_Bool b : 1;
} s;
s.a = true;
s.b = false;
if (!s.a || s.b)
goto Fail;
if (!++s.a)
goto Fail;
if (!s.a)
goto Fail;
if (--s.a)
goto Fail;
if (--s.a != true)
goto Fail;
s.b = 0x80000000;
if (!s.b)
goto Fail;
s.b = 2 + 4 == 5;
if (s.b)
goto Fail;
s.a = 0.0001;
s.b = 0.0;
if (s.b || !s.a)
goto Fail;
s.a = (void*)0;
s.b = &a;
if (s.a || !s.b)
goto Fail;
printf ("Passed Conformance Test c99bool\n");
return 0;
Fail:
printf ("Failed Conformance Test c99bool\n");
}