struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3459.c
blobb1474ca68eb9365959f0dc281c77e24d734a1bc5
1 /* bug-3459.c
2 An issue that resulted in a value in register hl being overwritten on z80.
3 */
5 #include <testfwk.h>
7 /// Test derived from code by SF user "Under4Mhz" in 2022.
8 /// GPL 2.0 or greater
9 #include <stdbool.h>
10 #include <stdint.h>
11 #include <stdio.h>
13 #define PICTURE_TILE_COUNT 4
14 #define PICTURE1_TILES 34
15 #define PICTURE2_TILES ( PICTURE1_TILES + PICTURE_TILE_COUNT )
17 ///< Is matching tiles
18 bool IsSameTile( int8_t tile1, int8_t tile2 ) {
20 if ( tile1 <= 0 || tile2 <= 0 ) return false;
22 bool same = tile1 == tile2;
23 bool flowers = tile1 > PICTURE1_TILES && tile1 <= PICTURE2_TILES && tile2 > PICTURE1_TILES && tile2 <= PICTURE2_TILES;
24 bool seasons = tile1 > PICTURE2_TILES && tile2 > PICTURE2_TILES;
26 return same || seasons || flowers;
29 void
30 testBug( void ) {
31 ASSERT ( IsSameTile(PICTURE1_TILES + 1, PICTURE1_TILES + 2) );
32 ASSERT ( IsSameTile(PICTURE2_TILES + 2, PICTURE2_TILES + 3) );
33 ASSERT ( IsSameTile(PICTURE1_TILES + 2, PICTURE1_TILES + 3) );
34 ASSERT ( IsSameTile(PICTURE2_TILES + 1, PICTURE2_TILES + 2) );