From ae70f68546ea2acb6046b2321beee19beffaa7b3 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Tue, 21 Apr 2026 14:45:47 +0300 Subject: [PATCH] tests: add test for gg.context.remove_cached_image_by_idx panic (fixes #23584) --- vlib/gg/image_test.v | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/vlib/gg/image_test.v b/vlib/gg/image_test.v index 3254a7d8c..d1bf201e5 100644 --- a/vlib/gg/image_test.v +++ b/vlib/gg/image_test.v @@ -22,6 +22,21 @@ fn test_remove_cached_image_remove_and_get() { assert ctx.get_cached_image_by_idx(idx).ok == false } +fn test_remove_cached_images_by_id_keeps_other_ids_valid() { + mut ctx := gg.new_context(width: 100) + background_bytes := os.read_bytes(background_path)! + prev := ctx.create_image_from_byte_array(background_bytes)! + curr := ctx.create_image_from_byte_array(background_bytes)! + assert prev.id == 0 + assert curr.id == 1 + assert ctx.get_cached_image_by_idx(prev.id).ok == true + assert ctx.get_cached_image_by_idx(curr.id).ok == true + ctx.remove_cached_image_by_idx(prev.id) + ctx.remove_cached_image_by_idx(curr.id) + assert ctx.get_cached_image_by_idx(prev.id).ok == false + assert ctx.get_cached_image_by_idx(curr.id).ok == false +} + fn test_new_context_sets_borderless_window_flag() { ctx := gg.new_context( width: 100 -- 2.39.5