1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#![crate_name = "objc_test_utils"]
#![crate_type = "lib"]
#[link(name = "Foundation", kind = "framework")]
extern { }
pub enum IntBlock { }
pub enum AddBlock { }
#[link(name="block_utils", kind="static")]
extern {
pub fn get_int_block() -> *mut IntBlock;
pub fn get_int_block_with(i: i32) -> *mut IntBlock;
pub fn get_add_block() -> *mut AddBlock;
pub fn get_add_block_with(i: i32) -> *mut AddBlock;
pub fn invoke_int_block(block: *mut IntBlock) -> i32;
pub fn invoke_add_block(block: *mut AddBlock, a: i32) -> i32;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_int_block() {
unsafe {
assert!(invoke_int_block(get_int_block()) == 7);
assert!(invoke_int_block(get_int_block_with(13)) == 13);
}
}
#[test]
fn test_add_block() {
unsafe {
assert!(invoke_add_block(get_add_block(), 5) == 12);
assert!(invoke_add_block(get_add_block_with(3), 5) == 8);
}
}
}