diff --git a/rust/src/lib.rs b/rust/src/lib.rs index 283938a26..62a07bc7e 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -36,57 +36,3 @@ pub use palette::*; pub use pixel::*; pub use plane::*; pub use visual::*; - -// TODO: move tests out -#[cfg(test)] -mod tests { - use core::ptr::{null, null_mut}; - use cstr_core::{CStr, CString}; - - use libc_print::*; - use serial_test::serial; // serialize tests w/ nc::notcurses_init() - - use crate as nc; - - #[test] - #[serial] - fn get_notcurses_version() { - let c_str = unsafe { - let s = nc::notcurses_version(); - assert!(!s.is_null()); - CStr::from_ptr(s) - }; - let r_str = c_str.to_str().unwrap(); - libc_println!("rust-bound notcurses v{}", r_str); - } - - #[test] - #[serial] - fn create_notcurses_context() { - unsafe { - let _ = libc::setlocale(libc::LC_ALL, CString::new("").unwrap().as_ptr()); - let opts = nc::notcurses_options { - loglevel: 0, - termtype: null(), - renderfp: null_mut(), - margin_t: 0, - margin_r: 0, - margin_b: 0, - margin_l: 0, - flags: (nc::NCOPTION_NO_ALTERNATE_SCREEN | nc::NCOPTION_INHIBIT_SETLOCALE) as u64, - }; - let nc = nc::notcurses_init(&opts, null_mut()); - nc::notcurses_stop(nc); - } - } - - #[test] - #[serial] - fn create_direct_context() { - unsafe { - let _ = libc::setlocale(libc::LC_ALL, CString::new("").unwrap().as_ptr()); - let nc = nc::ncdirect_init(null_mut(), null_mut(), 0); - nc::ncdirect_stop(nc); - } - } -} diff --git a/rust/tests/notcurses.rs b/rust/tests/notcurses.rs new file mode 100644 index 000000000..85242ed18 --- /dev/null +++ b/rust/tests/notcurses.rs @@ -0,0 +1,49 @@ +use core::ptr::{null, null_mut}; +use cstr_core::{CStr, CString}; + +use libc_print::*; +use serial_test::serial; // serialize tests w/ nc::notcurses_init() + +use libnotcurses_sys as nc; + +#[test] +#[serial] +fn get_notcurses_version() { + let c_str = unsafe { + let s = nc::notcurses_version(); + assert!(!s.is_null()); + CStr::from_ptr(s) + }; + let r_str = c_str.to_str().unwrap(); + libc_println!("rust-bound notcurses v{}", r_str); +} + +#[test] +#[serial] +fn create_notcurses_context() { + unsafe { + let _ = libc::setlocale(libc::LC_ALL, CString::new("").unwrap().as_ptr()); + let opts = nc::notcurses_options { + loglevel: 0, + termtype: null(), + renderfp: null_mut(), + margin_t: 0, + margin_r: 0, + margin_b: 0, + margin_l: 0, + flags: (nc::NCOPTION_NO_ALTERNATE_SCREEN | nc::NCOPTION_INHIBIT_SETLOCALE) as u64, + }; + let nc = nc::notcurses_init(&opts, null_mut()); + nc::notcurses_stop(nc); + } +} + +#[test] +#[serial] +fn create_direct_context() { + unsafe { + let _ = libc::setlocale(libc::LC_ALL, CString::new("").unwrap().as_ptr()); + let nc = nc::ncdirect_init(null_mut(), null_mut(), 0); + nc::ncdirect_stop(nc); + } +}