test: move dc_msg_guess_msgtype_from_suffix tests to dc_msg.rs

This commit is contained in:
Lars-Magnus Skog
2019-05-13 16:23:47 +02:00
parent 986c092801
commit 5c9dc3a334
2 changed files with 33 additions and 44 deletions

View File

@@ -1616,3 +1616,36 @@ pub unsafe fn dc_update_server_uid(
sqlite3_step(stmt);
sqlite3_finalize(stmt);
}
#[cfg(test)]
mod tests {
use super::*;
use std::ffi::CStr;
#[test]
fn test_dc_msg_guess_msgtype_from_suffix() {
unsafe {
let mut type_0: libc::c_int = 0;
let mut mime_0: *mut libc::c_char = 0 as *mut libc::c_char;
dc_msg_guess_msgtype_from_suffix(
b"foo/bar-sth.mp3\x00" as *const u8 as *const libc::c_char,
0 as *mut libc::c_int,
&mut mime_0,
);
assert_eq!(
CStr::from_ptr(mime_0 as *const libc::c_char)
.to_str()
.unwrap(),
"audio/mpeg"
);
dc_msg_guess_msgtype_from_suffix(
b"foo/bar-sth.mp3\x00" as *const u8 as *const libc::c_char,
&mut type_0,
0 as *mut *mut libc::c_char,
);
assert_eq!(type_0, 40);
// TODO add more tests for different message types
free(mime_0 as *mut libc::c_void);
}
}
}