Skip to content

Commit

Permalink
added tests for smime_decnonicalize
Browse files Browse the repository at this point in the history
  • Loading branch information
nitneuqr committed Sep 17, 2024
1 parent 71e8abc commit fd3aed5
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/rust/src/pkcs7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ mod tests {
use std::borrow::Cow;
use std::ops::Deref;

use super::smime_canonicalize;
use super::{smime_canonicalize, smime_decanonicalize};

#[test]
fn test_smime_canonicalize() {
Expand Down Expand Up @@ -722,4 +722,32 @@ mod tests {
);
}
}

#[test]
fn test_smime_decanonicalize() {
for (input, text_mode, expected_output) in [
// Values with text_mode=false
(b"" as &[u8], false, b"" as &[u8]),
(b"abc\r\n", false, b"abc\n"),
(b"\r\nabc\n", false, b"\nabc\n"),
(b"abc\r\ndef\r\n", false, b"abc\ndef\n"),
(b"abc\r\ndef\nabc", false, b"abc\ndef\nabc"),
// Values with text_mode=true
(b"Content-Type: text/plain\r\n\r\n", true, b""),
(b"Content-Type: text/plain\r\n\r\nabc", true, b"abc"),
(
b"Content-Type: text/plain\r\n\r\nabc\r\ndef\r\n",
true,
b"abc\ndef\n",
),
(
b"Content-Type: text/plain\r\n\r\nabc\r\ndef\nabc",
true,
b"abc\ndef\nabc",
),
] {
let result = smime_decanonicalize(input, text_mode);
assert_eq!(result.deref(), expected_output);
}
}
}

0 comments on commit fd3aed5

Please sign in to comment.