mirror of
https://github.com/bend-n/fimg.git
synced 2024-12-22 02:28:19 -06:00
fix debug_assert and add test for repeat
This commit is contained in:
parent
51c506425c
commit
36355a5c83
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "fimg"
|
||||
version = "0.3.3"
|
||||
version = "0.3.4"
|
||||
authors = ["bend-n <bend.n@outlook.com>"]
|
||||
license = "MIT"
|
||||
edition = "2021"
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -372,3 +372,13 @@ macro_rules! img {
|
|||
}
|
||||
#[cfg(test)]
|
||||
use img;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn repeat() {
|
||||
let x: Image<&[u8], 3> = Image::build(8, 8).buf(include_bytes!("../benches/3_8x8.imgbuf"));
|
||||
unsafe { x.repeated(128, 128) }; // repeat 16 times
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,8 +131,9 @@ impl OverlayAt<Image<&[u8], 3>> for Image<&mut [u8], 3> {
|
|||
let o_x = ((j + y as usize) * self.width() as usize + x as usize) * 3
|
||||
..((j + y as usize) * self.width() as usize + x as usize + ($n as usize))
|
||||
* 3;
|
||||
debug_assert!(o_x.end < self.buffer().len());
|
||||
debug_assert!(i_x.end < with.buffer().len());
|
||||
// <= because ".." range
|
||||
debug_assert!(o_x.end <= self.buffer().len());
|
||||
debug_assert!(i_x.end <= with.buffer().len());
|
||||
// SAFETY: bounds are ✅
|
||||
let a = unsafe { self.buffer.get_unchecked_mut(o_x) };
|
||||
// SAFETY: we are in ⬜!
|
||||
|
|
Loading…
Reference in a new issue