add create_context() function

This commit is contained in:
Lars-Magnus Skog
2019-05-08 20:33:41 +02:00
parent a154de6cc5
commit c9b6bb6a9b

View File

@@ -4467,6 +4467,10 @@ unsafe fn stress_functions(context: &dc_context_t) {
}; };
} }
#[cfg(test)]
mod tests {
use super::*;
unsafe extern "C" fn cb( unsafe extern "C" fn cb(
_context: &dc_context_t, _context: &dc_context_t,
_event: Event, _event: Event,
@@ -4476,9 +4480,7 @@ unsafe extern "C" fn cb(
0 0
} }
#[test] unsafe fn create_context() -> dc_context_t {
fn run_stress_tests() {
unsafe {
let mut ctx = dc_context_new(cb, std::ptr::null_mut(), std::ptr::null_mut()); let mut ctx = dc_context_new(cb, std::ptr::null_mut(), std::ptr::null_mut());
let dir = tempdir().unwrap(); let dir = tempdir().unwrap();
let dbfile = CString::new(dir.path().join("db.sqlite").to_str().unwrap()).unwrap(); let dbfile = CString::new(dir.path().join("db.sqlite").to_str().unwrap()).unwrap();
@@ -4491,6 +4493,14 @@ fn run_stress_tests() {
.unwrap() .unwrap()
); );
stress_functions(&ctx) ctx
}
#[test]
fn run_stress_tests() {
unsafe {
let ctx = create_context();
stress_functions(&ctx);
}
} }
} }