mirror of
https://github.com/aljazceru/goose.git
synced 2026-01-31 12:14:32 +01:00
Add GIF unsupported format test (#2618)
This commit is contained in:
@@ -172,6 +172,8 @@ fn is_image_file(path: &Path) -> bool {
|
||||
[0x89, 0x50, 0x4E, 0x47] => true,
|
||||
// JPEG: FF D8 FF
|
||||
[0xFF, 0xD8, 0xFF, _] => true,
|
||||
// GIF: 47 49 46 38
|
||||
[0x47, 0x49, 0x46, 0x38] => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -214,6 +214,8 @@ fn is_image_file(path: &Path) -> bool {
|
||||
[0x89, 0x50, 0x4E, 0x47] => true,
|
||||
// JPEG: FF D8 FF
|
||||
[0xFF, 0xD8, 0xFF, _] => true,
|
||||
// GIF: 47 49 46 38
|
||||
[0x47, 0x49, 0x46, 0x38] => true,
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
@@ -411,6 +413,21 @@ mod tests {
|
||||
// Test non-existent file
|
||||
let result = load_image_file("nonexistent.png");
|
||||
assert!(result.is_err());
|
||||
|
||||
// Create a GIF file with valid header bytes
|
||||
let gif_path = temp_dir.path().join("test.gif");
|
||||
// Minimal GIF89a header
|
||||
let gif_data = [0x47, 0x49, 0x46, 0x38, 0x39, 0x61];
|
||||
std::fs::write(&gif_path, &gif_data).unwrap();
|
||||
let gif_path_str = gif_path.to_str().unwrap();
|
||||
|
||||
// Test loading unsupported GIF format
|
||||
let result = load_image_file(gif_path_str);
|
||||
assert!(result.is_err());
|
||||
assert!(result
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("Unsupported image format"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user