mirror of
https://github.com/chatmail/core.git
synced 2026-04-29 03:16:29 +03:00
Merge pull request #106 from deltachat/split-stress
Split stress, part 2
This commit is contained in:
@@ -401,3 +401,98 @@ pub unsafe fn dc_arr_to_string(arr: *const uint32_t, cnt: libc::c_int) -> *mut l
|
||||
);
|
||||
strdup(to_cstring(res).as_ptr())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::ffi::CStr;
|
||||
|
||||
#[test]
|
||||
fn test_dc_array() {
|
||||
unsafe {
|
||||
let arr = dc_array_new(7 as size_t);
|
||||
assert_eq!(dc_array_get_cnt(arr), 0);
|
||||
|
||||
let mut i: libc::c_int = 0;
|
||||
while i < 1000 {
|
||||
dc_array_add_id(arr, (i + 2) as uint32_t);
|
||||
i += 1
|
||||
}
|
||||
|
||||
assert_eq!(dc_array_get_cnt(arr), 1000);
|
||||
|
||||
i = 0;
|
||||
|
||||
while i < 1000i32 {
|
||||
assert_eq!(
|
||||
dc_array_get_id(arr, i as size_t),
|
||||
(i + 1i32 * 2i32) as libc::c_uint
|
||||
);
|
||||
i += 1
|
||||
}
|
||||
|
||||
assert_eq!(dc_array_get_id(arr, -1i32 as size_t), 0);
|
||||
assert_eq!(dc_array_get_id(arr, 1000 as size_t), 0);
|
||||
assert_eq!(dc_array_get_id(arr, 1001 as size_t), 0);
|
||||
|
||||
dc_array_empty(arr);
|
||||
|
||||
assert_eq!(dc_array_get_cnt(arr), 0);
|
||||
|
||||
dc_array_add_id(arr, 13 as uint32_t);
|
||||
dc_array_add_id(arr, 7 as uint32_t);
|
||||
dc_array_add_id(arr, 666 as uint32_t);
|
||||
dc_array_add_id(arr, 0 as uint32_t);
|
||||
dc_array_add_id(arr, 5000 as uint32_t);
|
||||
|
||||
dc_array_sort_ids(arr);
|
||||
|
||||
assert_eq!(dc_array_get_id(arr, 0 as size_t), 0);
|
||||
assert_eq!(dc_array_get_id(arr, 1 as size_t), 7);
|
||||
assert_eq!(dc_array_get_id(arr, 2 as size_t), 13);
|
||||
assert_eq!(dc_array_get_id(arr, 3 as size_t), 666);
|
||||
|
||||
let str = dc_array_get_string(arr, b"-\x00" as *const u8 as *const libc::c_char);
|
||||
assert_eq!(
|
||||
CStr::from_ptr(str as *const libc::c_char).to_str().unwrap(),
|
||||
"0-7-13-666-5000"
|
||||
);
|
||||
free(str as *mut libc::c_void);
|
||||
|
||||
dc_array_empty(arr);
|
||||
|
||||
dc_array_add_ptr(
|
||||
arr,
|
||||
b"XX\x00" as *const u8 as *const libc::c_char as *mut libc::c_void,
|
||||
);
|
||||
dc_array_add_ptr(
|
||||
arr,
|
||||
b"item1\x00" as *const u8 as *const libc::c_char as *mut libc::c_void,
|
||||
);
|
||||
dc_array_add_ptr(
|
||||
arr,
|
||||
b"bbb\x00" as *const u8 as *const libc::c_char as *mut libc::c_void,
|
||||
);
|
||||
dc_array_add_ptr(
|
||||
arr,
|
||||
b"aaa\x00" as *const u8 as *const libc::c_char as *mut libc::c_void,
|
||||
);
|
||||
dc_array_sort_strings(arr);
|
||||
|
||||
let str = dc_array_get_ptr(arr, 0 as size_t) as *mut libc::c_char;
|
||||
assert_eq!(CStr::from_ptr(str).to_str().unwrap(), "XX");
|
||||
|
||||
let str = dc_array_get_ptr(arr, 1 as size_t) as *mut libc::c_char;
|
||||
assert_eq!(CStr::from_ptr(str).to_str().unwrap(), "aaa");
|
||||
|
||||
let str = dc_array_get_ptr(arr, 2 as size_t) as *mut libc::c_char;
|
||||
assert_eq!(CStr::from_ptr(str).to_str().unwrap(), "bbb");
|
||||
|
||||
let str = dc_array_get_ptr(arr, 3 as size_t) as *mut libc::c_char;
|
||||
assert_eq!(CStr::from_ptr(str).to_str().unwrap(), "item1");
|
||||
|
||||
dc_array_unref(arr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -372,3 +372,68 @@ pub unsafe fn dc_param_set_float(param: *mut dc_param_t, key: libc::c_int, value
|
||||
dc_param_set(param, key, value_str);
|
||||
free(value_str as *mut libc::c_void);
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::ffi::CStr;
|
||||
|
||||
#[test]
|
||||
fn test_dc_param() {
|
||||
unsafe {
|
||||
let p1: *mut dc_param_t = dc_param_new();
|
||||
dc_param_set_packed(
|
||||
p1,
|
||||
b"\r\n\r\na=1\nb=2\n\nc = 3 \x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
|
||||
assert_eq!(dc_param_get_int(p1, 'a' as i32, 0), 1);
|
||||
assert_eq!(dc_param_get_int(p1, 'b' as i32, 0), 2);
|
||||
assert_eq!(dc_param_get_int(p1, 'c' as i32, 0), 0);
|
||||
assert_eq!(dc_param_exists(p1, 'c' as i32), 0);
|
||||
|
||||
dc_param_set_int(p1, 'd' as i32, 4i32);
|
||||
|
||||
assert_eq!(dc_param_get_int(p1, 'd' as i32, 0), 4);
|
||||
|
||||
dc_param_empty(p1);
|
||||
dc_param_set(
|
||||
p1,
|
||||
'a' as i32,
|
||||
b"foo\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
dc_param_set_int(p1, 'b' as i32, 2i32);
|
||||
dc_param_set(p1, 'c' as i32, 0 as *const libc::c_char);
|
||||
dc_param_set_int(p1, 'd' as i32, 4i32);
|
||||
|
||||
assert_eq!(
|
||||
CStr::from_ptr((*p1).packed as *const libc::c_char)
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"a=foo\nb=2\nd=4"
|
||||
);
|
||||
|
||||
dc_param_set(p1, 'b' as i32, 0 as *const libc::c_char);
|
||||
|
||||
assert_eq!(
|
||||
CStr::from_ptr((*p1).packed as *const libc::c_char)
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"a=foo\nd=4",
|
||||
);
|
||||
|
||||
dc_param_set(p1, 'a' as i32, 0 as *const libc::c_char);
|
||||
dc_param_set(p1, 'd' as i32, 0 as *const libc::c_char);
|
||||
|
||||
assert_eq!(
|
||||
CStr::from_ptr((*p1).packed as *const libc::c_char)
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"",
|
||||
);
|
||||
|
||||
dc_param_unref(p1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -898,4 +898,62 @@ mod tests {
|
||||
unsafe { print_hex(hex.as_mut_ptr(), cur) };
|
||||
assert_eq!(to_string(hex.as_ptr() as *const _), "=3A");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dc_urlencode_urldecode() {
|
||||
unsafe {
|
||||
let buf1 =
|
||||
dc_urlencode(b"Bj\xc3\xb6rn Petersen\x00" as *const u8 as *const libc::c_char);
|
||||
|
||||
assert_eq!(
|
||||
CStr::from_ptr(buf1 as *const libc::c_char)
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"Bj%C3%B6rn+Petersen"
|
||||
);
|
||||
|
||||
let buf2 = dc_urldecode(buf1);
|
||||
|
||||
assert_eq!(
|
||||
strcmp(
|
||||
buf2,
|
||||
b"Bj\xc3\xb6rn Petersen\x00" as *const u8 as *const libc::c_char
|
||||
),
|
||||
0
|
||||
);
|
||||
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dc_encode_decode_modified_utf7() {
|
||||
unsafe {
|
||||
let buf1 = dc_encode_modified_utf7(
|
||||
b"Bj\xc3\xb6rn Petersen\x00" as *const u8 as *const libc::c_char,
|
||||
1,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
CStr::from_ptr(buf1 as *const libc::c_char)
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"Bj&APY-rn_Petersen"
|
||||
);
|
||||
|
||||
let buf2 = dc_decode_modified_utf7(buf1, 1);
|
||||
|
||||
assert_eq!(
|
||||
strcmp(
|
||||
buf2,
|
||||
b"Bj\xc3\xb6rn Petersen\x00" as *const u8 as *const libc::c_char
|
||||
),
|
||||
0
|
||||
);
|
||||
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1816,4 +1816,84 @@ mod tests {
|
||||
|
||||
unsafe { free(raw as *mut _) };
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dc_replace_bad_utf8_chars_1() {
|
||||
unsafe {
|
||||
let buf1 = strdup(b"ol\xc3\xa1 mundo <>\"\'& \xc3\xa4\xc3\x84\xc3\xb6\xc3\x96\xc3\xbc\xc3\x9c\xc3\x9f foo\xc3\x86\xc3\xa7\xc3\x87 \xe2\x99\xa6&noent;\x00" as *const u8 as *const libc::c_char);
|
||||
let buf2 = strdup(buf1);
|
||||
|
||||
dc_replace_bad_utf8_chars(buf2);
|
||||
|
||||
assert_eq!(strcmp(buf1, buf2), 0);
|
||||
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dc_replace_bad_utf8_chars_2() {
|
||||
unsafe {
|
||||
let buf1 = strdup(b"ISO-String with Ae: \xc4\x00" as *const u8 as *const libc::c_char);
|
||||
let buf2 = strdup(buf1);
|
||||
|
||||
dc_replace_bad_utf8_chars(buf2);
|
||||
|
||||
assert_eq!(
|
||||
CStr::from_ptr(buf2 as *const libc::c_char)
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"ISO-String with Ae: _"
|
||||
);
|
||||
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dc_replace_bad_utf8_chars_3() {
|
||||
unsafe {
|
||||
let buf1 = strdup(b"\x00" as *const u8 as *const libc::c_char);
|
||||
let buf2 = strdup(buf1);
|
||||
|
||||
dc_replace_bad_utf8_chars(buf2);
|
||||
|
||||
assert_eq!(*buf2.offset(0), 0);
|
||||
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dc_replace_bad_utf8_chars_4() {
|
||||
unsafe {
|
||||
dc_replace_bad_utf8_chars(0 as *mut libc::c_char);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dc_create_id() {
|
||||
unsafe {
|
||||
let buf = dc_create_id();
|
||||
assert_eq!(strlen(buf), 11);
|
||||
free(buf as *mut libc::c_void);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_dc_utf8_strlen() {
|
||||
unsafe {
|
||||
assert_eq!(
|
||||
dc_utf8_strlen(b"c\x00" as *const u8 as *const libc::c_char),
|
||||
1
|
||||
);
|
||||
assert_eq!(
|
||||
dc_utf8_strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char),
|
||||
1
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
594
tests/stress.rs
594
tests/stress.rs
@@ -19,7 +19,6 @@ use deltachat::dc_qr::*;
|
||||
use deltachat::dc_saxparser::*;
|
||||
use deltachat::dc_securejoin::*;
|
||||
use deltachat::dc_strbuilder::*;
|
||||
use deltachat::dc_strencode::*;
|
||||
use deltachat::dc_tools::*;
|
||||
use deltachat::key::*;
|
||||
use deltachat::keyring::*;
|
||||
@@ -413,599 +412,6 @@ unsafe fn stress_functions(context: &Context) {
|
||||
free(fn0 as *mut libc::c_void);
|
||||
free(fn1 as *mut libc::c_void);
|
||||
}
|
||||
|
||||
let mut buf1: *mut libc::c_char =
|
||||
strdup(b"ol\xc3\xa1 mundo <>\"\'& \xc3\xa4\xc3\x84\xc3\xb6\xc3\x96\xc3\xbc\xc3\x9c\xc3\x9f foo\xc3\x86\xc3\xa7\xc3\x87 \xe2\x99\xa6&noent;\x00"
|
||||
as *const u8 as *const libc::c_char);
|
||||
let mut buf2: *mut libc::c_char = strdup(buf1);
|
||||
dc_replace_bad_utf8_chars(buf2);
|
||||
if 0 != !(strcmp(buf1, buf2) == 0i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
512i32,
|
||||
b"strcmp(buf1, buf2)==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
buf1 = strdup(b"ISO-String with Ae: \xc4\x00" as *const u8 as *const libc::c_char);
|
||||
buf2 = strdup(buf1);
|
||||
dc_replace_bad_utf8_chars(buf2);
|
||||
if 0 != !(strcmp(
|
||||
b"ISO-String with Ae: _\x00" as *const u8 as *const libc::c_char,
|
||||
buf2,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
517i32,
|
||||
b"strcmp(\"ISO-String with Ae: _\", buf2)==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
buf1 = strdup(b"\x00" as *const u8 as *const libc::c_char);
|
||||
buf2 = strdup(buf1);
|
||||
dc_replace_bad_utf8_chars(buf2);
|
||||
if 0 != !(*buf2.offset(0isize) as libc::c_int == 0i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
522i32,
|
||||
b"buf2[0]==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
dc_replace_bad_utf8_chars(0 as *mut libc::c_char);
|
||||
buf1 = dc_urlencode(b"Bj\xc3\xb6rn Petersen\x00" as *const u8 as *const libc::c_char);
|
||||
if 0 != !(strcmp(
|
||||
buf1,
|
||||
b"Bj%C3%B6rn+Petersen\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
528i32,
|
||||
b"strcmp(buf1, \"Bj%C3%B6rn+Petersen\") == 0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
buf2 = dc_urldecode(buf1);
|
||||
if 0 != !(strcmp(
|
||||
buf2,
|
||||
b"Bj\xc3\xb6rn Petersen\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
530i32,
|
||||
b"strcmp(buf2, \"Bj\xc3\xb6rn Petersen\") == 0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
buf1 = dc_create_id();
|
||||
if 0 != !(strlen(buf1) == 11) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
534i32,
|
||||
b"strlen(buf1) == DC_CREATE_ID_LEN\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
free(buf1 as *mut libc::c_void);
|
||||
buf1 = dc_encode_modified_utf7(
|
||||
b"Bj\xc3\xb6rn Petersen\x00" as *const u8 as *const libc::c_char,
|
||||
1i32,
|
||||
);
|
||||
if 0 != !(strcmp(
|
||||
buf1,
|
||||
b"Bj&APY-rn_Petersen\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
600i32,
|
||||
b"strcmp(buf1, \"Bj&APY-rn_Petersen\")==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
buf2 = dc_decode_modified_utf7(buf1, 1i32);
|
||||
if 0 != !(strcmp(
|
||||
buf2,
|
||||
b"Bj\xc3\xb6rn Petersen\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
602i32,
|
||||
b"strcmp(buf2, \"Bj\xc3\xb6rn Petersen\")==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
free(buf1 as *mut libc::c_void);
|
||||
free(buf2 as *mut libc::c_void);
|
||||
if 0 != !(2100i32 == 2100i32 || 2100i32 == 2052i32 || 2100i32 == 2055i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
606i32,
|
||||
b"DC_EVENT_DATA1_IS_STRING(2100)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(2052i32 == 2100i32 || 2052i32 == 2052i32 || 2052i32 == 2055i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
607i32,
|
||||
b"DC_EVENT_DATA1_IS_STRING(2052)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != (100i32 == 2100i32 || 100i32 == 2052i32 || 100i32 == 2055i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
608i32,
|
||||
b"!DC_EVENT_DATA1_IS_STRING(100)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != (300i32 == 2100i32 || 300i32 == 2052i32 || 300i32 == 2055i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
609i32,
|
||||
b"!DC_EVENT_DATA1_IS_STRING(300)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != (400i32 == 2100i32 || 400i32 == 2052i32 || 400i32 == 2055i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
610i32,
|
||||
b"!DC_EVENT_DATA1_IS_STRING(400)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(100i32 >= 100i32 && 100i32 <= 499i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
612i32,
|
||||
b"DC_EVENT_DATA2_IS_STRING(100)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(300i32 >= 100i32 && 300i32 <= 499i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
613i32,
|
||||
b"DC_EVENT_DATA2_IS_STRING(300)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(400i32 >= 100i32 && 400i32 <= 499i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
614i32,
|
||||
b"DC_EVENT_DATA2_IS_STRING(400)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != (2010i32 >= 100i32 && 2010i32 <= 499i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
615i32,
|
||||
b"!DC_EVENT_DATA2_IS_STRING(2010)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(2091i32 == 2091i32 || 2091i32 == 2100i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
617i32,
|
||||
b"DC_EVENT_RETURNS_STRING(2091)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(2100i32 == 2091i32 || 2100i32 == 2100i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
618i32,
|
||||
b"DC_EVENT_RETURNS_STRING(2100)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != (100i32 == 2091i32 || 100i32 == 2100i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
619i32,
|
||||
b"!DC_EVENT_RETURNS_STRING(100)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != (300i32 == 2091i32 || 300i32 == 2100i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
620i32,
|
||||
b"!DC_EVENT_RETURNS_STRING(300)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != (400i32 == 2091i32 || 400i32 == 2100i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
621i32,
|
||||
b"!DC_EVENT_RETURNS_STRING(400)\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(dc_utf8_strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1
|
||||
&& strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
623i32,
|
||||
b"dc_utf8_strlen(\"c\")==1 && strlen(\"c\")==1\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(dc_utf8_strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) == 1
|
||||
&& strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) == 2) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
624i32,
|
||||
b"dc_utf8_strlen(\"\xc3\xa4\")==1 && strlen(\"\xc3\xa4\")==2\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
let arr = dc_array_new(7i32 as size_t);
|
||||
if 0 != !(dc_array_get_cnt(arr) == 0) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
633i32,
|
||||
b"dc_array_get_cnt(arr) == 0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
let mut i: libc::c_int = 0;
|
||||
while i < 1000i32 {
|
||||
dc_array_add_id(arr, (i + 1i32 * 2i32) as uint32_t);
|
||||
i += 1
|
||||
}
|
||||
if 0 != !(dc_array_get_cnt(arr) == 1000) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
639i32,
|
||||
b"dc_array_get_cnt(arr) == TEST_CNT\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
i = 0i32;
|
||||
while i < 1000i32 {
|
||||
if 0 != !(dc_array_get_id(arr, i as size_t) == (i + 1i32 * 2i32) as libc::c_uint) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
642i32,
|
||||
b"dc_array_get_id(arr, i) == i+1*2\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
i += 1
|
||||
}
|
||||
if 0 != !(dc_array_get_id(arr, -1i32 as size_t) == 0i32 as libc::c_uint) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
644i32,
|
||||
b"dc_array_get_id(arr, -1) == 0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(dc_array_get_id(arr, 1000i32 as size_t) == 0i32 as libc::c_uint) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
645i32,
|
||||
b"dc_array_get_id(arr, TEST_CNT) == 0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(dc_array_get_id(arr, (1000i32 + 1i32) as size_t) == 0i32 as libc::c_uint) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
646i32,
|
||||
b"dc_array_get_id(arr, TEST_CNT+1) == 0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
dc_array_empty(arr);
|
||||
if 0 != !(dc_array_get_cnt(arr) == 0) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
649i32,
|
||||
b"dc_array_get_cnt(arr) == 0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
dc_array_add_id(arr, 13i32 as uint32_t);
|
||||
dc_array_add_id(arr, 7i32 as uint32_t);
|
||||
dc_array_add_id(arr, 666i32 as uint32_t);
|
||||
dc_array_add_id(arr, 0i32 as uint32_t);
|
||||
dc_array_add_id(arr, 5000i32 as uint32_t);
|
||||
dc_array_sort_ids(arr);
|
||||
if 0 != !(dc_array_get_id(arr, 0i32 as size_t) == 0i32 as libc::c_uint
|
||||
&& dc_array_get_id(arr, 1i32 as size_t) == 7i32 as libc::c_uint
|
||||
&& dc_array_get_id(arr, 2i32 as size_t) == 13i32 as libc::c_uint
|
||||
&& dc_array_get_id(arr, 3i32 as size_t) == 666i32 as libc::c_uint) as usize
|
||||
{
|
||||
__assert_rtn((*::std::mem::transmute::<&[u8; 17],
|
||||
&[libc::c_char; 17]>(b"stress_functions\x00")).as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as
|
||||
*const libc::c_char, 657i32,
|
||||
b"dc_array_get_id(arr, 0)==0 && dc_array_get_id(arr, 1)==7 && dc_array_get_id(arr, 2)==13 && dc_array_get_id(arr, 3)==666\x00"
|
||||
as *const u8 as *const libc::c_char);
|
||||
} else {
|
||||
};
|
||||
let str_0 = dc_array_get_string(arr, b"-\x00" as *const u8 as *const libc::c_char);
|
||||
if 0 != !(strcmp(
|
||||
str_0,
|
||||
b"0-7-13-666-5000\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
660i32,
|
||||
b"strcmp(str, \"0-7-13-666-5000\")==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
free(str_0 as *mut libc::c_void);
|
||||
dc_array_empty(arr);
|
||||
dc_array_add_ptr(
|
||||
arr,
|
||||
b"XX\x00" as *const u8 as *const libc::c_char as *mut libc::c_void,
|
||||
);
|
||||
dc_array_add_ptr(
|
||||
arr,
|
||||
b"item1\x00" as *const u8 as *const libc::c_char as *mut libc::c_void,
|
||||
);
|
||||
dc_array_add_ptr(
|
||||
arr,
|
||||
b"bbb\x00" as *const u8 as *const libc::c_char as *mut libc::c_void,
|
||||
);
|
||||
dc_array_add_ptr(
|
||||
arr,
|
||||
b"aaa\x00" as *const u8 as *const libc::c_char as *mut libc::c_void,
|
||||
);
|
||||
dc_array_sort_strings(arr);
|
||||
if 0 != !(strcmp(
|
||||
b"XX\x00" as *const u8 as *const libc::c_char,
|
||||
dc_array_get_ptr(arr, 0i32 as size_t) as *mut libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
674i32,
|
||||
b"strcmp(\"XX\", (char*)dc_array_get_ptr(arr, 0))==0\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(strcmp(
|
||||
b"aaa\x00" as *const u8 as *const libc::c_char,
|
||||
dc_array_get_ptr(arr, 1i32 as size_t) as *mut libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
675i32,
|
||||
b"strcmp(\"aaa\", (char*)dc_array_get_ptr(arr, 1))==0\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(strcmp(
|
||||
b"bbb\x00" as *const u8 as *const libc::c_char,
|
||||
dc_array_get_ptr(arr, 2i32 as size_t) as *mut libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
676i32,
|
||||
b"strcmp(\"bbb\", (char*)dc_array_get_ptr(arr, 2))==0\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(strcmp(
|
||||
b"item1\x00" as *const u8 as *const libc::c_char,
|
||||
dc_array_get_ptr(arr, 3i32 as size_t) as *mut libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
677i32,
|
||||
b"strcmp(\"item1\", (char*)dc_array_get_ptr(arr, 3))==0\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
dc_array_unref(arr);
|
||||
let p1: *mut dc_param_t = dc_param_new();
|
||||
dc_param_set_packed(
|
||||
p1,
|
||||
b"\r\n\r\na=1\nb=2\n\nc = 3 \x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
if 0 != !(dc_param_get_int(p1, 'a' as i32, 0i32) == 1i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
690i32,
|
||||
b"dc_param_get_int(p1, \'a\', 0)==1\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(dc_param_get_int(p1, 'b' as i32, 0i32) == 2i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
691i32,
|
||||
b"dc_param_get_int(p1, \'b\', 0)==2\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(dc_param_get_int(p1, 'c' as i32, 0i32) == 0i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
692i32,
|
||||
b"dc_param_get_int(p1, \'c\', 0)==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
if 0 != !(dc_param_exists(p1, 'c' as i32) == 0i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
693i32,
|
||||
b"dc_param_exists (p1, \'c\')==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
dc_param_set_int(p1, 'd' as i32, 4i32);
|
||||
if 0 != !(dc_param_get_int(p1, 'd' as i32, 0i32) == 4i32) as usize {
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
696i32,
|
||||
b"dc_param_get_int(p1, \'d\', 0)==4\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
dc_param_empty(p1);
|
||||
dc_param_set(
|
||||
p1,
|
||||
'a' as i32,
|
||||
b"foo\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
dc_param_set_int(p1, 'b' as i32, 2i32);
|
||||
dc_param_set(p1, 'c' as i32, 0 as *const libc::c_char);
|
||||
dc_param_set_int(p1, 'd' as i32, 4i32);
|
||||
if 0 != !(strcmp(
|
||||
(*p1).packed,
|
||||
b"a=foo\nb=2\nd=4\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0i32) as usize
|
||||
{
|
||||
__assert_rtn(
|
||||
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
|
||||
.as_ptr(),
|
||||
b"../cmdline/stress.c\x00" as *const u8 as *const libc::c_char,
|
||||
703i32,
|
||||
b"strcmp(p1->packed, \"a=foo\\nb=2\\nd=4\")==0\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
} else {
|
||||
};
|
||||
|
||||
dc_param_set(p1, 'b' as i32, 0 as *const libc::c_char);
|
||||
|
||||
assert_eq!(
|
||||
CStr::from_ptr((*p1).packed as *const libc::c_char)
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"a=foo\nd=4",
|
||||
);
|
||||
|
||||
dc_param_set(p1, 'a' as i32, 0 as *const libc::c_char);
|
||||
dc_param_set(p1, 'd' as i32, 0 as *const libc::c_char);
|
||||
|
||||
assert_eq!(
|
||||
CStr::from_ptr((*p1).packed as *const libc::c_char)
|
||||
.to_str()
|
||||
.unwrap(),
|
||||
"",
|
||||
);
|
||||
|
||||
dc_param_unref(p1);
|
||||
|
||||
let mut keys: *mut libc::c_char = dc_get_config(
|
||||
context,
|
||||
b"sys.config_keys\x00" as *const u8 as *const libc::c_char,
|
||||
|
||||
Reference in New Issue
Block a user