mirror of
https://github.com/chatmail/core.git
synced 2026-05-01 20:36:31 +03:00
Make dc_mimeparser_parse() return parser instead of modifying reference
Since dc_mimeparser_parse() called `dc_mimeparser_empty()' on passed reference anyway, it makes more sense to create new instance of `dc_mimeparser_t' and return it instead. Previously, usage pattern was following: dc_mimeparser_new() dc_mimeparser_empty() // semantically no-op, called inside dc_mimeparser_parse Now call to dc_mimeparser_empty() is avoided.
This commit is contained in:
committed by
Floris Bruynooghe
parent
21976b14a6
commit
8e4a01c98d
@@ -657,11 +657,9 @@ unsafe fn create_test_context() -> TestContext {
|
||||
fn test_dc_mimeparser_with_context() {
|
||||
unsafe {
|
||||
let context = create_test_context();
|
||||
|
||||
let mut mimeparser = dc_mimeparser_new(&context.ctx);
|
||||
let raw = b"Content-Type: multipart/mixed; boundary=\"==break==\";\nSubject: outer-subject\nX-Special-A: special-a\nFoo: Bar\nChat-Version: 0.0\n\n--==break==\nContent-Type: text/plain; protected-headers=\"v1\";\nSubject: inner-subject\nX-Special-B: special-b\nFoo: Xy\nChat-Version: 1.0\n\ntest1\n\n--==break==--\n\n\x00";
|
||||
let mut mimeparser = dc_mimeparser_parse(&context.ctx, &raw[..]);
|
||||
|
||||
dc_mimeparser_parse(&mut mimeparser, &raw[..]);
|
||||
assert_eq!(
|
||||
as_str(mimeparser.subject as *const libc::c_char),
|
||||
"inner-subject",
|
||||
|
||||
Reference in New Issue
Block a user