From 972c4fc4e06e00a50fb979ab7f4d3e7296924019 Mon Sep 17 00:00:00 2001 From: Paolo Barbolini Date: Fri, 22 Nov 2024 20:55:00 +0100 Subject: [PATCH] test: fix 3 blind spots reported by cargo-mutants --- src/body/base64.rs | 2 +- src/body/chooser.rs | 8 +++++++- src/headers/rfc2231.rs | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/body/base64.rs b/src/body/base64.rs index adb9172..ce6a221 100644 --- a/src/body/base64.rs +++ b/src/body/base64.rs @@ -70,7 +70,7 @@ pub fn encode(b: &[u8], w: &mut dyn Write) -> fmt::Result { pub fn encoded_len(input_len: usize) -> usize { let mut base64_len = input_len / 3 * 4; if input_len % 3 != 0 { - base64_len += 4 - base64_len % 4; + base64_len += 4; } let mut crlf_len = base64_len / LINE_LEN * CRLF.len(); if crlf_len >= CRLF.len() && base64_len % LINE_LEN == 0 { diff --git a/src/body/chooser.rs b/src/body/chooser.rs index 30fe5ec..0225244 100644 --- a/src/body/chooser.rs +++ b/src/body/chooser.rs @@ -226,7 +226,13 @@ mod tests { #[test] fn not_too_long_multiline() { - let input = concat!("0123\n", "4567").as_bytes(); + let input = concat!( + "0123\n", + "4567\n", + "00000000000000000000000000000000000000000\n", + "89" + ) + .as_bytes(); assert!(!line_too_long(input)); } diff --git a/src/headers/rfc2231.rs b/src/headers/rfc2231.rs index ef6973a..c3f289f 100644 --- a/src/headers/rfc2231.rs +++ b/src/headers/rfc2231.rs @@ -372,4 +372,12 @@ mod tests { } } } + + #[test] + #[should_panic(expected = "`key` must only be composed of ascii alphanumeric chars")] + fn non_ascii_key() { + let mut s = String::new(); + let mut w = EmailWriter::new(&mut s, 0, 0, true); + let _ = encode("📬", "", &mut w); + } }