From 80f1fc9bb8cdc11d344250c0ad9aecb06989410b Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Mon, 10 Jul 2023 11:14:49 +0200 Subject: [PATCH] add tests to lazy parser --- src/multipass/field_lazy.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/multipass/field_lazy.rs b/src/multipass/field_lazy.rs index c5b00c7..32922c0 100644 --- a/src/multipass/field_lazy.rs +++ b/src/multipass/field_lazy.rs @@ -46,4 +46,30 @@ mod tests { } ); } + + #[test] + fn test_mime_fields() { + assert_eq!( + new(&extract_fields::Parsed { + fields: vec![ + "MIME-Version: 1.0 \r\n", + "Content-Type: multipart/alternative; boundary=\"bound\"\r\n", + "Content-Transfer-Encoding: 7bit\r\n", + "Content-ID: \r\n", + "Content-Description: hello world\r\n", + ], + body: b"Hello world!", + }), + Parsed { + fields: vec![ + lazy::Field::MIMEVersion(lazy::Version("1.0 \r\n")), + lazy::Field::ContentType(lazy::Type("multipart/alternative; boundary=\"bound\"\r\n")), + lazy::Field::ContentTransferEncoding(lazy::Mechanism("7bit\r\n")), + lazy::Field::ContentID(lazy::Identifier("\r\n")), + lazy::Field::ContentDescription(lazy::Unstructured("hello world\r\n")), + ], + body: b"Hello world!", + } + ); + } }