mirror of
https://github.com/byteworksinc/ORCA-C.git
synced 2024-11-19 03:07:00 +00:00
1 line
9.3 KiB
Plaintext
1 line
9.3 KiB
Plaintext
|
/* Conformance Test 4.5.3.2: Verfication of static array declarations */
#include <math.h>
static int i1 [50], i3 [3] [5] [8]; /* all basic types */
static long L1 [9], L2 [2] [6];
static unsigned int ui3 [4] [5] [1], ui1 [7];
static unsigned long ul2 [5] [3], ul1 [1];
static comp c1 [3], c2 [2] [3];
static char ch2 [6] [5], ch1 [10];
static float f1 [3], f4 [2] [3] [1] [4];
static double d2 [2] [4], d1 [8];
static extended e1 [9], e2 [7] [3];
/* conglomerate types */
struct s { int a;
float f; };
static struct s s1 [10], s2 [5] [4];
enum colors { red, black, green };
static enum colors C3 [2] [1] [3], C1 [6];
union longOrShort { int first;
long second; };
static union longOrShort u2 [3] [3], u1 [12];
main ()
{
static int TestArray (void);
if ( TestArray() )
printf ("Passed Conformance Test 4.5.3.2\n");
else
printf ("Failed Conformance Test 4.5.3.2\n");
}
/****************************************************************************/
static int TestArray ( void )
{
int i, j, k, n; /* loop indices */
long L; /* l-values */
char ch;
float f;
double d;
extended e;
unsigned int ui;
unsigned long ul;
for (i = 0; i < 50; i++) /* assign & check singly-dimensioned */
i1 [i] = i; /* integer array */
for (i = 49; i >= 0; i--)
if (i1 [i] != i)
goto Fail;
for (i = 0; i < 3; i++) /* assign & check multiply-dimensioned */
for (j = 0; j < 5; j++) /* integer array */
for (k = 0; k < 8; k++)
i3 [i] [j] [k] = k;
for (i = 2; i >= 0; i--)
for (j = 4; j >= 0; j--)
for (k = 7; k >= 0; k--)
if (i3 [i] [j] [k] != k)
goto Fail;
for (ch = 'a', i = 0; i < 6; i++) /* assign & check multiply-dimensioned */
for (j = 0; j < 5; j++) /* character arrays */
ch2 [i] [j] = ch++;
for (ch = '~', n = 5; n >= 0; n--)
for (k = 4; k >= 0; k--)
if (ch2 [n] [k] != ch--)
goto Fail;
for (i = 0; i < 10; i++) /* assign & check singly-dimensioned */
ch1 [i] = (char) (i + 0x41); /* character arrays */
for (ch = 'J', i = 9; i >= 0; i--)
if (ch1 [i] != ch--)
goto Fail;
for (i = 8; i >= 0; i--) /* assign & check singly-dimensioned */
L1 [i] = 2147483647; /* long integer array */
for (i = 0; i < 9; i++)
if (L1 [i] != 2147483647)
goto Fail;
for (L = 2147483646, i = 0; i < 2; i++) /* assign & check multiply- */
for (j = 0; j < 6; j++) /* dimensioned long integer*/
L2 [i] [j] = L--; /* array */
for (L = 2147483635, i = 1; i >= 0; i--)
for (j = 5; j >= 0; j--)
if (L2 [i] [j] != L++)
goto Fail;
for (ui = 65534, i = 0; i < 7; i++) /* assign & check singly-dimensioned */
ui1 [i] = ui--; /* unsigned integer array */
for (ui = 65528, i = 6; i >= 0; i--)
if (ui1 [i] != ui++)
goto Fail;
for (ui = 65534, i = 0; i < 4; i++) /* assign & check multiply-dimensioned */
for (j = 0; j < 5; j++) /* unsigned integer array */
for (k = 0; k < 1; k++)
ui3 [i] [j] [k] = ui--;
for (ui = 65515, i = 3, k = 0; i >= 0; i--)
for (j = 4; j >= 0; j--)
if (ui3 [i] [j] [k] != ui++)
goto Fail;
for (ul = 4294967279ul, i = 0; i < 5; i++) /* assign & check multiply- */
for (j = 0; j < 3; j++) /* dimensioned unsigned */
ul2 [i] [j] = ul++; /* long integer array */
for (ul = 4294967293ul,
|