diff --git a/rust/src/lib.rs b/rust/src/lib.rs index a4bfe46..518419c 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -1,15 +1,28 @@ #![no_std] -use core::panic::PanicInfo; - /// This function is called on panic. +#[cfg(not(test))] #[panic_handler] -fn panic(_info: &PanicInfo) -> ! { +fn panic(_info: &core::panic::PanicInfo) -> ! { loop {} } - #[no_mangle] pub extern "C" fn get_rust_u8() -> u8 { - 9 -} + //9 + unsafe { get_c_u8() } +} + +extern "C" { + fn get_c_u8() -> u8; +} + +#[cfg(test)] +mod tests { + use crate::*; + + #[test] + fn it_works() { + assert_eq!(get_rust_u8(), 9); + } +} diff --git a/src/main.c b/src/main.c index a8860e5..18a28ee 100644 --- a/src/main.c +++ b/src/main.c @@ -58,6 +58,10 @@ #define MAX_LIST 20 +uint8_t get_c_u8(void) { + return 20; +} + struct glyph { int xoff;