Developing the command-line application and testing
In the previous section, we built the library for image resizing. In this section, we will review the design and key parts of the code for the main command-line application.
Let's begin with some automated unit tests to test the image resizing functionality in resize.rs
: This way we can confirm that the image resizing library works independently of any calling function.
Two test cases are shown here in the following code—one to resize a single image, and the other to resize multiple images. You can replace the source folder and filenames in the code with your own:
src/imagix/resize.rs
#[cfg(test)] mod tests { use super::*; #[test] fn test_single_image_resize() { let mut path = PathBuf::from("/tmp/images/ image1.jpg...