1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-01 23:29:41 +00:00
cc65/test/val/struct1.c
2014-09-25 21:38:34 +02:00

101 lines
1.2 KiB
C

/*
!!DESCRIPTION!!
!!ORIGIN!! SDCC regression tests
!!LICENCE!! GPL, read COPYING.GPL
*/
#include <stdio.h>
#include <limits.h>
unsigned char success = 0;
unsigned char failures = 0;
unsigned char dummy = 0;
#if SUPPORT_BIT_TYPES
bit bit0 = 0;
bit bit1 = 0;
bit bit2 = 0;
bit bit3 = 0;
bit bit4 = 0;
bit bit5 = 0;
bit bit6 = 0;
bit bit7 = 0;
bit bit8 = 0;
bit bit9 = 0;
bit bit10 = 0;
bit bit11 = 0;
#endif
unsigned int aint0 = 0;
unsigned int aint1 = 0;
unsigned char achar0 = 0;
unsigned char achar1 = 0;
unsigned char *acharP = 0;
struct chars
{
unsigned char c0, c1;
unsigned int i0, i1;
};
struct chars struct1;
void
done ()
{
dummy++;
}
void
struct_test (void)
{
if (struct1.c0 || struct1.c1)
failures++;
struct1.c0++;
if (struct1.c0 != 1)
failures++;
}
void
ptr_to_struct (struct chars *p)
{
if (p->c1)
failures++;
p->c1++;
if (p->c1 != 1)
failures++;
}
void add_chars(void)
{
achar0 = struct1.c0 + struct1.c1;
if(achar0 != 1)
failures++;
}
int
main (void)
{
struct1.c0 = 0;
struct1.c1 = 0;
struct_test ();
ptr_to_struct (&struct1);
struct1.c0 = 0;
struct1.c1 = 1;
add_chars();
success = failures;
done ();
printf("failures: %d\n",failures);
return failures;
}