Rust: Import unsafe funcs

This commit is contained in:
Alex Kotov 2022-01-31 09:43:27 +05:00
parent 01ee4fdf25
commit a9275430f2
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 17 additions and 0 deletions

View File

@ -1 +1,3 @@
mod ntoa;
pub use ntoa::*;

View File

@ -0,0 +1,15 @@
#[cfg(test)]
mod tests {
use std::ffi::CStr;
use kernaux_sys::{utoa10, UTOA10_BUFFER_SIZE};
#[test]
fn test_utoa10() {
let mut buffer: [i8; UTOA10_BUFFER_SIZE] = [0; UTOA10_BUFFER_SIZE];
unsafe { utoa10(123, buffer.as_mut_ptr()) };
let result =
unsafe { CStr::from_ptr(buffer.as_ptr()) }.to_str().unwrap();
assert_eq!(result, "123");
}
}