@@ -328,6 +328,32 @@ TEST test_draw_vline_xyh_custom_clip_regression(void) {
328328 PASS ();
329329}
330330
331+ /*
332+ * Line clipped by top edge of custom clip window only:
333+ * Only y=50..59 visible.
334+ */
335+ TEST test_draw_vline_xyh_custom_clip_top (void ) {
336+ hagl_set_clip (& bitmap , 50 , 50 , 200 , 200 );
337+ hagl_draw_vline_xyh (& bitmap , 75 , 40 , 20 , 0xFFFF );
338+
339+ /* On line: top edge of clip window */
340+ ASSERT_EQ (0xFFFF , hagl_get_pixel (& bitmap , 75 , 50 ));
341+
342+ /* On line: bottom endpoint of original line */
343+ ASSERT_EQ (0xFFFF , hagl_get_pixel (& bitmap , 75 , 59 ));
344+
345+ /* Outside: just above clip window */
346+ ASSERT_EQ (0x0000 , hagl_get_pixel (& bitmap , 75 , 49 ));
347+
348+ /* Outside: just below original line end */
349+ ASSERT_EQ (0x0000 , hagl_get_pixel (& bitmap , 75 , 60 ));
350+
351+ /* Total: 10 pixels */
352+ ASSERT_EQ (10 , count_pixels (& bitmap , 0xFFFF ));
353+
354+ PASS ();
355+ }
356+
331357SUITE (vline_suite ) {
332358 SET_SETUP (setup_callback , NULL );
333359 SET_TEARDOWN (teardown_callback , NULL );
@@ -345,6 +371,7 @@ SUITE(vline_suite) {
345371 RUN_TEST (test_draw_vline_xyh_outside );
346372 RUN_TEST (test_draw_vline_xyh_custom_clip );
347373 RUN_TEST (test_draw_vline_xyh_custom_clip_regression );
374+ RUN_TEST (test_draw_vline_xyh_custom_clip_top );
348375}
349376
350377GREATEST_MAIN_DEFS ();
0 commit comments