bitmagic_sys/
lib.rs

1#![allow(non_upper_case_globals)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![allow(dead_code)]
5#![allow(improper_ctypes)]
6#![allow(clippy::redundant_static_lifetimes)]
7#![allow(clippy::upper_case_acronyms)]
8
9#[cfg(feature = "bindgen")]
10include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
11
12#[cfg(not(feature = "bindgen"))]
13include!("bindings.rs");
14
15#[cfg(test)]
16mod tests {
17    use super::*;
18    use std::ptr;
19
20    #[test]
21    fn construction() {
22        unsafe {
23            BM_init(ptr::null_mut());
24
25            let mut h = ptr::null_mut();
26            let _res = BM_bvector_construct(&mut h, 100);
27            // TODO: check res
28            // BMERR_CHECK(res, "BM_bvector_construct()");
29
30            BM_bvector_free(h);
31        }
32    }
33
34    #[test]
35    fn resize() {
36        unsafe {
37            BM_init(ptr::null_mut());
38
39            let mut _res;
40            let size1 = 100000;
41            let size2 = 100000;
42            let mut size = 0;
43
44            let mut h = ptr::null_mut();
45            _res = BM_bvector_construct(&mut h, size1);
46            // TODO: check res
47
48            _res = BM_bvector_get_size(h, &mut size);
49            // TODO: check res
50            assert_eq!(size, size1);
51
52            _res = BM_bvector_set_size(h, size2);
53            // TODO: check res
54            _res = BM_bvector_get_size(h, &mut size);
55            // TODO: check res
56            assert_eq!(size, size2);
57
58            BM_bvector_free(h);
59        }
60    }
61}