cbqn_sys/
lib.rs

1// Copyright (C) 2022 Antti Keränen
2//
3// This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3.
4
5#![allow(non_upper_case_globals)]
6#![allow(non_camel_case_types)]
7#![allow(non_snake_case)]
8#[cfg(feature = "bindgen")]
9include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
10
11#[cfg(not(feature = "bindgen"))]
12mod pregenerated;
13
14#[cfg(not(feature = "bindgen"))]
15pub use pregenerated::*;
16
17#[cfg(test)]
18mod test {
19    use super::*;
20    use std::ffi::CString;
21
22    #[test]
23    fn test_bqn_ffi() {
24        let code = CString::new("2+2").unwrap();
25        let ret = unsafe {
26            bqn_init();
27            bqn_toF64(bqn_evalCStr(code.as_ptr()))
28        };
29        assert_eq!(ret, 4.0);
30    }
31}