mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 03:02:49 +01:00
graphics: Better test for a crash
This commit is contained in:
parent
876e483d0c
commit
6783aaae56
@ -1339,3 +1339,17 @@ func TestImageAddressRepeat(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReplacePixelsAfterClear(t *testing.T) {
|
||||||
|
const w, h = 256, 256
|
||||||
|
img, _ := NewImage(w, h, FilterDefault)
|
||||||
|
img.ReplacePixels(make([]byte, 4*w*h))
|
||||||
|
// Clear used to call DrawImage to clear the image, which was the cause of crash. It is because after
|
||||||
|
// DrawImage is called, ReplacePixels for a region is forbidden.
|
||||||
|
//
|
||||||
|
// Now ReplacePixels was always called at Clear instead.
|
||||||
|
img.Clear()
|
||||||
|
img.ReplacePixels(make([]byte, 4*w*h))
|
||||||
|
|
||||||
|
// The test passes if this doesn't crash.
|
||||||
|
}
|
||||||
|
@ -287,13 +287,3 @@ func TestReplacePixelsAfterDrawImage(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestVariousReplacePixelsMustNotCrash(t *testing.T) {
|
|
||||||
const w, h = 256, 256
|
|
||||||
img0 := NewImage(w, h)
|
|
||||||
defer img0.Dispose()
|
|
||||||
img0.ReplacePixels(nil)
|
|
||||||
img0.ReplacePixels(make([]byte, 4*w*h))
|
|
||||||
img0.ReplacePixels(nil)
|
|
||||||
img0.ReplacePixels(make([]byte, 4*w*h))
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user