Add error types and core image types: ImageFormat, ImageSource, Dimensions, QualityPreset
This commit is contained in:
46
pixstrip-core/tests/error_tests.rs
Normal file
46
pixstrip-core/tests/error_tests.rs
Normal file
@@ -0,0 +1,46 @@
|
||||
use pixstrip_core::error::PixstripError;
|
||||
|
||||
#[test]
|
||||
fn error_display_image_load() {
|
||||
let err = PixstripError::ImageLoad {
|
||||
path: "/tmp/bad.jpg".into(),
|
||||
reason: "corrupt header".into(),
|
||||
};
|
||||
let msg = err.to_string();
|
||||
assert!(msg.contains("/tmp/bad.jpg"));
|
||||
assert!(msg.contains("corrupt header"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_display_unsupported_format() {
|
||||
let err = PixstripError::UnsupportedFormat {
|
||||
format: "bmp".into(),
|
||||
};
|
||||
assert!(err.to_string().contains("bmp"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_display_io() {
|
||||
let io_err = std::io::Error::new(std::io::ErrorKind::NotFound, "file missing");
|
||||
let err = PixstripError::Io(io_err);
|
||||
assert!(err.to_string().contains("file missing"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_display_output_exists() {
|
||||
let err = PixstripError::OutputExists {
|
||||
path: "/tmp/out.jpg".into(),
|
||||
};
|
||||
assert!(err.to_string().contains("/tmp/out.jpg"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn error_display_processing() {
|
||||
let err = PixstripError::Processing {
|
||||
operation: "resize".into(),
|
||||
reason: "invalid dimensions".into(),
|
||||
};
|
||||
let msg = err.to_string();
|
||||
assert!(msg.contains("resize"));
|
||||
assert!(msg.contains("invalid dimensions"));
|
||||
}
|
||||
Reference in New Issue
Block a user