helics 0.1.0

helics.rs: Safe rust bindings to HELICS cosimulation library
use helics_sys;

use libc::c_char;
use std::ffi::CStr;
use std::str;

pub fn get_version() -> String {
    let c_buf: *const c_char = unsafe { helics_sys::helicsGetVersion() };
    let c_str: &CStr = unsafe { CStr::from_ptr(c_buf) };
    let str_slice: &str = c_str.to_str().unwrap();
    let str_buf: String = str_slice.to_owned(); // if necessary
    str_buf
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_helics_get_version() {
        assert_eq!(get_version(), "3.0.0-alpha.2 (2020-11-08)");
    }
}