#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(clippy::all)]
#[cfg(feature = "regenerate-bindings")]
mod bindings {
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
}
#[cfg(not(feature = "regenerate-bindings"))]
#[path = "bindings.rs"]
mod bindings;
pub use bindings::*;
#[cfg(test)]
mod smoke {
use super::*;
use std::ffi::CStr;
use std::os::raw::c_char;
const METHANE_MOLFILE: &str = "\n inchi-sys\n\n 1 0 0 0 0 0 0 0 0 0999 V2000\n 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\nM END\n";
#[test]
fn methane_via_molfile_text() {
let moltext = std::ffi::CString::new(METHANE_MOLFILE).expect("no interior NUL");
let options = std::ffi::CString::new("").expect("no interior NUL");
let mut out: inchi_Output = unsafe { std::mem::zeroed() };
let rc = unsafe {
MakeINCHIFromMolfileText(moltext.as_ptr(), options.as_ptr() as *mut c_char, &mut out)
};
assert!(
rc == inchi_Ret_OKAY as i32 || rc == inchi_Ret_WARNING as i32,
"MakeINCHIFromMolfileText returned {rc}"
);
assert!(!out.szInChI.is_null(), "no InChI produced");
let inchi = unsafe { CStr::from_ptr(out.szInChI) }
.to_str()
.expect("InChI is valid UTF-8")
.to_owned();
unsafe { FreeINCHI(&mut out) };
assert_eq!(inchi, "InChI=1S/CH4/h1H4");
}
}