mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 15:29:46 +00:00
Add test case for sign extending < 1 byte
This commit is contained in:
parent
04d16b3740
commit
c0f2b69bef
@ -30,7 +30,8 @@ static struct signed_ints {
|
||||
signed int a : 3;
|
||||
signed int b : 3;
|
||||
signed int c : 3;
|
||||
} si = {-4, -1, 3};
|
||||
signed int d : 10;
|
||||
} si = {-4, -1, 3, -500};
|
||||
|
||||
static void test_signed_bitfield(void)
|
||||
{
|
||||
@ -61,9 +62,19 @@ static void test_signed_bitfield(void)
|
||||
failures++;
|
||||
}
|
||||
|
||||
if (si.d >= 0) {
|
||||
printf("Got si.d = %d, expected negative.\n", si.d);
|
||||
failures++;
|
||||
}
|
||||
if (si.d != -500) {
|
||||
printf("Got si.d = %d, expected -500.\n", si.d);
|
||||
failures++;
|
||||
}
|
||||
|
||||
si.a = -3;
|
||||
si.b = 1;
|
||||
si.c = -2;
|
||||
si.d = 500;
|
||||
|
||||
if (si.a >= 0) {
|
||||
printf("Got si.a = %d, expected negative.\n", si.a);
|
||||
@ -91,6 +102,15 @@ static void test_signed_bitfield(void)
|
||||
printf("Got si.c = %d, expected -2.\n", si.c);
|
||||
failures++;
|
||||
}
|
||||
|
||||
if (si.d <= 0) {
|
||||
printf("Got si.d = %d, expected positive.\n", si.d);
|
||||
failures++;
|
||||
}
|
||||
if (si.d != 500) {
|
||||
printf("Got si.d = %d, expected 500.\n", si.d);
|
||||
failures++;
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
Loading…
Reference in New Issue
Block a user