Skip to content

Instantly share code, notes, and snippets.

@trimoq
Created October 14, 2019 14:54
Show Gist options
  • Save trimoq/209cf01265404b139b0f2338402a71be to your computer and use it in GitHub Desktop.
Save trimoq/209cf01265404b139b0f2338402a71be to your computer and use it in GitHub Desktop.
// the internal function that is not exposed otherwise
fn generate_preview(image: &RgbaImage) -> RgbaImage {
// ...
}
// ...
#[cfg(test)] // this ensures that this module is only included if you build a `test` target
mod tests { // the tests live in their own module
// assert that the generated (landscape) image has the hardcoded maximum width
#[test]
fn test_preview_image_size() {
let image = DynamicImage::new_rgb8(1920, 1080).to_rgba();
let (_, _, preview) = PreviewService::new(image);
//max width is 512
assert_eq!(512, preview.preview_image.width());
//9:16*512=288
assert_eq!(288, preview.preview_image.height());
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment