//! Raw FFI bindings to the [ThorVG](https://github.com/thorvg/thorvg) vector graphics library.
//!
//! This crate provides unsafe, low-level bindings generated by `bindgen` from the ThorVG C API
//! (`thorvg_capi.h`). For a safe, idiomatic Rust API, use the [`thorvg`] crate instead.
//!
//! This crate is `no_std` compatible.

#![no_std]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
// Generated bindgen docs contain C-style identifiers
#![allow(clippy::doc_markdown)]

include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

#[cfg(test)]
mod tests {
    extern crate std;

    use super::*;

    #[test]
    fn test_engine_init_and_term() {
        unsafe {
            let result = tvg_engine_init(0);
            assert_eq!(result, Tvg_Result::TVG_RESULT_SUCCESS);

            let result = tvg_engine_term();
            assert_eq!(result, Tvg_Result::TVG_RESULT_SUCCESS);
        }
    }

    #[test]
    fn test_engine_version() {
        unsafe {
            let mut major: u32 = 0;
            let mut minor: u32 = 0;
            let mut micro: u32 = 0;
            let mut version: *const core::ffi::c_char = core::ptr::null();

            let result = tvg_engine_version(
                &raw mut major,
                &raw mut minor,
                &raw mut micro,
                &raw mut version,
            );
            assert_eq!(result, Tvg_Result::TVG_RESULT_SUCCESS);
            assert!(major >= 1);
        }
    }
}
