fix: get_contacts logic was broken

This commit is contained in:
dignifiedquire
2019-07-12 11:17:49 +02:00
parent 08d8eebc37
commit 9d2ee5c0f7
2 changed files with 44 additions and 16 deletions

View File

@@ -10,6 +10,7 @@ use deltachat::constants::*;
use deltachat::context::*;
use deltachat::dc_array::*;
use deltachat::dc_configure::*;
use deltachat::dc_contact::*;
use deltachat::dc_imex::*;
use deltachat::dc_location::*;
use deltachat::dc_lot::*;
@@ -945,6 +946,31 @@ fn test_stress_tests() {
}
}
#[test]
fn test_get_contacts() {
unsafe {
let context = create_test_context();
let contacts = dc_get_contacts(&context.ctx, 0, to_cstring("some2").as_ptr());
assert_eq!(dc_array_get_cnt(contacts), 0);
dc_array_unref(contacts);
let id = dc_create_contact(
&context.ctx,
to_cstring("bob").as_ptr(),
to_cstring("bob@mail.de").as_ptr(),
);
assert_ne!(id, 0);
let contacts = dc_get_contacts(&context.ctx, 0, to_cstring("bob").as_ptr());
assert_eq!(dc_array_get_cnt(contacts), 1);
dc_array_unref(contacts);
let contacts = dc_get_contacts(&context.ctx, 0, to_cstring("alice").as_ptr());
assert_eq!(dc_array_get_cnt(contacts), 0);
dc_array_unref(contacts);
}
}
#[test]
fn test_arr_to_string() {
let arr2: [uint32_t; 4] = [