Created
July 23, 2019 17:08
-
-
Save kolen/2fd057848dfa0f82dfe58461263d1f62 to your computer and use it in GitHub Desktop.
Rust Image library test cases for iteration methods on ImageBuffer with zero width and/or height causing 'chunk_size != 0' panic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "image-iter-panic-demo" | |
version = "0.1.0" | |
edition = "2018" | |
[dependencies] | |
image = { git = "https://github.com/image-rs/image" } | |
[lib] | |
path = "lib.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(test)] | |
use image::{ImageBuffer, RgbaImage}; | |
#[cfg(test)] | |
mod tests_zero_width_zero_height { | |
use super::*; | |
fn test_image() -> RgbaImage { | |
ImageBuffer::new(0, 0) | |
} | |
#[test] | |
fn test_rows_mut() { | |
let mut image = test_image(); | |
let rows = image.rows_mut(); | |
assert_eq!(rows.count(), 0); | |
} | |
#[test] | |
fn test_pixels_mut() { | |
let mut image = test_image(); | |
let rows = image.pixels_mut(); | |
assert_eq!(rows.count(), 0); | |
} | |
#[test] | |
fn test_rows() { | |
let image = test_image(); | |
let rows = image.rows(); | |
assert_eq!(rows.count(), 0); | |
} | |
#[test] | |
fn test_pixels() { | |
let image = test_image(); | |
let rows = image.pixels(); | |
assert_eq!(rows.count(), 0); | |
} | |
} | |
#[cfg(test)] | |
mod tests_zero_width_nonzero_height { | |
use super::*; | |
fn test_image() -> RgbaImage { | |
ImageBuffer::new(0, 2) | |
} | |
#[test] | |
fn test_rows_mut() { | |
let mut image = test_image(); | |
let rows = image.rows_mut(); | |
assert_eq!(rows.count(), 2); | |
} | |
#[test] | |
fn test_pixels_mut() { | |
let mut image = test_image(); | |
let rows = image.pixels_mut(); | |
assert_eq!(rows.count(), 0); | |
} | |
#[test] | |
fn test_rows() { | |
let image = test_image(); | |
let rows = image.rows(); | |
assert_eq!(rows.count(), 2); | |
} | |
#[test] | |
fn test_pixels() { | |
let image = test_image(); | |
let rows = image.pixels(); | |
assert_eq!(rows.count(), 0); | |
} | |
} | |
#[cfg(test)] | |
mod tests_nonzero_width_zero_height { | |
use super::*; | |
fn test_image() -> RgbaImage { | |
ImageBuffer::new(2, 0) | |
} | |
#[test] | |
fn test_rows_mut() { | |
let mut image = test_image(); | |
let rows = image.rows_mut(); | |
assert_eq!(rows.count(), 0); | |
} | |
#[test] | |
fn test_pixels_mut() { | |
let mut image = test_image(); | |
let rows = image.pixels_mut(); | |
assert_eq!(rows.count(), 0); | |
} | |
#[test] | |
fn test_rows() { | |
let image = test_image(); | |
let rows = image.rows(); | |
assert_eq!(rows.count(), 0); | |
} | |
#[test] | |
fn test_pixels() { | |
let image = test_image(); | |
let rows = image.pixels(); | |
assert_eq!(rows.count(), 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment