struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2208.c
blob6890d25391ace53f5270befc71105176c0f834c6
1 /*
2 bug-2208.c
3 */
5 #include <testfwk.h>
7 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_pic14) // Lack of memory
8 typedef
9 struct SDCCBUG_Card {
10 signed char suit, rank;
11 } SDCCBUG_Card;
13 typedef
14 SDCCBUG_Card SDCCBUG_Cards[37];
16 SDCCBUG_Cards SDCCBUG_pack;
17 unsigned char SDCCBUG_packN;
18 unsigned char SDCCBUG_handN[2];
19 SDCCBUG_Cards SDCCBUG_hand[2];
20 signed char SDCCBUG_skill = 1;
22 void SDCCBUG_DealCardsTo (unsigned char player)
24 unsigned char i, j;
25 SDCCBUG_Card tmp;
26 if ((int)SDCCBUG_handN[player] >= 6 || (int)SDCCBUG_packN == 0) {
27 return;
29 i = (int)SDCCBUG_handN[player] + 1;
30 while ((int)i <= 6) {
31 if (SDCCBUG_skill == 4) {
32 j = (int)SDCCBUG_packN - 3;
33 if (SDCCBUG_pack[SDCCBUG_packN].rank > SDCCBUG_pack[j].rank) {
34 tmp.suit = SDCCBUG_pack[SDCCBUG_packN].suit;
38 SDCCBUG_hand[player][i].suit = SDCCBUG_pack[SDCCBUG_packN].suit;
39 SDCCBUG_hand[player][i].rank = SDCCBUG_pack[SDCCBUG_packN].rank;
40 SDCCBUG_handN[player] = i;
41 SDCCBUG_packN -= 1;
43 if ((int)SDCCBUG_packN == 0) {
44 return;
46 i += 1;
49 #endif
51 void testBug(void)
53 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15) && !defined(__SDCC_pic14) // Lack of memory
54 SDCCBUG_packN = 1;
55 SDCCBUG_skill = 1;
56 SDCCBUG_pack[SDCCBUG_packN].suit = 23;
57 SDCCBUG_pack[SDCCBUG_packN].rank = 42;
58 SDCCBUG_handN[0] = 0;
60 SDCCBUG_DealCardsTo (0);
62 ASSERT(SDCCBUG_hand[0][1].suit == 23);
63 ASSERT(SDCCBUG_hand[0][1].rank == 42);
64 ASSERT(!SDCCBUG_packN);
65 #endif