diff options
Diffstat (limited to 'tests/test_func.rs')
-rw-r--r-- | tests/test_func.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/test_func.rs b/tests/test_func.rs new file mode 100644 index 00000000..83bc2696 --- /dev/null +++ b/tests/test_func.rs @@ -0,0 +1,45 @@ +#[test] +fn func_ptr() { + assert_bind_eq!("headers/func_ptr.h", cx, + quote_item!(cx, + extern "C" { + pub static mut foo: ::std::option::Option< + extern "C" fn(x: ::libc::c_int, + y: ::libc::c_int) -> ::libc::c_int>; + } + ) + ); +} + +#[test] +fn func_ptr_in_struct() { + assert_bind_eq!("headers/func_ptr_in_struct.h", cx, + quote_item!(cx, + #[repr(C)] + #[deriving(Copy)] + pub struct Struct_Foo { + pub bar: ::std::option::Option< + extern "C" fn(x: ::libc::c_int, + y: ::libc::c_int) -> Enum_baz>, + } + ) + ); +} + +#[test] +fn func_proto() { + assert_bind_eq!("headers/func_proto.h", cx, + quote_item!(cx, + pub type foo = extern "C" fn(bar: ::libc::c_int) -> ::libc::c_int; + )); +} + +#[test] +fn with_func_ptr_arg() { + assert_bind_eq!("headers/func_with_func_ptr_arg.h", cx, + quote_item!(cx, + extern "C" { + pub fn foo(bar: ::std::option::Option<extern "C" fn()>); + } + )); +} |