From a1e790b91b66149df25ea2cc5391b0657ed2de0d Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Fri, 7 Jun 2019 21:03:30 +0200 Subject: [PATCH] test: add test for dc_get_abs_path() --- tests/stress.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/stress.rs b/tests/stress.rs index 5a7b6eaba..ecbaea04e 100644 --- a/tests/stress.rs +++ b/tests/stress.rs @@ -2,6 +2,7 @@ use std::collections::HashSet; use std::ffi::{CStr, CString}; +use std::path::PathBuf; use mmime::mailimf_types::*; use tempfile::{tempdir, TempDir}; @@ -945,6 +946,23 @@ fn test_dc_get_oauth2_token() { assert_eq!(res, None); } +#[test] +fn test_dc_get_abs_path() { + let ctx = unsafe { create_test_context() }; + + let blobdir_c = unsafe { dc_get_blobdir(&ctx.ctx) }; + let mut image_path = PathBuf::from(to_string(blobdir_c)); + image_path.push("image.png"); + + let mut image_path_2 = PathBuf::from("$BLOBDIR"); + image_path_2.push("image.png"); + + let image_c = CString::new(image_path_2.to_str().unwrap()).unwrap(); + let abs_path = unsafe { dc_get_abs_path(&ctx.ctx, image_c.as_ptr()) }; + + assert_eq!(to_string(abs_path), image_path.to_str().unwrap()); +} + #[test] fn test_stress_tests() { unsafe {