Add a test for a malformed WebP image
- ID
b46b850- date
2024-09-04 07:55:22+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
34f9aa4- message
Add a test for a malformed WebP image- changed files
2 files, 13 additions
Changed files
src/main.rs (9855) → src/main.rs (10216)
diff --git a/src/main.rs b/src/main.rs
index d12c086..301c6e3 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -265,6 +265,18 @@ mod tests {
}
#[test]
+ fn it_fails_if_you_pass_a_malformed_webp() {
+ let output = get_failure(&["./src/tests/malformed.txt.webp"]);
+
+ assert_eq!(output.exit_code, 1);
+ assert_eq!(output.stdout, "");
+ assert_eq!(
+ output.stderr,
+ "Format error decoding WebP: Invalid Chunk header: [82, 73, 70, 70]\n"
+ );
+ }
+
+ #[test]
fn it_fails_if_you_pass_a_path_without_a_file_extension() {
let output = get_failure(&["./src/tests/noextension"]);
src/tests/malformed.txt.webp (0) → src/tests/malformed.txt.webp (22)
diff --git a/src/tests/malformed.txt.webp b/src/tests/malformed.txt.webp
new file mode 100644
index 0000000..d6d2570
--- /dev/null
+++ b/src/tests/malformed.txt.webp
@@ -0,0 +1 @@
+Ceci n'est pas une png
\ No newline at end of file