speex_sys/
lib.rs

1////////////////////////////////////////////////////////////////////////////////
2// Copyright (c) 2023.                                                         /
3// This Source Code Form is subject to the terms of the Mozilla Public License,/
4// v. 2.0. If a copy of the MPL was not distributed with this file, You can    /
5// obtain one at http://mozilla.org/MPL/2.0/.                                  /
6////////////////////////////////////////////////////////////////////////////////
7#![allow(non_upper_case_globals)]
8#![allow(non_camel_case_types)]
9#![allow(non_snake_case)]
10
11include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
12
13#[cfg(test)]
14mod test {
15    use super::*;
16    use std::ffi::{c_char, c_void, CStr};
17    use std::ptr::null;
18
19    #[test]
20    fn linked_correctly() {
21        let mut char_ptr: *const c_char = null();
22        let ptr = &mut char_ptr as *mut *const c_char;
23        let ptr = ptr as *mut c_void;
24        let c_str = unsafe {
25            speex_lib_ctl(SPEEX_LIB_GET_VERSION_STRING as i32, ptr);
26            CStr::from_ptr(char_ptr)
27        };
28        let version_str = format!("{c_str:?}");
29        assert_eq!(version_str, "\"speex-1.2.1\"".to_string())
30    }
31}