add test for trimEdges function with empty image

This commit is contained in:
Vetle Leinonen-Roeim 2025-03-30 18:36:14 +02:00
parent 5a66c793b9
commit 493fe180d3

View file

@ -539,3 +539,19 @@ func TestTrimEdgesUneven(t *testing.T) {
t.Errorf("trimEdges() pixel data does not match expected result") t.Errorf("trimEdges() pixel data does not match expected result")
} }
} }
func TestTrimEdgesEmptyImage(t *testing.T) {
// Create an empty image (0x0 dimensions)
src := newImage(0, 0)
// The expected result should also be an empty image
want := src
// Apply the trimEdges function
got := trimEdges(src)
// Compare pixel data
if !compareImages(got, want) {
t.Errorf("trimEdges() for empty image returned %v, want %v", got.Bounds(), want.Bounds())
}
}