Created
October 14, 2019 14:54
-
-
Save trimoq/209cf01265404b139b0f2338402a71be to your computer and use it in GitHub Desktop.
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
// 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