@@ -16,9 +16,9 @@ constexpr int ROCKET_WIDTH = 36, ROCKET_HEIGHT = 72,
1616 BACKGROUND_WIDTH = 864 , BACKGROUND_HEIGHT = 769 ,
1717 FROG_WIDTH = 294 , FROG_HEIGHT = 422 ;
1818
19- TEST_CASE (" bitmaps can be created and freed" , " [load_bitmap][bitmap_width][bitmap_height][free_bitmap]" )
19+ TEST_CASE (" bitmaps can be loaded and freed" , " [load_bitmap][bitmap_width][bitmap_height][free_bitmap]" )
2020{
21- // Creating bitmaps
21+ // Loading bitmaps
2222 bitmap rocket_bmp, frog_bmp, background_bmp;
2323 rocket_bmp = load_bitmap (" rocket_sprt" , " rocket_sprt.png" );
2424 REQUIRE (bitmap_valid (rocket_bmp));
@@ -134,3 +134,47 @@ TEST_CASE("bitmap bounding details can be retrieved", "[bitmap]")
134134 }
135135 free_bitmap (bmp);
136136}
137+
138+ TEST_CASE (" can create and free a new bitmap" , " [create_bitmap]" )
139+ {
140+ // Initialise
141+ int width = 256 ;
142+ int height = 128 ;
143+ bitmap bmp = create_bitmap (" new_bitmap" , width, height);
144+
145+ // Ensure bitmap exists and is valid
146+ REQUIRE (bmp != nullptr );
147+ REQUIRE (bitmap_valid (bmp));
148+ REQUIRE (has_bitmap (" new_bitmap" ));
149+
150+ SECTION (" bitmap has correct dimensions" )
151+ {
152+ REQUIRE (bitmap_width (bmp) == width);
153+ REQUIRE (bitmap_height (bmp) == height);
154+ }
155+
156+ SECTION (" bitmap is transparent" )
157+ {
158+ // Sample pixel colours
159+ color p1 = get_pixel (bmp, 0 , 0 );
160+ color p2 = get_pixel (bmp, width - 1 , height - 1 );
161+ color p3 = get_pixel (bmp, width / 2 , height / 2 );
162+
163+ // Check transparency (alpha == 0)
164+ REQUIRE (p1.a == 0 );
165+ REQUIRE (p2.a == 0 );
166+ REQUIRE (p3.a == 0 );
167+ }
168+
169+ SECTION (" bitmap can be drawn on" )
170+ {
171+ // Try to draw a single white pixel
172+ REQUIRE_NOTHROW (draw_pixel_on_bitmap (bmp, color_white (), 0 , 0 ));
173+ }
174+
175+ SECTION (" bitmap can be freed" )
176+ {
177+ free_bitmap (bmp);
178+ REQUIRE_FALSE (bitmap_valid (bmp));
179+ }
180+ }
0 commit comments